SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, FE);
+ std::vector<Location> Result;
+ // Handle goto definition for #include.
+ for (auto &IncludeLoc : AST.getInclusionLocations()) {
+ Range R = IncludeLoc.first;
+ Position Pos = sourceLocToPosition(SourceMgr, SourceLocationBeg);
+
+ if (R.contains(Pos))
+ Result.push_back(Location{URIForFile{IncludeLoc.second}, {}});
+ }
+ if (!Result.empty())
+ return Result;
+
auto DeclMacrosFinder = std::make_shared<DeclarationAndMacrosFinder>(
llvm::errs(), SourceLocationBeg, AST.getASTContext(),
AST.getPreprocessor());
std::vector<const Decl *> Decls = DeclMacrosFinder->takeDecls();
std::vector<MacroDecl> MacroInfos = DeclMacrosFinder->takeMacroInfos();
- std::vector<Location> Result;
for (auto Item : Decls) {
auto L = getDeclarationLocation(AST, Item->getSourceRange());
Result.push_back(*L);
}
- /// Process targets for paths inside #include directive.
- for (auto &IncludeLoc : AST.getInclusionLocations()) {
- Range R = IncludeLoc.first;
- Position Pos = sourceLocToPosition(SourceMgr, SourceLocationBeg);
-
- if (R.contains(Pos))
- Result.push_back(Location{URIForFile{IncludeLoc.second}, {}});
- }
-
return Result;
}