diff options
author | Anders Carlsson <andersca@mac.com> | 2009-12-09 03:01:51 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-12-09 03:01:51 +0000 |
commit | b6cc91be4da4f55c7e3dca87ecfdb532b33c83ca (patch) | |
tree | 2464c7a7cd676c431220df9f65891499ce5cb050 /lib/Sema/SemaDeclCXX.cpp | |
parent | 17f4da8f150f6b9dfb571cebd6299b06948e5385 (diff) |
Pass the current SourceLocation to getAssignOperatorMethod, fixing a crash when the assign operator method needs to be instantiated. Doug, please review the updated default-assignment-operator.cpp change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90935 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 3a3bf3e9c1..6f8a4f16d3 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3387,7 +3387,8 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation, CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); if (CXXMethodDecl *BaseAssignOpMethod = - getAssignOperatorMethod(MethodDecl->getParamDecl(0), BaseClassDecl)) + getAssignOperatorMethod(CurrentLocation, MethodDecl->getParamDecl(0), + BaseClassDecl)) MarkDeclarationReferenced(CurrentLocation, BaseAssignOpMethod); } for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(), @@ -3399,7 +3400,8 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation, CXXRecordDecl *FieldClassDecl = cast<CXXRecordDecl>(FieldClassType->getDecl()); if (CXXMethodDecl *FieldAssignOpMethod = - getAssignOperatorMethod(MethodDecl->getParamDecl(0), FieldClassDecl)) + getAssignOperatorMethod(CurrentLocation, MethodDecl->getParamDecl(0), + FieldClassDecl)) MarkDeclarationReferenced(CurrentLocation, FieldAssignOpMethod); } else if (FieldType->isReferenceType()) { Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign) @@ -3420,7 +3422,8 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation, } CXXMethodDecl * -Sema::getAssignOperatorMethod(ParmVarDecl *ParmDecl, +Sema::getAssignOperatorMethod(SourceLocation CurrentLocation, + ParmVarDecl *ParmDecl, CXXRecordDecl *ClassDecl) { QualType LHSType = Context.getTypeDeclType(ClassDecl); QualType RHSType(LHSType); @@ -3430,18 +3433,17 @@ Sema::getAssignOperatorMethod(ParmVarDecl *ParmDecl, RHSType = Context.getCVRQualifiedType(RHSType, ParmDecl->getType().getCVRQualifiers()); ExprOwningPtr<Expr> LHS(this, new (Context) DeclRefExpr(ParmDecl, - LHSType, - SourceLocation())); + LHSType, + SourceLocation())); ExprOwningPtr<Expr> RHS(this, new (Context) DeclRefExpr(ParmDecl, - RHSType, - SourceLocation())); + RHSType, + CurrentLocation)); Expr *Args[2] = { &*LHS, &*RHS }; OverloadCandidateSet CandidateSet; AddMemberOperatorCandidates(clang::OO_Equal, SourceLocation(), Args, 2, CandidateSet); OverloadCandidateSet::iterator Best; - if (BestViableFunction(CandidateSet, - ClassDecl->getLocation(), Best) == OR_Success) + if (BestViableFunction(CandidateSet, CurrentLocation, Best) == OR_Success) return cast<CXXMethodDecl>(Best->Function); assert(false && "getAssignOperatorMethod - copy assignment operator method not found"); |