aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/ThreadSafety.cpp
diff options
context:
space:
mode:
authorAaron Puchert <aaronpuchert@alice-dsl.net>2020-10-30 00:35:14 +0100
committerAaron Puchert <aaronpuchert@alice-dsl.net>2020-10-30 00:35:14 +0100
commitbbed8cfe80cd27d3a47d877c7608d9be4e487d97 (patch)
tree47dd93d6529a17d84a3f51e82b0ce422fb550743 /clang/lib/Analysis/ThreadSafety.cpp
parent99f2779c18c8dcd24eaa7edf1f32c59593954cf1 (diff)
downloadllvm-bbed8cfe80cd27d3a47d877c7608d9be4e487d97.zip
llvm-bbed8cfe80cd27d3a47d877c7608d9be4e487d97.tar.gz
llvm-bbed8cfe80cd27d3a47d877c7608d9be4e487d97.tar.bz2
Thread safety analysis: Consider static class members as inaccessible
This fixes the issue pointed out in D84604#2363134. For now we exclude static members completely, we'll take them into account later.
Diffstat (limited to 'clang/lib/Analysis/ThreadSafety.cpp')
-rw-r--r--clang/lib/Analysis/ThreadSafety.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 65d410a..21583e9 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1269,10 +1269,16 @@ bool ThreadSafetyAnalyzer::inCurrentScope(const CapabilityExpr &CapE) {
const threadSafety::til::SExpr *SExp = CapE.sexpr();
assert(SExp && "Null expressions should be ignored");
- // Global variables are always in scope.
if (const auto *LP = dyn_cast<til::LiteralPtr>(SExp)) {
const ValueDecl *VD = LP->clangDecl();
- return VD->isDefinedOutsideFunctionOrMethod();
+ // Variables defined in a function are always inaccessible.
+ if (!VD->isDefinedOutsideFunctionOrMethod())
+ return false;
+ // For now we consider static class members to be inaccessible.
+ if (isa<CXXRecordDecl>(VD->getDeclContext()))
+ return false;
+ // Global variables are always in scope.
+ return true;
}
// Members are in scope from methods of the same class.