================
@@ -215,32 +151,38 @@ class SuppressNonBlockingStreams : public
BugReporterVisitor {
class BlockInCriticalSectionChecker
: public Checker<check::PostCall, eval::Call> {
private:
- const std::array<MutexDescriptor, 9> MutexDescriptors{
+ const CallDescriptionMap<ThreadingCallDescription> ThreadingCalls{
// NOTE: There are standard library implementations where some methods
// of `std::mutex` are inherited from an implementation detail base
// class, and those aren't matched by the name specification {"std",
// "mutex", "lock"}.
// As a workaround here we omit the class name and only require the
// presence of the name parts "std" and "lock"/"unlock".
// TODO: Ensure that CallDescription understands inherited methods.
- MemberMutexDescriptor(
- {/*MatchAs=*/CDM::CXXMethod,
- /*QualifiedName=*/{"std", /*"mutex",*/ "lock"},
- /*RequiredArgs=*/0},
- {CDM::CXXMethod, {"std", /*"mutex",*/ "unlock"}, 0}),
- FirstArgMutexDescriptor({CDM::CLibrary, {"pthread_mutex_lock"}, 1},
- {CDM::CLibrary, {"pthread_mutex_unlock"}, 1}),
- FirstArgMutexDescriptor({CDM::CLibrary, {"mtx_lock"}, 1},
- {CDM::CLibrary, {"mtx_unlock"}, 1}),
- FirstArgMutexDescriptor({CDM::CLibrary, {"pthread_mutex_trylock"}, 1},
- {CDM::CLibrary, {"pthread_mutex_unlock"}, 1}),
- FirstArgMutexDescriptor({CDM::CLibrary, {"mtx_trylock"}, 1},
- {CDM::CLibrary, {"mtx_unlock"}, 1}),
- FirstArgMutexDescriptor({CDM::CLibrary, {"mtx_timedlock"}, 1},
- {CDM::CLibrary, {"mtx_unlock"}, 1}),
- RAIIMutexDescriptor("lock_guard"),
- RAIIMutexDescriptor("unique_lock"),
- RAIIMutexDescriptor("scoped_lock")};
+ {{CDM::CXXMethod, {"std", /*"mutex",*/ "lock"}, 0},
+ {Role::Lock, getCXXThisRegion}},
+ {{CDM::CXXMethod, {"std", /*"mutex",*/ "unlock"}, 0},
+ {Role::Unlock, getCXXThisRegion}},
+ {{CDM::CLibrary, {"pthread_mutex_lock"}, 1}, {Role::Lock}},
+ {{CDM::CLibrary, {"pthread_mutex_unlock"}, 1}, {Role::Unlock}},
+ {{CDM::CLibrary, {"mtx_lock"}, 1}, {Role::Lock}},
+ {{CDM::CLibrary, {"mtx_unlock"}, 1}, {Role::Unlock}},
+ {{CDM::CLibrary, {"pthread_mutex_trylock"}, 1}, {Role::Lock}},
+ {{CDM::CLibrary, {"mtx_trylock"}, 1}, {Role::Lock}},
+ {{CDM::CLibrary, {"mtx_timedlock"}, 1}, {Role::Lock}},
----------------
steakhal wrote:
This is a pre-existing bug: `mtx_timedlock` should have 2 parameters - not 1 as
specified here.
Fix this in a followup PR.
https://github.com/llvm/llvm-project/pull/224230
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits