[cfe-commits] r166161 - in /cfe/trunk: include/clang-c/Index.h test/Index/index-module.m tools/c-index-test/c-index-test.c tools/libclang/Indexing.cpp tools/libclang/IndexingContext.cpp tools/libclang/IndexingContext.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Oct 17 17:17:05 PDT 2012
Author: akirtzidis
Date: Wed Oct 17 19:17:05 2012
New Revision: 166161
URL: http://llvm.org/viewvc/llvm-project?rev=166161&view=rev
Log:
[libclang] Invoke a ppIncludedFile callback when indexing implicit module imports.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/index-module.m
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/tools/libclang/IndexingContext.cpp
cfe/trunk/tools/libclang/IndexingContext.h
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=166161&r1=166160&r2=166161&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Oct 17 19:17:05 2012
@@ -4985,6 +4985,11 @@
CXFile file;
int isImport;
int isAngled;
+ /**
+ * \brief Non-zero if the directive was automatically turned into a module
+ * import.
+ */
+ int isModuleImport;
} CXIdxIncludedFileInfo;
/**
Modified: cfe/trunk/test/Index/index-module.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=166161&r1=166160&r2=166161&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-module.m (original)
+++ cfe/trunk/test/Index/index-module.m Wed Oct 17 19:17:05 2012
@@ -9,6 +9,7 @@
// CHECK-NOT: [indexDeclaration]
// CHECK: [importedASTFile]: [[PCM:.*[/\\]DependsOnModule\.pcm]] | loc: 2:2 | name: "DependsOnModule" | isImplicit: 1
+// CHECK-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/DependsOnModule.framework{{[/\\]}}Headers{{[/\\]}}DependsOnModule.h | name: "DependsOnModule/DependsOnModule.h" | hash loc: 2:1 | isImport: 0 | isAngled: 1 | isModule: 1
// CHECK-NOT: [indexDeclaration]
// CHECK: [importedASTFile]: [[PCM]] | loc: 3:1 | name: "DependsOnModule" | isImplicit: 0
// CHECK-NEXT: [indexDeclaration]: kind: variable | name: glob | {{.*}} | loc: 4:5
@@ -18,6 +19,7 @@
// CHECK-DMOD: [startedTranslationUnit]
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]] | {{.*}} | hash loc: <invalid>
+// CHECK-DMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/Module.framework{{[/\\]}}Headers{{[/\\]}}Module.h | name: "Module/Module.h" | hash loc: {{.*}}/Modules/Inputs/DependsOnModule.framework{{[/\\]}}Headers{{[/\\]}}DependsOnModule.h:1:1 | isImport: 0 | isAngled: 1 | isModule: 1
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_OTHER_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]other\.h]] | {{.*}} | hash loc: <invalid>
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]] | {{.*}} | hash loc: <invalid>
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]] | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | isAngled: 0
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=166161&r1=166160&r2=166161&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Oct 17 19:17:05 2012
@@ -2363,7 +2363,8 @@
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;
}
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=166161&r1=166160&r2=166161&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Wed Oct 17 19:17:05 2012
@@ -73,14 +73,10 @@
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 @@
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());
}
}
}
Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=166161&r1=166160&r2=166161&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Wed Oct 17 19:17:05 2012
@@ -240,7 +240,8 @@
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 @@
CXIdxIncludedFileInfo Info = { getIndexLoc(hashLoc),
SA.toCStr(filename),
(CXFile)File,
- isImport, isAngled };
+ isImport, isAngled, isModuleImport };
CXIdxClientFile idxFile = CB.ppIncludedFile(ClientData, &Info);
FileMap[File] = idxFile;
}
Modified: cfe/trunk/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.h?rev=166161&r1=166160&r2=166161&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.h (original)
+++ cfe/trunk/tools/libclang/IndexingContext.h Wed Oct 17 19:17:05 2012
@@ -369,7 +369,7 @@
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);
More information about the cfe-commits
mailing list