diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp index ef48ae439c5f3..89a3087a59247 100644 --- a/clang/lib/Analysis/ThreadSafetyCommon.cpp +++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp @@ -394,6 +394,13 @@ til::SExpr *SExprBuilder::translateDeclRefExpr(const DeclRefExpr *DRE, if (const auto *VarD = dyn_cast(VD)) return translateVariable(VarD, Ctx); + if (const auto *FD = dyn_cast(VD)) { + if (Ctx && Ctx->SelfArg) { + til::SExpr *E = new (Arena) til::SApply(SelfVar); + return new (Arena) til::Project(E, FD); + } + } + // For non-local variables, treat it as a reference to a named object. return new (Arena) til::LiteralPtr(VD); } diff --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp index 0e91639a271c5..f68699f701851 100644 --- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -3590,14 +3590,10 @@ void requireDecl(RelockableScope &scope) { struct foo { Mutex mu; - // expected-note@+1{{see attribute on parameter here}} void require(RelockableScope &scope EXCLUSIVE_LOCKS_REQUIRED(mu)); void callRequire(){ RelockableScope scope(&mu); - // TODO: False positive due to incorrect parsing of parameter attribute arguments. require(scope); - // expected-warning@-1{{calling function 'require' requires holding mutex 'mu' exclusively}} - // expected-warning@-2{{mutex managed by 'scope' is 'mu' instead of 'mu'}} } };