diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-09 16:51:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-09 16:51:10 +0000 |
commit | bbcb7ea8a062a8f1d5cb504e4518a5d4fbab873a (patch) | |
tree | 8ce1dc6a5b845b22a92e4e529f3343013b8a6458 /lib/Sema/SemaChecking.cpp | |
parent | 99107ebc0a5aea953b736e12757e0919d5249d43 (diff) |
When type-checking a call to an overloaded, builtin atomic operation,
construct a new DeclRefExpr rather than re-using the existing
DeclRefExpr. Patch by Likai Liu, fixes PR8345.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index b1a87a83dc..68e25e7f4e 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -614,13 +614,20 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { TheCall->setArg(i+1, Arg.get()); } - // Switch the DeclRefExpr to refer to the new decl. - DRE->setDecl(NewBuiltinDecl); - DRE->setType(NewBuiltinDecl->getType()); + ASTContext& Context = this->getASTContext(); + + // Create a new DeclRefExpr to refer to the new decl. + DeclRefExpr* NewDRE = DeclRefExpr::Create( + Context, + DRE->getQualifierLoc(), + NewBuiltinDecl, + DRE->getLocation(), + NewBuiltinDecl->getType(), + DRE->getValueKind()); // Set the callee in the CallExpr. // FIXME: This leaks the original parens and implicit casts. - ExprResult PromotedCall = UsualUnaryConversions(DRE); + ExprResult PromotedCall = UsualUnaryConversions(NewDRE); if (PromotedCall.isInvalid()) return ExprError(); TheCall->setCallee(PromotedCall.take()); |