[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 24 17:12:53 PDT 2025
================
@@ -103,6 +103,23 @@ static StringRef ClassifyDiagnostic(QualType VDT) {
return "mutex";
}
+static unsigned getCapabilityExprFlags(QualType VDT) {
+ unsigned Flags = 0;
+
+ if (const auto *RT = VDT->getAs<RecordType>()) {
+ if (const auto *RD = RT->getDecl())
+ if (RD->hasAttr<ReentrantCapabilityAttr>())
+ Flags |= CapabilityExpr::FlagReentrant;
+ } else if (const auto *TT = VDT->getAs<TypedefType>()) {
+ if (const auto *TD = TT->getDecl())
+ if (TD->hasAttr<ReentrantCapabilityAttr>())
+ Flags |= CapabilityExpr::FlagReentrant;
+ } else if (VDT->isPointerOrReferenceType())
+ return getCapabilityExprFlags(VDT->getPointeeType());
+
+ return Flags;
+}
----------------
aaronpuchert wrote:
I suppose this could be merged with `ClassifyDiagnostic` as we're doing the same cases, but maybe I'm missing something?
https://github.com/llvm/llvm-project/pull/137133
More information about the cfe-commits
mailing list