Skip to content

Commit 19ec3d8

Browse files
author
git apple-llvm automerger
committed
Merge commit 'f5626d5491c8' from apple/stable/20210107 into swift/main
2 parents 5fbf4ff + f5626d5 commit 19ec3d8

File tree

6 files changed

+71
-22
lines changed

6 files changed

+71
-22
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,9 +2744,10 @@ ASTReader::ReadControlBlock(ModuleFile &F,
27442744

27452745
bool hasErrors = Record[6];
27462746
if (hasErrors && !DisableValidation) {
2747-
// If requested by the caller, mark modules on error as out-of-date.
2748-
if (F.Kind == MK_ImplicitModule &&
2749-
(ClientLoadCapabilities & ARR_TreatModuleWithErrorsAsOutOfDate))
2747+
// If requested by the caller and the module hasn't already been read
2748+
// or compiled, mark modules on error as out-of-date.
2749+
if ((ClientLoadCapabilities & ARR_TreatModuleWithErrorsAsOutOfDate) &&
2750+
!ModuleMgr.getModuleCache().isPCMFinal(F.FileName))
27502751
return OutOfDate;
27512752

27522753
if (!AllowASTWithCompilerErrors) {

clang/test/Modules/Inputs/error/error.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#pragma mark mark
2+
13
@import undefined;
24

35
@interface Error
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
module error {
22
header "error.h"
33
}
4+
5+
module use_error_a {
6+
header "use_error_a.h"
7+
export error
8+
}
9+
10+
module use_error_b {
11+
header "use_error_b.h"
12+
export error
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import error;
2+
3+
void funca(Error *a);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import error;
2+
3+
void funcb(Error *b);

clang/test/Modules/load-module-with-errors.m

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
// matter in this test.
33

44
// pcherror-error@* {{PCH file contains compiler errors}}
5-
@import error; // notallowerror-error {{could not build module 'error'}}
5+
@import use_error_a; // notallowerror-error {{could not build module 'use_error_a'}}
6+
@import use_error_b;
67
// expected-no-diagnostics
78

89
void test(Error *x) {
10+
funca(x);
11+
funcb(x);
912
[x method];
1013
}
1114

@@ -16,41 +19,66 @@ void test(Error *x) {
1619
// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \
1720
// RUN: -fmodule-name=error -o %t/prebuilt/error.pcm \
1821
// 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
1930

31+
// Prebuilt modules
2032
// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \
2133
// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \
2234
// RUN: -ast-print %s | FileCheck %s
2335
// RUN: %clang_cc1 -fsyntax-only -fmodules \
2436
// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \
2537
// RUN: -verify=pcherror %s
2638

39+
// Explicit prebuilt modules (loaded when needed)
2740
// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \
28-
// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \
29-
// RUN: -ast-print %s | FileCheck %s
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
3045
// RUN: %clang_cc1 -fsyntax-only -fmodules \
31-
// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \
32-
// RUN: -verify=pcherror %s
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
3350

51+
// Explicit prebuilt modules without name (always loaded)
3452
// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \
35-
// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \
36-
// RUN: -ast-print %s | FileCheck %s
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.
3759
// RUN: not %clang_cc1 -fsyntax-only -fmodules \
38-
// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \
39-
// RUN: -verify=pcherror %s
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 "PCH file contains compiler errors"
4065

41-
// Shouldn't build the cached module (that has errors) when not allowing errors
66+
// Shouldn't build the cached modules (that have errors) when not allowing
67+
// errors
4268
// RUN: not %clang_cc1 -fsyntax-only -fmodules \
4369
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \
4470
// RUN: -x objective-c %s
4571
// RUN: find %t -name "error-*.pcm" | not grep error
4672

47-
// Should build the cached module when allowing errors
73+
// Should build the cached modules when allowing errors
4874
// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \
4975
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \
5076
// RUN: -x objective-c -verify %s
5177
// 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
5280

53-
// Make sure there is still an error after the module is already in the cache
81+
// Check build when the modules are already cached
5482
// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \
5583
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \
5684
// RUN: -x objective-c -verify %s
@@ -59,7 +87,7 @@ void test(Error *x) {
5987
// the verify would fail as it would be the PCH error instead)
6088
// RUN: %clang_cc1 -fsyntax-only -fmodules \
6189
// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \
62-
// RUN: -x objective-c -verify=notallowerror %s
90+
// RUN: -x objective-c %s -verify=notallowerror
6391

6492
// allow-pcm-with-compiler-errors should also allow errors in PCH
6593
// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x objective-c \
@@ -71,15 +99,17 @@ void test(Error *x) {
7199
// CHECK-NEXT: @end
72100
// CHECK: void test(Error *x)
73101

74-
// RUN: c-index-test -code-completion-at=%s:9:6 %s -fmodules -fmodules-cache-path=%t \
102+
// RUN: c-index-test -code-completion-at=%s:12:6 %s -fmodules -fmodules-cache-path=%t \
75103
// RUN: -Xclang -fallow-pcm-with-compiler-errors -I %S/Inputs/error | FileCheck -check-prefix=COMPLETE %s
76104
// COMPLETE: ObjCInstanceMethodDecl:{ResultType int}{TypedText method}
77105
// COMPLETE: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2}
78106

79107
// RUN: c-index-test -test-load-source local %s -fmodules -fmodules-cache-path=%t \
80108
// RUN: -Xclang -fallow-pcm-with-compiler-errors -I %S/Inputs/error | FileCheck -check-prefix=SOURCE %s
81-
// SOURCE: load-module-with-errors.m:8:6: FunctionDecl=test:8:6 (Definition) Extent=[8:1 - 10:2]
82-
// SOURCE: load-module-with-errors.m:8:18: ParmDecl=x:8:18 (Definition) Extent=[8:11 - 8:19]
83-
// SOURCE: load-module-with-errors.m:8:11: ObjCClassRef=Error:3:12 Extent=[8:11 - 8:16]
84-
// SOURCE: load-module-with-errors.m:8:21: CompoundStmt= Extent=[8:21 - 10:2]
85-
// SOURCE: load-module-with-errors.m:9:3: ObjCMessageExpr=method:4:8 Extent=[9:3 - 9:13]
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]

0 commit comments

Comments
 (0)