Public members are always in scope, protected members in derived classes
with sufficient access.
Details
- Reviewers
aaron.ballman
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
| Time | Test | |
|---|---|---|
| 400 ms | linux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp |
Event Timeline
| clang/lib/Analysis/ThreadSafety.cpp | ||
|---|---|---|
| 1317 | This should probably have a FIXME? | |
| 1323–1325 | llvm::any_of()? | |
| clang/test/SemaCXX/warn-thread-safety-negative.cpp | ||
| 168 | Given that this is touching on declaration contexts, it would also be good to have some tests checking for differences between declaration contexts (like out-of-line method definitions) | |
| clang/test/SemaCXX/warn-thread-safety-negative.cpp | ||
|---|---|---|
| 168 | Isn't there a semantic and a lexical declaration context, and aren't we consistently using the semantic context? | |
Some more interesting errors this time :)
The ones I originally saw look correct now (i.e. it's flagging the things that are valid, but not the things out of visibility). I tried building the rest of this package, and I guess scoping isn't considered in this case though?
class Foo {
public:
static void Bar();
private:
struct Params {
Mutex mu_;
}
static Params* GetParams();
};
// In the .cc file:
void Foo::Bar() {
Params& params = *GetParams();
MutexLock lock(params.mu_); // error: acquiring mutex 'params.mu_' requires negative capability '!params.mu_'
}
/* static */ Params* Foo::GetParams() {
static Params params;
return ¶ms;
}On one hand, it's totally valid. On the other hand, annotating the method like static void Bar() REQUIRES(!params.mu_); isn't possible because params is a local variable.
(I'm new to threading analysis, so maybe I'm just using the wrong annotations)
That's a good point, while mu_ is public, params is a local variable.
I need to take into account the left-hand side of a til::Project, which we're currently ignoring.
This should probably have a FIXME?