================
@@ -235,6 +236,54 @@ std::optional<Location> makeLocation(const ASTContext 
&AST, SourceLocation Loc,
   return L;
 }
 
+std::optional<LocatedSymbol>
+locateModuleReferent(const syntax::Token &TouchedIdentifier, ParsedAST &AST,
+                     llvm::StringRef MainFilePath) {
+  const SourceManager &SM = AST.getSourceManager();
+  const ASTContext &Context = AST.getASTContext();
+
+  const Module *ResultModule = nullptr;
+
+  for (const ImportDecl *Import : Context.local_imports()) {
----------------
ArcsinX wrote:

It looks like `local_imports()` is sorted.
I don't think there is a reason for binary search (as far as number of imports 
is typically quite low), but maybe we can add an early return login when we 
found that token's location is before the current import's identifier range 
(i.e. no reason to check imports after current import if the token is already 
passed)

https://github.com/llvm/llvm-project/pull/219839
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to