[PATCH] D69533: Thread safety analysis: Peel away NoOp implicit casts in initializers
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 29 17:45:49 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae3159e49793: Thread safety analysis: Peel away NoOp implicit casts in initializers (authored by aaronpuchert).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69533/new/
https://reviews.llvm.org/D69533
Files:
clang/lib/Analysis/ThreadSafety.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp
Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===================================================================
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -3051,6 +3051,20 @@
int b = a; // expected-warning {{reading variable 'a' requires holding mutex 'getMutexPtr()'}}
}
+#ifdef __cpp_guaranteed_copy_elision
+
+void guaranteed_copy_elision() {
+ MutexLock lock = MutexLock{&sls_mu};
+ sls_guard_var = 0;
+}
+
+void guaranteed_copy_elision_const() {
+ const MutexLock lock = MutexLock{&sls_mu};
+ sls_guard_var = 0;
+}
+
+#endif
+
} // end namespace TemporaryCleanupExpr
Index: clang/lib/Analysis/ThreadSafety.cpp
===================================================================
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -2142,6 +2142,9 @@
// handle constructors that involve temporaries
if (auto *EWC = dyn_cast<ExprWithCleanups>(E))
E = EWC->getSubExpr();
+ if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
+ if (ICE->getCastKind() == CK_NoOp)
+ E = ICE->getSubExpr();
if (auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
E = BTE->getSubExpr();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69533.227002.patch
Type: text/x-patch
Size: 1250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191030/40730e08/attachment.bin>
More information about the cfe-commits
mailing list