================
@@ -39,20 +40,24 @@ Hints declHints(const Decl *D) {
 }
 
 std::vector<Hinted<SymbolLocation>> locateDecl(const Decl &D) {
-  std::vector<Hinted<SymbolLocation>> Result;
-  // FIXME: Should we also provide physical locations?
-  if (auto SS = tooling::stdlib::Recognizer()(&D)) {
-    Result.push_back({*SS, Hints::CompleteSymbol});
-    if (!D.hasBody())
-      return Result;
-  }
+  SourceManager &SM = D.getASTContext().getSourceManager();
+  bool HasBodyInMainFile = llvm::any_of(D.redecls(), [&](Decl *Redecl) {
+    return Redecl->hasBody() && SM.isInMainFile(Redecl->getLocation());
+  });
+  // if decl has body and in main file, we don't need to do further search.
+  if (!HasBodyInMainFile)
----------------
HerrCai0907 wrote:

Agree. This patch is a temporary fix to avoid breaking it for a long time. I 
think avoiding to include decl which already in the same file is always fine.

And I agree we need to  consider more about how to handle this case elegantly 
because std library use more and more short name function which make it harder 
to avoid to use the same name.

I think more about this issue today. In my opinion, the basic requirements 
should be:
1. If any decl (with or without body) is defined in user written header, we 
should use user written header
2. If any decl is match stdlib, we should use stdlib
3. the other we just use what we can find.

So the priority should be: decl in user written file > stdlib recognition > 
other found.

WDYT?

https://github.com/llvm/llvm-project/pull/95797
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to