================
@@ -27,27 +27,47 @@ static bool isLockGuardDecl(const NamedDecl *Decl) {
Decl->getName() == "lock_guard" && Decl->isInStdNamespace();
}
-static bool isLockGuard(const QualType &Type) {
+static bool isScopedLockDecl(const NamedDecl *Decl) {
+ return Decl->getDeclName().isIdentifier() &&
+ Decl->getName() == "scoped_lock" && Decl->isInStdNamespace();
+}
+
+static const NamedDecl *getLockClassDecl(const QualType &Type) {
if (const auto *Record = Type->getAsCanonical<RecordType>())
- if (const RecordDecl *Decl = Record->getDecl())
- return isLockGuardDecl(Decl);
+ return Record->getDecl();
if (const auto *TemplateSpecType = Type->getAs<TemplateSpecializationType>())
- if (const TemplateDecl *Decl =
- TemplateSpecType->getTemplateName().getAsTemplateDecl())
- return isLockGuardDecl(Decl);
+ return TemplateSpecType->getTemplateName().getAsTemplateDecl();
+ return nullptr;
+}
+
+static bool isLockGuard(const QualType &Type) {
+ if (const NamedDecl *LockDecl = getLockClassDecl(Type))
+ return isLockGuardDecl(LockDecl);
return false;
}
+static bool isScopedLock(const QualType &Type) {
+ if (const NamedDecl *LockDecl = getLockClassDecl(Type))
+ return isScopedLockDecl(LockDecl);
+ return false;
+}
+
+static StringRef getLockClassName(const QualType &Type) {
+ if (const NamedDecl *LockDecl = getLockClassDecl(Type))
+ return LockDecl->getName();
+ return "";
----------------
zwuis wrote:
This branch is unused currently. Use `assert` to check if `LockDecl` is null?
https://github.com/llvm/llvm-project/pull/209272
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits