[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:56 PDT 2026


================
@@ -108,6 +113,16 @@ static std::string GetEnclosingDeclContextSignature(const Decl *D) {
       // the method.
       DeclName = ND->getQualifiedNameAsString();
       break;
+    case Decl::Field:
+    case Decl::Var:
+    case Decl::ParmVar:
+      if (const DeclContext *DC = D->getDeclContext())
+        return GetEnclosingDeclContextSignature(Decl::castFromDeclContext(DC));
+      break;
+    case Decl::ObjCIvar:
+      if (auto *Interface = cast<ObjCIvarDecl>(ND)->getContainingInterface())
+        return GetEnclosingDeclContextSignature(Interface);
+      break;
----------------
NagyDonat wrote:

Previously this method always returned the _name_ of the thing declared at `D` in its most qualified form (full signature for things that could be overloaded, qualified name otherwise).

Now these new branches act differently: they return the name of the thing that _contains_ the thing declared at `D`.

You should avoid this unnatural generalization of this function, especially since (as far as I see) it is easy to avoid this.

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


More information about the cfe-commits mailing list