[PATCH] D76943: [clang analysis] Make mutex guard detection more reliable.
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 30 11:58:09 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24485aec4750: [clang analysis] Make mutex guard detection more reliable. (authored by efriedma).
Changed prior to commit:
https://reviews.llvm.org/D76943?vs=253253&id=253657#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76943/new/
https://reviews.llvm.org/D76943
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
@@ -5648,6 +5648,22 @@
auto ptr = get();
return ptr->f();
}
+ void use_constructor() {
+ auto ptr = ReadLockedPtr<Object>(nullptr);
+ ptr->f();
+ auto ptr2 = ReadLockedPtr<Object>{nullptr};
+ ptr2->f();
+ auto ptr3 = (ReadLockedPtr<Object>{nullptr});
+ ptr3->f();
+ }
+ struct Convertible {
+ Convertible();
+ operator ReadLockedPtr<Object>();
+ };
+ void use_conversion() {
+ ReadLockedPtr<Object> ptr = Convertible();
+ ptr->f();
+ }
}
namespace PR38640 {
Index: clang/lib/Analysis/ThreadSafety.cpp
===================================================================
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -2139,12 +2139,14 @@
// 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();
+ E = EWC->getSubExpr()->IgnoreParens();
+ if (auto *CE = dyn_cast<CastExpr>(E))
+ if (CE->getCastKind() == CK_NoOp ||
+ CE->getCastKind() == CK_ConstructorConversion ||
+ CE->getCastKind() == CK_UserDefinedConversion)
+ E = CE->getSubExpr()->IgnoreParens();
if (auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
- E = BTE->getSubExpr();
+ E = BTE->getSubExpr()->IgnoreParens();
if (const auto *CE = dyn_cast<CXXConstructExpr>(E)) {
const auto *CtorD = dyn_cast_or_null<NamedDecl>(CE->getConstructor());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76943.253657.patch
Type: text/x-patch
Size: 1827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200330/61e67ad9/attachment-0001.bin>
More information about the cfe-commits
mailing list