summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/index/SymbolCollector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/index/SymbolCollector.cpp')
-rw-r--r--clang-tools-extra/clangd/index/SymbolCollector.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 93bd3f75a9c..e237e136d25 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "SymbolCollector.h"
+#include "../AST.h"
#include "../CodeCompletionStrings.h"
#include "../Logger.h"
#include "../URI.h"
@@ -184,30 +185,16 @@ getIncludeHeader(llvm::StringRef QName, const SourceManager &SM,
llvm::Optional<SymbolLocation> getSymbolLocation(
const NamedDecl &D, SourceManager &SM, const SymbolCollector::Options &Opts,
const clang::LangOptions &LangOpts, std::string &FileURIStorage) {
- SourceLocation SpellingLoc = SM.getSpellingLoc(D.getLocation());
- if (D.getLocation().isMacroID()) {
- std::string PrintLoc = SpellingLoc.printToString(SM);
- if (llvm::StringRef(PrintLoc).startswith("<scratch") ||
- llvm::StringRef(PrintLoc).startswith("<command line>")) {
- // We use the expansion location for the following symbols, as spelling
- // locations of these symbols are not interesting to us:
- // * symbols formed via macro concatenation, the spelling location will
- // be "<scratch space>"
- // * symbols controlled and defined by a compile command-line option
- // `-DName=foo`, the spelling location will be "<command line>".
- SpellingLoc = SM.getExpansionRange(D.getLocation()).first;
- }
- }
-
- auto U = toURI(SM, SM.getFilename(SpellingLoc), Opts);
+ SourceLocation NameLoc = findNameLoc(&D);
+ auto U = toURI(SM, SM.getFilename(NameLoc), Opts);
if (!U)
return llvm::None;
FileURIStorage = std::move(*U);
SymbolLocation Result;
Result.FileURI = FileURIStorage;
- Result.StartOffset = SM.getFileOffset(SpellingLoc);
+ Result.StartOffset = SM.getFileOffset(NameLoc);
Result.EndOffset = Result.StartOffset + clang::Lexer::MeasureTokenLength(
- SpellingLoc, SM, LangOpts);
+ NameLoc, SM, LangOpts);
return std::move(Result);
}
OpenPOWER on IntegriCloud