[PATCH] D87194: Thread safety analysis: Use access specifiers to decide about scope
Jordan Rupprecht via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 15:20:28 PST 2020
rupprecht added a comment.
In D87194#2369485 <https://reviews.llvm.org/D87194#2369485>, @aaronpuchert wrote:
> @rupprecht, maybe you can try it again?
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)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87194/new/
https://reviews.llvm.org/D87194
More information about the cfe-commits
mailing list