diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 3 | ||||
-rw-r--r-- | tools/libclang/Indexing.cpp | 27 | ||||
-rw-r--r-- | tools/libclang/IndexingContext.cpp | 5 | ||||
-rw-r--r-- | tools/libclang/IndexingContext.h | 2 |
4 files changed, 17 insertions, 20 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index c46ba74ce4..eda82d1872 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -2363,7 +2363,8 @@ static CXIdxClientFile index_ppIncludedFile(CXClientData client_data, printf(" | name: \"%s\"", info->filename); printf(" | hash loc: "); printCXIndexLoc(info->hashLoc, client_data); - printf(" | isImport: %d | isAngled: %d\n", info->isImport, info->isAngled); + printf(" | isImport: %d | isAngled: %d | isModule: %d\n", + info->isImport, info->isAngled, info->isModuleImport); return (CXIdxClientFile)info->file; } diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 887b5fc1ee..36442fa232 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -73,14 +73,10 @@ public: StringRef SearchPath, StringRef RelativePath, const Module *Imported) { - if (Imported) { - // We handle implicit imports via ImportDecls. - return; - } - bool isImport = (IncludeTok.is(tok::identifier) && IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import); - IndexCtx.ppIncludedFile(HashLoc, FileName, File, isImport, IsAngled); + IndexCtx.ppIncludedFile(HashLoc, FileName, File, isImport, IsAngled, + Imported); } /// MacroDefined - This hook is called whenever a macro definition is seen. @@ -458,16 +454,15 @@ static void indexPreprocessingRecord(ASTUnit &Unit, IndexingContext &IdxCtx) { PreprocessedEntity *PPE = *I; if (InclusionDirective *ID = dyn_cast<InclusionDirective>(PPE)) { - 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()); - } + 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(), ID->importedModule()); } } } diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index 74b3cf362b..09efebb62f 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -240,7 +240,8 @@ void IndexingContext::enteredMainFile(const FileEntry *File) { void IndexingContext::ppIncludedFile(SourceLocation hashLoc, StringRef filename, const FileEntry *File, - bool isImport, bool isAngled) { + bool isImport, bool isAngled, + bool isModuleImport) { if (!CB.ppIncludedFile) return; @@ -248,7 +249,7 @@ void IndexingContext::ppIncludedFile(SourceLocation hashLoc, CXIdxIncludedFileInfo Info = { getIndexLoc(hashLoc), SA.toCStr(filename), (CXFile)File, - isImport, isAngled }; + isImport, isAngled, isModuleImport }; CXIdxClientFile idxFile = CB.ppIncludedFile(ClientData, &Info); FileMap[File] = idxFile; } diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h index 7671e6c2f1..78a8abc270 100644 --- a/tools/libclang/IndexingContext.h +++ b/tools/libclang/IndexingContext.h @@ -369,7 +369,7 @@ public: void ppIncludedFile(SourceLocation hashLoc, StringRef filename, const FileEntry *File, - bool isImport, bool isAngled); + bool isImport, bool isAngled, bool isModuleImport); void importedModule(const ImportDecl *ImportD); void importedPCH(const FileEntry *File); |