summaryrefslogtreecommitdiffstats
path: root/clang/tools/c-index-test/core_main.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-04-09 14:12:51 +0000
committerSam McCall <sam.mccall@gmail.com>2018-04-09 14:12:51 +0000
commitcc026ebf32de97bc685ded159dd9a2aa8710eaa3 (patch)
tree6278c508f7360ac56c3f89eb853d9806c9c3a64b /clang/tools/c-index-test/core_main.cpp
parent6400c03e6a7aff8e7c8c41d31c6c1d123d48aa5b (diff)
downloadbcm5719-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/c-index-test/core_main.cpp')
-rw-r--r--clang/tools/c-index-test/core_main.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/tools/c-index-test/core_main.cpp b/clang/tools/c-index-test/core_main.cpp
index c255f54ba68..98658baaa1a 100644
--- a/clang/tools/c-index-test/core_main.cpp
+++ b/clang/tools/c-index-test/core_main.cpp
@@ -88,13 +88,14 @@ public:
bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation> Relations,
- FileID FID, unsigned Offset,
- ASTNodeInfo ASTNode) override {
+ SourceLocation Loc, ASTNodeInfo ASTNode) override {
ASTContext &Ctx = D->getASTContext();
SourceManager &SM = Ctx.getSourceManager();
- unsigned Line = SM.getLineNumber(FID, Offset);
- unsigned Col = SM.getColumnNumber(FID, Offset);
+ Loc = SM.getFileLoc(Loc);
+ FileID FID = SM.getFileID(Loc);
+ unsigned Line = SM.getLineNumber(FID, SM.getFileOffset(Loc));
+ unsigned Col = SM.getColumnNumber(FID, SM.getFileOffset(Loc));
OS << Line << ':' << Col << " | ";
printSymbolInfo(getSymbolInfo(D), OS);
@@ -124,12 +125,14 @@ public:
}
bool handleModuleOccurence(const ImportDecl *ImportD, SymbolRoleSet Roles,
- FileID FID, unsigned Offset) override {
+ SourceLocation Loc) override {
ASTContext &Ctx = ImportD->getASTContext();
SourceManager &SM = Ctx.getSourceManager();
- unsigned Line = SM.getLineNumber(FID, Offset);
- unsigned Col = SM.getColumnNumber(FID, Offset);
+ Loc = SM.getFileLoc(Loc);
+ FileID FID = SM.getFileID(Loc);
+ unsigned Line = SM.getLineNumber(FID, SM.getFileOffset(Loc));
+ unsigned Col = SM.getColumnNumber(FID, SM.getFileOffset(Loc));
OS << Line << ':' << Col << " | ";
printSymbolInfo(getSymbolInfo(ImportD), OS);
OpenPOWER on IntegriCloud