================
@@ -115,7 +115,25 @@ class RAIIMutexDescriptor {
return false;
const IdentifierInfo *II =
cast<CXXRecordDecl>(C->getDecl()->getParent())->getIdentifier();
- return II == Guard;
+ if (II != Guard)
+ return false;
+
+ // For unique_lock, check if it's constructed with a ctor that takes the
tag
+ // type defer_lock_t. In this case, the lock is not acquired.
+ if constexpr (std::is_same_v<T, CXXConstructorCall>) {
+ if (GuardName == "unique_lock" && C->getNumArgs() >= 2) {
+ const Expr *SecondArg = C->getArgExpr(1);
+ QualType ArgType = SecondArg->getType().getNonReferenceType();
+ QualType UnqualifiedType = ArgType.getUnqualifiedType();
+ if (const auto *RD = UnqualifiedType->getAsRecordDecl();
+ RD && RD->getName() == "defer_lock_t" &&
+ RD->getDeclContext()->isStdNamespace()) {
----------------
NagyDonat wrote:
```suggestion
RD->isInStdNamespace()) {
```
Slightly shorter and may be slightly more accurate in some crazy corner case.
https://github.com/llvm/llvm-project/pull/168338
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits