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 | e445c7236e41d854736fec37c77c915661edb8cf (patch) | |
tree | 333455e82d022c9dc0d1934b7a6ce5556667b207 /clang/tools/libclang/Indexing.cpp | |
parent | 130190ffffe5946276db9ee09133b58af1815c8b (diff) | |
download | bcm5719-llvm-e445c7236e41d854736fec37c77c915661edb8cf.tar.gz bcm5719-llvm-e445c7236e41d854736fec37c77c915661edb8cf.zip |
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.
llvm-svn: 165592
Diffstat (limited to 'clang/tools/libclang/Indexing.cpp')
-rw-r--r-- | clang/tools/libclang/Indexing.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp index 6ea87eb95ed..d2b0ab3c8dd 100644 --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/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()); + } } } } |