[PATCH] D44251: [clangd] Early return for #include goto definition.
Haojian Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 8 08:30:55 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327023: [clangd] Early return for #include goto definition. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D44251
Files:
clang-tools-extra/trunk/clangd/XRefs.cpp
Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -174,6 +174,18 @@
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());
@@ -187,7 +199,6 @@
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());
@@ -203,15 +214,6 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44251.137580.patch
Type: text/x-patch
Size: 1564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180308/f5a31ad0/attachment.bin>
More information about the llvm-commits
mailing list