[PATCH] D95989: [ASTReader] Always rebuild a cached module that has errors
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa2c1054c303f: [ASTReader] Always rebuild a cached module that has errors (authored by bnbarham, committed by akyrtzi). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D95989/new/ https://reviews.llvm.org/D95989 Files: clang/lib/Serialization/ASTReader.cpp clang/test/Modules/Inputs/error.h clang/test/Modules/Inputs/error/error.h clang/test/Modules/Inputs/error/module.modulemap clang/test/Modules/Inputs/module.map clang/test/Modules/load-module-with-errors.m Index: clang/test/Modules/load-module-with-errors.m === --- clang/test/Modules/load-module-with-errors.m +++ clang/test/Modules/load-module-with-errors.m @@ -1,25 +1,68 @@ // RUN: rm -rf %t // RUN: mkdir %t +// RUN: mkdir %t/prebuilt -// Write out a module with errors make sure it can be read // RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -emit-module \ -// RUN: -fmodule-name=error %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -I %S/Inputs \ -// RUN: -fimplicit-module-maps -ast-print %s | FileCheck %s +// RUN: -fmodule-name=error -o %t/prebuilt/error.pcm \ +// RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// Shouldn't build the cached module (that has errors) when not allowing errors +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c %s +// RUN: find %t -name "error-*.pcm" | not grep error + +// Should build the cached module when allowing errors +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s +// RUN: find %t -name "error-*.pcm" | grep error + +// Make sure there is still an error after the module is already in the cache +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s + +// Should rebuild the cached module if it had an error (if it wasn't rebuilt +// the verify would fail as it would be the PCH error instead) +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s // allow-pcm-with-compiler-errors should also allow errors in PCH -// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x c++ -emit-pch \ -// RUN: -o %t/check.pch %S/Inputs/error.h +// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x objective-c \ +// RUN: -o %t/check.pch -emit-pch %S/Inputs/error/error.h -@import error; +// pcherror-error@* {{PCH file contains compiler errors}} +@import error; // expected-error {{could not build module 'error'}} -void test(id x) { +void test(Error *x) { [x method]; } // CHECK: @interface Error // CHECK-NEXT: - (int)method; +// CHECK-NEXT: - (id)method2; // CHECK-NEXT: @end -// CHECK: void test(id x) +// CHECK: void test(Error *x) Index: clang/test/Modules/Inputs/module.map === --- clang/test/Modules/Inputs/module.map +++ clang/test/Modules/Inputs/module.map @@ -483,4 +483,3 @@ header "template-nontrivial1.h" export * } -module error { header "error.h" } Index: clang/test/Modules/Inputs/error/module.modulemap === --- /dev/null +++ clang/test/Modules/Inputs/error/module.modulemap @@ -0,0 +1,3 @@ +module error { + header
[PATCH] D95989: [ASTReader] Always rebuild a cached module that has errors
bnbarham updated this revision to Diff 321308. bnbarham set the repository for this revision to rG LLVM Github Monorepo. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D95989/new/ https://reviews.llvm.org/D95989 Files: clang/lib/Serialization/ASTReader.cpp clang/test/Modules/Inputs/error.h clang/test/Modules/Inputs/error/error.h clang/test/Modules/Inputs/error/module.modulemap clang/test/Modules/Inputs/module.map clang/test/Modules/load-module-with-errors.m Index: clang/test/Modules/load-module-with-errors.m === --- clang/test/Modules/load-module-with-errors.m +++ clang/test/Modules/load-module-with-errors.m @@ -1,25 +1,68 @@ // RUN: rm -rf %t // RUN: mkdir %t +// RUN: mkdir %t/prebuilt -// Write out a module with errors make sure it can be read // RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -emit-module \ -// RUN: -fmodule-name=error %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -I %S/Inputs \ -// RUN: -fimplicit-module-maps -ast-print %s | FileCheck %s +// RUN: -fmodule-name=error -o %t/prebuilt/error.pcm \ +// RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// Shouldn't build the cached module (that has errors) when not allowing errors +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c %s +// RUN: find %t -name "error-*.pcm" | not grep error + +// Should build the cached module when allowing errors +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s +// RUN: find %t -name "error-*.pcm" | grep error + +// Make sure there is still an error after the module is already in the cache +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s + +// Should rebuild the cached module if it had an error (if it wasn't rebuilt +// the verify would fail as it would be the PCH error instead) +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s // allow-pcm-with-compiler-errors should also allow errors in PCH -// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x c++ -emit-pch \ -// RUN: -o %t/check.pch %S/Inputs/error.h +// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x objective-c \ +// RUN: -o %t/check.pch -emit-pch %S/Inputs/error/error.h -@import error; +// pcherror-error@* {{PCH file contains compiler errors}} +@import error; // expected-error {{could not build module 'error'}} -void test(id x) { +void test(Error *x) { [x method]; } // CHECK: @interface Error // CHECK-NEXT: - (int)method; +// CHECK-NEXT: - (id)method2; // CHECK-NEXT: @end -// CHECK: void test(id x) +// CHECK: void test(Error *x) Index: clang/test/Modules/Inputs/module.map === --- clang/test/Modules/Inputs/module.map +++ clang/test/Modules/Inputs/module.map @@ -483,4 +483,3 @@ header "template-nontrivial1.h" export * } -module error { header "error.h" } Index: clang/test/Modules/Inputs/error/module.modulemap === --- /dev/null +++ clang/test/Modules/Inputs/error/module.modulemap @@ -0,0 +1,3 @@ +module error { + header "error.h" +} Index: clang/test/Modules/Inputs/error/error.h === --- /dev/null +++
[PATCH] D95989: [ASTReader] Always rebuild a cached module that has errors
bnbarham updated this revision to Diff 321305. bnbarham added a comment. Added a couple semi-colons to the test file CHANGES SINCE LAST ACTION https://reviews.llvm.org/D95989/new/ https://reviews.llvm.org/D95989 Files: clang/lib/Serialization/ASTReader.cpp clang/test/Modules/Inputs/error.h clang/test/Modules/Inputs/error/error.h clang/test/Modules/Inputs/error/module.modulemap clang/test/Modules/Inputs/module.map clang/test/Modules/load-module-with-errors.m Index: clang/test/Modules/load-module-with-errors.m === --- clang/test/Modules/load-module-with-errors.m +++ clang/test/Modules/load-module-with-errors.m @@ -1,25 +1,68 @@ // RUN: rm -rf %t // RUN: mkdir %t +// RUN: mkdir %t/prebuilt -// Write out a module with errors make sure it can be read // RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -emit-module \ -// RUN: -fmodule-name=error %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -I %S/Inputs \ -// RUN: -fimplicit-module-maps -ast-print %s | FileCheck %s +// RUN: -fmodule-name=error -o %t/prebuilt/error.pcm \ +// RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// Shouldn't build the cached module (that has errors) when not allowing errors +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c %s +// RUN: find %t -name "error-*.pcm" | not grep error + +// Should build the cached module when allowing errors +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s +// RUN: find %t -name "error-*.pcm" | grep error + +// Make sure there is still an error after the module is already in the cache +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s + +// Should rebuild the cached module if it had an error (if it wasn't rebuilt +// the verify would fail as it would be the PCH error instead) +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s // allow-pcm-with-compiler-errors should also allow errors in PCH -// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x c++ -emit-pch \ -// RUN: -o %t/check.pch %S/Inputs/error.h +// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x objective-c \ +// RUN: -o %t/check.pch -emit-pch %S/Inputs/error/error.h -@import error; +// pcherror-error@* {{PCH file contains compiler errors}} +@import error; // expected-error {{could not build module 'error'}} -void test(id x) { +void test(Error *x) { [x method]; } // CHECK: @interface Error // CHECK-NEXT: - (int)method; +// CHECK-NEXT: - (id)method2; // CHECK-NEXT: @end -// CHECK: void test(id x) +// CHECK: void test(Error *x) Index: clang/test/Modules/Inputs/module.map === --- clang/test/Modules/Inputs/module.map +++ clang/test/Modules/Inputs/module.map @@ -483,4 +483,3 @@ header "template-nontrivial1.h" export * } -module error { header "error.h" } Index: clang/test/Modules/Inputs/error/module.modulemap === --- /dev/null +++ clang/test/Modules/Inputs/error/module.modulemap @@ -0,0 +1,3 @@ +module error { + header "error.h" +} Index: clang/test/Modules/Inputs/error/error.h === --- /dev/null +++ clang/test/Modules/Inputs/error/error.h @@ -0,0
[PATCH] D95989: [ASTReader] Always rebuild a cached module that has errors
bnbarham created this revision. bnbarham added a reviewer: akyrtzi. bnbarham requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. A module in the cache with an error should just be a cache miss. If allowing errors (with -fallow-pcm-with-compiler-errors), a rebuild is needed so that the appropriate diagnostics are output and in case search paths have changed. If not allowing errors, the module was built *allowing* errors and thus should be rebuilt regardless. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D95989 Files: clang/lib/Serialization/ASTReader.cpp clang/test/Modules/Inputs/error.h clang/test/Modules/Inputs/error/error.h clang/test/Modules/Inputs/error/module.modulemap clang/test/Modules/Inputs/module.map clang/test/Modules/load-module-with-errors.m Index: clang/test/Modules/load-module-with-errors.m === --- clang/test/Modules/load-module-with-errors.m +++ clang/test/Modules/load-module-with-errors.m @@ -1,25 +1,68 @@ // RUN: rm -rf %t // RUN: mkdir %t +// RUN: mkdir %t/prebuilt -// Write out a module with errors make sure it can be read // RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -emit-module \ -// RUN: -fmodule-name=error %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ -// RUN: -fmodules-cache-path=%t -x objective-c -I %S/Inputs \ -// RUN: -fimplicit-module-maps -ast-print %s | FileCheck %s +// RUN: -fmodule-name=error -o %t/prebuilt/error.pcm \ +// RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fprebuilt-module-path=%t/prebuilt -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=error=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -ast-print %s | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodule-file=%t/prebuilt/error.pcm -fmodules-cache-path=%t \ +// RUN: -verify=pcherror %s + +// Shouldn't build the cached module (that has errors) when not allowing errors +// RUN: not %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c %s +// RUN: find %t -name "error-*.pcm" | not grep error + +// Should build the cached module when allowing errors +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s +// RUN: find %t -name "error-*.pcm" | grep error + +// Make sure there is still an error after the module is already in the cache +// RUN: %clang_cc1 -fsyntax-only -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s + +// Should rebuild the cached module if it had an error (if it wasn't rebuilt +// the verify would fail as it would be the PCH error instead) +// RUN: %clang_cc1 -fsyntax-only -fmodules \ +// RUN: -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/error \ +// RUN: -x objective-c -verify %s // allow-pcm-with-compiler-errors should also allow errors in PCH -// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x c++ -emit-pch \ -// RUN: -o %t/check.pch %S/Inputs/error.h +// RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x objective-c \ +// RUN: -o %t/check.pch -emit-pch %S/Inputs/error/error.h -@import error; +// pcherror-error@* {{PCH file contains compiler errors}} +@import error; // expected-error {{could not build module 'error'}} -void test(id x) { +void test(Error *x) { [x method]; } // CHECK: @interface Error // CHECK-NEXT: - (int)method; +// CHECK-NEXT: - (id)method2; // CHECK-NEXT: @end -// CHECK: void test(id x) +// CHECK: void test(Error *x) Index: clang/test/Modules/Inputs/module.map === --- clang/test/Modules/Inputs/module.map +++ clang/test/Modules/Inputs/module.map @@ -483,4 +483,3 @@ header "template-nontrivial1.h" export * } -module error { header "error.h" } Index: clang/test/Modules/Inputs/error/module.modulemap