diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-10 02:12:47 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-10 02:12:47 +0000 |
commit | 62288edde26ff4af9fc079c979a0e1bdc577ce9d (patch) | |
tree | 29130aae0c9d9738d9a35b4b883d222cf6ef7353 /tools/libclang/Indexing.cpp | |
parent | 2a857180050fb78b356c17931e311eef7f2daf3e (diff) |
When indexing a module file, for the ppIncludedFile callback give
an invalid location if the location points to the synthetic buffer
for the module input.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165592 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/Indexing.cpp')
-rw-r--r-- | tools/libclang/Indexing.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 6ea87eb95e..d2b0ab3c8d 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -450,14 +450,21 @@ static void indexPreprocessingRecord(ASTUnit &Unit, IndexingContext &IdxCtx) { PreprocessingRecord::iterator I, E; llvm::tie(I, E) = Unit.getLocalPreprocessingEntities(); + bool isModuleFile = Unit.isModuleFile(); for (; I != E; ++I) { PreprocessedEntity *PPE = *I; if (InclusionDirective *ID = dyn_cast<InclusionDirective>(PPE)) { - if (!ID->importedModule()) - IdxCtx.ppIncludedFile(ID->getSourceRange().getBegin(),ID->getFileName(), + if (!ID->importedModule()) { + SourceLocation Loc = ID->getSourceRange().getBegin(); + // Modules have synthetic main files as input, give an invalid location + // if the location points to such a file. + if (isModuleFile && Unit.isInMainFileID(Loc)) + Loc = SourceLocation(); + IdxCtx.ppIncludedFile(Loc, ID->getFileName(), ID->getFile(), ID->getKind() == InclusionDirective::Import, !ID->wasInQuotes()); + } } } } |