diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-04-09 14:12:51 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-04-09 14:12:51 +0000 |
commit | cc026ebf32de97bc685ded159dd9a2aa8710eaa3 (patch) | |
tree | 6278c508f7360ac56c3f89eb853d9806c9c3a64b /clang/tools/libclang/CXIndexDataConsumer.cpp | |
parent | 6400c03e6a7aff8e7c8c41d31c6c1d123d48aa5b (diff) | |
download | bcm5719-llvm-cc026ebf32de97bc685ded159dd9a2aa8710eaa3.tar.gz bcm5719-llvm-cc026ebf32de97bc685ded159dd9a2aa8710eaa3.zip |
[Index] Return SourceLocation to consumers, not FileID/Offset pair.
Summary:
The FileID/Offset conversion is lossy. The code takes the fileLoc, which loses
e.g. the spelling location in some macro cases.
Instead, pass the original SourceLocation which preserves all information, and
update consumers to match current behavior.
This allows us to fix two bugs in clangd that need the spelling location.
Reviewers: akyrtzi, arphaman
Subscribers: ilya-biryukov, ioeric, cfe-commits
Differential Revision: https://reviews.llvm.org/D45014
llvm-svn: 329570
Diffstat (limited to 'clang/tools/libclang/CXIndexDataConsumer.cpp')
-rw-r--r-- | clang/tools/libclang/CXIndexDataConsumer.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/clang/tools/libclang/CXIndexDataConsumer.cpp b/clang/tools/libclang/CXIndexDataConsumer.cpp index ba1e92f5457..616a0797f52 100644 --- a/clang/tools/libclang/CXIndexDataConsumer.cpp +++ b/clang/tools/libclang/CXIndexDataConsumer.cpp @@ -155,13 +155,10 @@ CXSymbolRole getSymbolRole(SymbolRoleSet Role) { } } -bool CXIndexDataConsumer::handleDeclOccurence(const Decl *D, - SymbolRoleSet Roles, - ArrayRef<SymbolRelation> Relations, - FileID FID, unsigned Offset, - ASTNodeInfo ASTNode) { - SourceLocation Loc = getASTContext().getSourceManager() - .getLocForStartOfFile(FID).getLocWithOffset(Offset); +bool CXIndexDataConsumer::handleDeclOccurence( + const Decl *D, SymbolRoleSet Roles, ArrayRef<SymbolRelation> Relations, + SourceLocation Loc, ASTNodeInfo ASTNode) { + Loc = getASTContext().getSourceManager().getFileLoc(Loc); if (Roles & (unsigned)SymbolRole::Reference) { const NamedDecl *ND = dyn_cast<NamedDecl>(D); @@ -226,8 +223,7 @@ bool CXIndexDataConsumer::handleDeclOccurence(const Decl *D, bool CXIndexDataConsumer::handleModuleOccurence(const ImportDecl *ImportD, SymbolRoleSet Roles, - FileID FID, - unsigned Offset) { + SourceLocation Loc) { IndexingDeclVisitor(*this, SourceLocation(), nullptr).Visit(ImportD); return !shouldAbort(); } |