r232425 - Take the non-reference type when constructing a dummy expression.
Richard Trieu
rtrieu at google.com
Mon Mar 16 14:49:43 PDT 2015
Author: rtrieu
Date: Mon Mar 16 16:49:43 2015
New Revision: 232425
URL: http://llvm.org/viewvc/llvm-project?rev=232425&view=rev
Log:
Take the non-reference type when constructing a dummy expression.
Otherwise, Expr will assert during construction with a reference type.
Added:
cfe/trunk/test/SemaCXX/thread-safety-reference-handling.cpp
Modified:
cfe/trunk/lib/Analysis/ThreadSafety.cpp
Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=232425&r1=232424&r2=232425&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Mon Mar 16 16:49:43 2015
@@ -2306,8 +2306,8 @@ void ThreadSafetyAnalyzer::runAnalysis(A
// Create a dummy expression,
VarDecl *VD = const_cast<VarDecl*>(AD.getVarDecl());
- DeclRefExpr DRE(VD, false, VD->getType(), VK_LValue,
- AD.getTriggerStmt()->getLocEnd());
+ DeclRefExpr DRE(VD, false, VD->getType().getNonReferenceType(),
+ VK_LValue, AD.getTriggerStmt()->getLocEnd());
LocksetBuilder.handleCall(&DRE, DD);
break;
}
Added: cfe/trunk/test/SemaCXX/thread-safety-reference-handling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/thread-safety-reference-handling.cpp?rev=232425&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/thread-safety-reference-handling.cpp (added)
+++ cfe/trunk/test/SemaCXX/thread-safety-reference-handling.cpp Mon Mar 16 16:49:43 2015
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety-analysis -std=c++11 %s
+// expected-no-diagnostics
+
+class Base {
+public:
+ Base() {}
+ virtual ~Base();
+};
+
+class S : public Base {
+public:
+ ~S() override = default;
+};
+
+void Test() {
+ const S &s = S();
+}
More information about the cfe-commits
mailing list