| 1 |
// Note: the run lines follow their respective tests, since line/column |
| 2 |
// matter in this test. |
| 3 |
|
| 4 |
// pcherror-error-re@* {{module file '{{.*}}use_error_a.pcm' contains compiler errors}} |
| 5 |
@import use_error_a; // notallowerror-error {{could not build module 'use_error_a'}} |
| 6 |
@import use_error_b; |
| 7 |
// expected-no-diagnostics |
| 8 |
|
| 9 |
void test(Error *x) { |
| 10 |
funca(x); |
| 11 |
funcb(x); |
| 12 |
[x method]; |
| 13 |
} |
| 14 |
|
| 15 |
// RUN: rm -rf %t |
| 16 |
// RUN: mkdir %t |
| 17 |
// RUN: mkdir %t/prebuilt |
| 18 |
|
| 19 |
// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ |
| 20 |
// RUN: -fmodule-name=error -o %t/prebuilt/error.pcm \ |
| 21 |
// RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap |
| 22 |
// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ |
| 23 |
// RUN: -fmodule-file=error=%t/prebuilt/error.pcm \ |
| 24 |
// RUN: -fmodule-name=use_error_a -o %t/prebuilt/use_error_a.pcm \ |
| 25 |
// RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap |
| 26 |
// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ |
| 27 |
// RUN: -fmodule-file=error=%t/prebuilt/error.pcm \ |
| 28 |
// RUN: -fmodule-name=use_error_b -o %t/prebuilt/use_error_b.pcm \ |
| 29 |
// RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap |
| 30 |
|
| 31 |
// Prebuilt modules |
| 32 |
// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ |
| 33 |
// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ |
| 34 |
// RUN: -ast-print %s | FileCheck %s |
| 35 |
// RUN: %clang_cc1 -fsyntax-only -fmodules \ |
| 36 |
// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ |
| 37 |
// RUN: -verify=pcherror %s |
| 38 |
|
| 39 |
// Explicit prebuilt modules (loaded when needed) |
| 40 |
// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ |
| 41 |
// RUN: -fmodule-file=error=%t/prebuilt/error.pcm \ |
| 42 |
// RUN: -fmodule-file=use_error_a=%t/prebuilt/use_error_a.pcm \ |
| 43 |
// RUN: -fmodule-file=use_error_b=%t/prebuilt/use_error_b.pcm \ |
| 44 |
// RUN: -fmodules-cache-path=%t -ast-print %s | FileCheck %s |
| 45 |
// RUN: %clang_cc1 -fsyntax-only -fmodules \ |
| 46 |
// RUN: -fmodule-file=error=%t/prebuilt/error.pcm \ |
| 47 |
// RUN: -fmodule-file=use_error_a=%t/prebuilt/use_error_a.pcm \ |
| 48 |
// RUN: -fmodule-file=use_error_b=%t/prebuilt/use_error_b.pcm \ |
| 49 |
// RUN: -fmodules-cache-path=%t -verify=pcherror %s |
| 50 |
|
| 51 |
// Explicit prebuilt modules without name (always loaded) |
| 52 |
// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ |
| 53 |
// RUN: -fmodule-file=%t/prebuilt/error.pcm \ |
| 54 |
// RUN: -fmodule-file=%t/prebuilt/use_error_a.pcm \ |
| 55 |
// RUN: -fmodule-file=%t/prebuilt/use_error_b.pcm \ |
| 56 |
// RUN: -fmodules-cache-path=%t -ast-print %s | FileCheck %s |
| 57 |
// As the modules are always loaded, compiling will fail before even parsing |
| 58 |
// this file - this means that -verify can't be used, so do a grep instead. |
| 59 |
// RUN: not %clang_cc1 -fsyntax-only -fmodules \ |
| 60 |
// RUN: -fmodule-file=%t/prebuilt/error.pcm \ |
| 61 |
// RUN: -fmodule-file=%t/prebuilt/use_error_a.pcm \ |
| 62 |
// RUN: -fmodule-file=%t/prebuilt/use_error_b.pcm \ |
| 63 |
// RUN: -fmodules-cache-path=%t 2>&1 | \ |
| 64 |
// RUN: grep "module file .* contains compiler errors" |
| 65 |
|
| 66 |
// Shouldn't build the cached modules (that have errors) when not allowing |
| 67 |
// errors |
| 68 |
// RUN: not %clang_cc1 -fsyntax-only -fmodules \ |
| 69 |
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ |
| 70 |
// RUN: -x objective-c %s |
| 71 |
// RUN: find %t -name "error-*.pcm" | not grep error |
| 72 |
|
| 73 |
// Should build the cached modules when allowing errors |
| 74 |
// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ |
| 75 |
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ |
| 76 |
// RUN: -x objective-c -verify %s |
| 77 |
// RUN: find %t -name "error-*.pcm" | grep error |
| 78 |
// RUN: find %t -name "use_error_a-*.pcm" | grep use_error_a |
| 79 |
// RUN: find %t -name "use_error_b-*.pcm" | grep use_error_b |
| 80 |
|
| 81 |
// Check build when the modules are already cached |
| 82 |
// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ |
| 83 |
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ |
| 84 |
// RUN: -x objective-c -verify %s |
| 85 |
|
| 86 |
// Should rebuild the cached module if it had an error (if it wasn't rebuilt |
| 87 |
// the verify would fail as it would be the PCH error instead) |
| 88 |
// RUN: %clang_cc1 -fsyntax-only -fmodules \ |
| 89 |
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ |
| 90 |
// RUN: -x objective-c %s -verify=notallowerror |
| 91 |
|
| 92 |
// allow-pcm-with-compiler-errors should also allow errors in PCH |
| 93 |
// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x objective-c \ |
| 94 |
// RUN: -o %t/check.pch -emit-pch %S/Inputs/error/error.h |
| 95 |
|
| 96 |
// CHECK: @interface Error |
| 97 |
// CHECK-NEXT: - (int)method; |
| 98 |
// CHECK-NEXT: - (id)method2; |
| 99 |
// CHECK-NEXT: @end |
| 100 |
// CHECK: void test(Error *x) |
| 101 |
|
| 102 |
// RUN: c-index-test -code-completion-at=%s:12:6 %s -fmodules -fmodules-cache-path=%t \ |
| 103 |
// RUN: -Xclang -fallow-pcm-with-compiler-errors -I %S/Inputs/error | FileCheck -check-prefix=COMPLETE %s |
| 104 |
// COMPLETE: ObjCInstanceMethodDecl:{ResultType int}{TypedText method} |
| 105 |
// COMPLETE: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2} |
| 106 |
|
| 107 |
// RUN: c-index-test -test-load-source local %s -fmodules -fmodules-cache-path=%t \ |
| 108 |
// RUN: -Xclang -fallow-pcm-with-compiler-errors -I %S/Inputs/error | FileCheck -check-prefix=SOURCE %s |
| 109 |
// SOURCE: load-module-with-errors.m:9:6: FunctionDecl=test:9:6 (Definition) Extent=[9:1 - 13:2] |
| 110 |
// SOURCE: load-module-with-errors.m:9:18: ParmDecl=x:9:18 (Definition) Extent=[9:11 - 9:19] |
| 111 |
// SOURCE: load-module-with-errors.m:9:11: ObjCClassRef=Error:5:12 Extent=[9:11 - 9:16] |
| 112 |
// SOURCE: load-module-with-errors.m:9:21: CompoundStmt= Extent=[9:21 - 13:2] |
| 113 |
// SOURCE: load-module-with-errors.m:10:3: CallExpr=funca:3:6 Extent=[10:3 - 10:11] |
| 114 |
// SOURCE: load-module-with-errors.m:11:3: CallExpr=funcb:3:6 Extent=[11:3 - 11:11] |
| 115 |
// SOURCE: load-module-with-errors.m:12:3: ObjCMessageExpr=method:6:8 Extent=[12:3 - 12:13] |