Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>, Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>, Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>, 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>
================ @@ -2263,6 +2265,28 @@ static bool neverReturns(const CFGBlock *B) { return false; } +void ThreadSafetyAnalyzer::checkMismatchedFunctionAttrs( + const FunctionDecl *FD) { + FD = FD->getMostRecentDecl(); + + auto collectCapabilities = [&](const FunctionDecl *FD) { + SmallVector<CapabilityExpr> Args; + for (const auto *A : FD->specific_attrs<RequiresCapabilityAttr>()) { + for (const Expr *E : A->args()) + Args.push_back(SxBuilder.translateAttrExpr(E, nullptr)); + } + return Args; + }; + + auto FDArgs = collectCapabilities(FD); + for (const FunctionDecl *D = FD->getPreviousDecl(); D; + D = D->getPreviousDecl()) { + auto DArgs = collectCapabilities(D); + if (DArgs.size() != FDArgs.size()) + Handler.handleAttributeMismatch(FD, D); ---------------- aaronpuchert wrote: In #110523 we had a similar problem and decided to compare the sets one-by-one (search for `zip_longest`). The attributes do not have a meaningful order, but I don't see a benefit in allowing different orders. It's probably better for readability if we enforce consistent ordering. But we can certainly also do a pairwise comparison to compute the difference sets and then emit warnings depending on which set contains `CapabilityExpr`s. 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