Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>, Timm =?utf-8?q?Bäder?= <tbae...@redhat.com> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/67...@github.com>
================ @@ -5794,6 +5794,30 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl *D, RequiresCapabilityAttr(S.Context, AL, Args.data(), Args.size()); D->addAttr(RCA); + + if (const auto *FD = dyn_cast<FunctionDecl>(D)) { + + auto collectExprs = [](const FunctionDecl *FuncDecl) { + std::set<const ValueDecl*> Args; + for (const auto *A : FuncDecl->specific_attrs<RequiresCapabilityAttr>()) { + for (const Expr *E : A->args()) { + if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) + Args.insert(DRE->getDecl()); ---------------- aaronpuchert wrote: Yes, in fact most expressions won't be `DeclRefExpr`s but `MemberExpr`s. You get a `DeclRefExpr` when you reference a global variable, but most mutexes are going to be class members. When you reference them, you get a `MemberExpr` with an implicit `CXXThisExpr`. The TIL has facilities for semantically comparing expressions. You can use `SExprBuilder::translateAttrExpr` to translate an expression as `CapabilityExpr` and then compare them using `CapabilityExpr::equals`. This will do the right comparison, e.g. in `mu1, mu1` it will consider both expressions equal. https://github.com/llvm/llvm-project/pull/67520 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits