[cfe-commits] r165732 - in /cfe/trunk: test/Index/index-module.m test/Index/index-pch-with-module.m tools/c-index-test/c-index-test.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Oct 11 12:00:44 PDT 2012


Author: akirtzidis
Date: Thu Oct 11 14:00:44 2012
New Revision: 165732

URL: http://llvm.org/viewvc/llvm-project?rev=165732&view=rev
Log:
[libclang] Add tests for indexing modules and PCHs using modules.

Added:
    cfe/trunk/test/Index/index-module.m
    cfe/trunk/test/Index/index-pch-with-module.m
Modified:
    cfe/trunk/tools/c-index-test/c-index-test.c

Added: cfe/trunk/test/Index/index-module.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=165732&view=auto
==============================================================================
--- cfe/trunk/test/Index/index-module.m (added)
+++ cfe/trunk/test/Index/index-module.m Thu Oct 11 14:00:44 2012
@@ -0,0 +1,52 @@
+
+#include <DependsOnModule/DependsOnModule.h>
+ at __experimental_modules_import DependsOnModule;
+int glob;
+
+// RUN: rm -rf %t.cache
+// RUN: c-index-test -index-file %s -fmodule-cache-path %t.cache -fmodules -F %S/../Modules/Inputs \
+// RUN:      -Xclang -fdisable-module-hash | FileCheck %s
+
+// CHECK-NOT: [indexDeclaration]
+// CHECK: [importedASTFile]: {{.*}}/DependsOnModule.pcm | loc: 2:2 | name: "DependsOnModule" | isImplicit: 1
+// CHECK-NOT: [indexDeclaration]
+// CHECK: [importedASTFile]: {{.*}}/DependsOnModule.pcm | loc: 3:1 | name: "DependsOnModule" | isImplicit: 0
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: glob | {{.*}} | loc: 4:5 
+// CHECK-NOT: [indexDeclaration]
+
+// RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck %s -check-prefix=CHECK-DMOD
+
+// CHECK-DMOD:      [startedTranslationUnit]
+// CHECK-DMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h | {{.*}} | hash loc: <invalid>
+// CHECK-DMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/DependsOnModule.framework/Headers/other.h | {{.*}} | hash loc: <invalid>
+// CHECK-DMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h | {{.*}} | hash loc: <invalid>
+// CHECK-DMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h | name: "SubFramework/Other.h" | hash loc: {{.*}}/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h:1:1 | isImport: 0 | isAngled: 0
+// CHECK-DMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h | {{.*}} | hash loc: <invalid>
+// CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache/Module.pcm | loc: {{.*}}/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h:1:2 | name: "Module" | isImplicit: 1
+// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: depends_on_module_other | {{.*}} | loc: {{.*}}/Modules/Inputs/DependsOnModule.framework/Headers/other.h:1:5
+// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework | {{.*}} | loc: {{.*}}/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h:2:8
+// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework_other | {{.*}} | loc: {{.*}}/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h:1:9
+// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: depends_on_module_private | {{.*}} | loc: {{.*}}/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h:1:5
+// CHECK-DMOD-NOT: [indexDeclaration]
+
+// RUN: c-index-test -index-tu %t.cache/Module.pcm | FileCheck %s -check-prefix=CHECK-TMOD
+
+// CHECK-TMOD:      [startedTranslationUnit]
+// CHECK-TMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h | {{.*}} | hash loc: <invalid>
+// CHECK-TMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/Module.framework/Headers/Sub.h | name: "Module/Sub.h" | hash loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:23:1 | isImport: 0 | isAngled: 1
+// CHECK-TMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/Module.framework/Headers/Sub2.h | name: "Module/Sub2.h" | hash loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Sub.h:1:1 | isImport: 0 | isAngled: 1
+// CHECK-TMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h | name: "Module/Buried/Treasure.h" | hash loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:24:1 | isImport: 0 | isAngled: 1
+// CHECK-TMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h | {{.*}} | hash loc: <invalid>
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: function | name: getModuleVersion | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:9:13
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class | name: Module | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:15:12
+// CHECK-TMOD-NEXT:      <ObjCContainerInfo>: kind: interface
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class-method | name: version | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:16:1
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class-method | name: alloc | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:17:1
+// CHECK-TMOD-NEXT: [importedASTFile]: {{.*}}.cache/Module.pcm | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:23:2 | name: "Module.Sub" | isImplicit: 1
+// CHECK-TMOD-NEXT: [importedASTFile]: {{.*}}.cache/Module.pcm | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Module.h:24:2 | name: "Module.Buried.Treasure" | isImplicit: 1
+// CHECK-TMOD-NEXT: [importedASTFile]: {{.*}}.cache/Module.pcm | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Sub.h:1:2 | name: "Module.Sub2" | isImplicit: 1
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: Module_Sub | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Sub.h:2:6
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: Module_Sub2 | USR: c:@Module_Sub2 | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Sub2.h:1:6
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: Buried_Treasure | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h:1:11
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: module_subframework | {{.*}} | loc: {{.*}}/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h:4:7
+// CHECK-TMOD-NOT: [indexDeclaration]

Added: cfe/trunk/test/Index/index-pch-with-module.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-pch-with-module.m?rev=165732&view=auto
==============================================================================
--- cfe/trunk/test/Index/index-pch-with-module.m (added)
+++ cfe/trunk/test/Index/index-pch-with-module.m Thu Oct 11 14:00:44 2012
@@ -0,0 +1,31 @@
+
+#ifndef PCH_HEADER
+#define PCH_HEADER
+
+#include <DependsOnModule/DependsOnModule.h>
+extern int pch_glob;
+
+#else
+
+int glob;
+
+#endif
+
+// RUN: rm -rf %t.cache
+// RUN: c-index-test -write-pch %t.h.pch %s -fmodule-cache-path %t.cache -fmodules -F %S/../Modules/Inputs -Xclang -fdisable-module-hash
+// RUN: c-index-test -index-file %s -include %t.h -fmodule-cache-path %t.cache -fmodules -F %S/../Modules/Inputs \
+// RUN:      -Xclang -fdisable-module-hash | FileCheck %s
+
+// CHECK-NOT: [indexDeclaration]
+// CHECK:      [importedASTFile]: {{.*}}.h.pch
+// CHECK-NEXT: [enteredMainFile]: {{.*}}/index-pch-with-module.m
+// CHECK-NEXT: [startedTranslationUnit]
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: glob | {{.*}} | loc: 10:5
+// CHECK-NOT: [indexDeclaration]
+
+// RUN: c-index-test -index-tu %t.h.pch | FileCheck %s -check-prefix=CHECK-PCH
+
+// CHECK-PCH: [enteredMainFile]: {{.*}}/index-pch-with-module.m
+// CHECK-PCH: [startedTranslationUnit]
+// CHECK-PCH: [importedASTFile]: {{.*}}.cache/DependsOnModule.pcm | loc: 5:2 | name: "DependsOnModule" | isImplicit: 1
+// CHECK-PCH: [indexDeclaration]: kind: variable | name: pch_glob | {{.*}} | loc: 6:12

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=165732&r1=165731&r2=165732&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Oct 11 14:00:44 2012
@@ -2137,7 +2137,7 @@
   index_data = (IndexData *)client_data;
   clang_indexLoc_getFileLocation(loc, &file, 0, &line, &column, 0);
   if (line == 0) {
-    printf("<null loc>");
+    printf("<invalid>");
     return;
   }
   if (!file) {





More information about the cfe-commits mailing list