================
@@ -53,7 +56,23 @@ class ContributorFinder : public DynamicRecursiveASTVisitor {
DeclContext *DC = D->getDeclContext();
// Collects Decl for global variables or static data members:
- if (DC->isFileContext() || D->isStaticDataMember())
+ if (DC->isFileContext() || D->isStaticDataMember()) {
+ Contributors.insert(D);
+ return true;
+ }
+
+ // Optionally include block-scope (function-local) variables. Parameters
+ // are intentionally skipped: they are exposed via their parent function's
+ // USR + a parameter-index suffix in getEntityName, so registering them as
+ // independent contributors would be redundant.
+ //
+ // FIXME: clang::index::generateUSRForDecl can produce non-unique or empty
+ // USRs for some local declaration shapes (e.g., locals of certain template
+ // instantiations). The current addEntity path returns std::nullopt when
+ // that happens and downstream extractors skip gracefully, so this is
+ // tolerated for now.
+ if (Opts.IncludeLocalEntities && !D->isImplicit() && !isa<ParmVarDecl>(D)
&&
+ DC->isFunctionOrMethod())
----------------
ziqingluo-90 wrote:
If a local entity is a function/method, it should be a contributor.
I think lambdas and class methods defined in a function have been covered
already. I wonder what else was missing and will be covered by this change.
https://github.com/llvm/llvm-project/pull/205351
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits