[clang] Thread Safety Analysis: Support attributes on function pointers (PR #191187)
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 19 15:39:59 PDT 2026
================
@@ -384,9 +412,15 @@ til::SExpr *SExprBuilder::translateDeclRefExpr(const DeclRefExpr *DRE,
const DeclContext *D = PV->getDeclContext();
if (Ctx && Ctx->FunArgs) {
const Decl *Canonical = Ctx->AttrDecl->getCanonicalDecl();
- if (isa<FunctionDecl>(D)
- ? (cast<FunctionDecl>(D)->getCanonicalDecl() == Canonical)
- : (cast<ObjCMethodDecl>(D)->getCanonicalDecl() == Canonical)) {
+ bool Match = false;
+ if (const auto *FD = dyn_cast<FunctionDecl>(D))
+ Match = (FD->getCanonicalDecl() == Canonical);
+ else if (const auto *MD = dyn_cast<ObjCMethodDecl>(D))
+ Match = (MD->getCanonicalDecl() == Canonical);
+ else if (getCanonicalParamDecl(Canonical, I) == PV->getCanonicalDecl())
+ Match = true;
----------------
aaronpuchert wrote:
Can you add `else llvm_unreachable();`?
https://github.com/llvm/llvm-project/pull/191187
More information about the cfe-commits
mailing list