[clang] [clang][StaticAnalyzer] Add support for variables and fields in GetEnclosingDeclContextSignature (PR #214102)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 4 20:02:55 PDT 2026


================
@@ -299,6 +299,7 @@ class RawPtrRefMemberChecker
                                  BR->getSourceManager());
     auto Report = std::make_unique<BasicBugReport>(Bug, Os.str(), BSLoc);
     Report->addRange(Member->getSourceRange());
+    Report->setDeclWithIssue(Member);
----------------
NagyDonat wrote:

If I understand it correctly this new call is the reason why you extended `GetEnclosingDeclContextSignature` with cases for `Field`, `Var`, `ParamVar` and `ObjCIvar` declarations (that recursively call `GetEnclosingDeclContextSignature`).

You should remove those recursive branches and change this line to `Report->setDeclWithIssue(getDeclarationContaining(Member))` where you use a new helper method `getDeclarationContaining` which converts the `Field`/`Var`/`ParamVar`/`ObjCIvar` to the enclosing declaration context or interface the same way as you do now to prepare for the recursive calls of `GetEnclosingDeclContextSignature`. (If `Member` can be anything else, you should still convert it to the enclosing declaration context for the sake of consistency.)



https://github.com/llvm/llvm-project/pull/214102


More information about the cfe-commits mailing list