================
@@ -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:

> telling apart a "physical" stdlib header (e.g. <__utility/pair.h>) from a 
> user header (e.g. <my_stdlib/pair.h>) isn't possible. hence when something 
> goes wrong, we'll always "insert" the wrong header (implementation detail, 
> rather than public header for a stdlib symbol).

I aggree it is not possible to identifier the user-defined stdlib with stdlib. 
But it is possible to identifier user-defined function with stdlib function 
which may have totally difference meanings. e.g. `log` to print something and 
`log` in `<cmath>` 

We may distinguish them by quota include or angle brackets? Since normally c++ 
developer will only use `#include <>` for system header file but `include ""` 
for the other file.


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