[clang] [NFC][analyzer] Replace BlockInCriticalSection MutexDescriptor with C… (PR #224230)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 06:38:10 PDT 2026


================
@@ -380,37 +323,52 @@ void BlockInCriticalSectionChecker::checkPostCall(const CallEvent &Call,
     return;
   }
 
-  if (std::optional<MutexDescriptor> LockDesc =
-          checkDescriptorMatch(Call, C, /*IsLock=*/true)) {
-    if (!std::holds_alternative<RAIIMutexDescriptor>(*LockDesc))
-      handleLock(*LockDesc, Call, C, C.getState());
+  // Constructors are modeled in evalCall, so skip them before the lookup.
+  if (isa<CXXConstructorCall>(Call))
     return;
-  }
-  if (std::optional<MutexDescriptor> UnlockDesc =
-          checkDescriptorMatch(Call, C, /*IsLock=*/false)) {
-    handleUnlock(*UnlockDesc, Call, C);
+
+  const ThreadingCallDescription *Desc = lookupThreadingCall(Call);
+  if (!Desc)
+    return;
+
+  switch (Desc->Role) {
+  case RoleKind::Lock:
+    handleLock(*Desc, Call, C, C.getState());
+    break;
+  case RoleKind::Unlock:
+    handleUnlock(*Desc, Call, C);
+    break;
----------------
steakhal wrote:

```suggestion
    return;
  case RoleKind::Unlock:
    handleUnlock(*Desc, Call, C);
    return;
```

https://github.com/llvm/llvm-project/pull/224230


More information about the cfe-commits mailing list