summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-08-09 08:48:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-08-09 08:48:41 +0000
commit0f99d6a4413e3da6ec242c0ab715d6699045dea8 (patch)
tree4ae2e591505c54ad7078c0d5235c3c9cbef143b5 /clang/test
parent38c1e6d355e45f73539326a3a1dee1ce0c5738b7 (diff)
downloadbcm5719-llvm-0f99d6a4413e3da6ec242c0ab715d6699045dea8.tar.gz
bcm5719-llvm-0f99d6a4413e3da6ec242c0ab715d6699045dea8.zip
[modules] PR22534: Load files specified by -fmodule-file= eagerly. In particular, this avoids the need to re-parse module map files when using such a module.
llvm-svn: 244416
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Index/pch-depending-on-deleted-module.c2
-rw-r--r--clang/test/Modules/dependency-gen.modulemap36
-rw-r--r--clang/test/Modules/explicit-build-missing-files.cpp21
-rw-r--r--clang/test/Modules/explicit-build.cpp5
-rw-r--r--clang/test/Modules/fatal-module-loader-error.m4
-rw-r--r--clang/test/Modules/relative-dep-gen.cpp6
6 files changed, 59 insertions, 15 deletions
diff --git a/clang/test/Index/pch-depending-on-deleted-module.c b/clang/test/Index/pch-depending-on-deleted-module.c
index a0fbaf559fc..8efa66a3237 100644
--- a/clang/test/Index/pch-depending-on-deleted-module.c
+++ b/clang/test/Index/pch-depending-on-deleted-module.c
@@ -9,6 +9,6 @@
// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -I %S/Inputs/Headers -verify-pch %t/use_LibA.pch 2>&1 | FileCheck -check-prefix=VERIFY %s
// RUN: not c-index-test -test-load-source all -x c -fmodules -fimplicit-module-maps -Xclang -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -I %S/Inputs/Headers -include-pch %t/use_LibA.pch %s 2>&1 | FileCheck -check-prefix=INDEX %s
-// VERIFY: fatal error: malformed or corrupted AST file: 'Unable to load module
+// VERIFY: fatal error: module file '{{.*}}LibA.pcm' not found
// INDEX: {{^}}Failure: AST deserialization error occurred{{$}}
diff --git a/clang/test/Modules/dependency-gen.modulemap b/clang/test/Modules/dependency-gen.modulemap
index ba109c2be40..ace1177a3e5 100644
--- a/clang/test/Modules/dependency-gen.modulemap
+++ b/clang/test/Modules/dependency-gen.modulemap
@@ -1,10 +1,10 @@
// RUN: cd %S
// RUN: rm -rf %t
//
-// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse %s -dependency-file - -MT implicit.pcm -o %t/implicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s
+// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse %s -dependency-file - -MT implicit.pcm -o %t/implicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s --check-prefix=IMPLICIT
//
// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test-base -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse Inputs/dependency-gen-base.modulemap -o %t/base.pcm -fmodule-map-file-home-is-cwd
-// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t/base.pcm %s -dependency-file - -MT explicit.pcm -o %t/explicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s
+// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t/base.pcm %s -dependency-file - -MT explicit.pcm -o %t/explicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s --check-prefix=EXPLICIT
module "test" {
export *
header "Inputs/dependency-gen.h"
@@ -14,10 +14,30 @@ module "test" {
extern module "test-base2" "Inputs/dependency-gen-base2.modulemap"
extern module "test-base" "Inputs/dependency-gen-base.modulemap"
-// CHECK-DAG: {{[/\\]}}dependency-gen.modulemap
-// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap
-// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base2.modulemap
+// For implicit use of a module via the module cache, the input files
+// referenced by the .pcm are also dependencies of this build.
+//
+// IMPLICIT-DAG: {{[/\\]}}dependency-gen.modulemap
+// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap
+// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base2.modulemap
+// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
+// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included.h
+// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h
-// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
-// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included.h
-// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h
+// For an explicit use of a module via -fmodule-file=, the other module maps
+// and included headers are not dependencies of this target (they are instead
+// dependencies of the explicitly-specified .pcm input).
+//
+// FIXME: We should avoid loading the other referenced module maps (we already
+// have a parsed copy of their contents from the .pcm file) and thus not list
+// them here.
+//
+// FIXME: We should list a dependency on the explicitly specified .pcm files
+// (whether or not -module-file-deps is specified on the command line).
+//
+// EXPLICIT-FIXME-NOT: dependency-gen-
+// EXPLICIT-FIXME: {{.*}}/base.pcm
+//
+// EXPLICIT: {{^}}explicit.pcm:
+// EXPLICIT: {{.*}}/dependency-gen.modulemap
+// EXPLICIT: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
diff --git a/clang/test/Modules/explicit-build-missing-files.cpp b/clang/test/Modules/explicit-build-missing-files.cpp
new file mode 100644
index 00000000000..2ea157b934c
--- /dev/null
+++ b/clang/test/Modules/explicit-build-missing-files.cpp
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'extern int a;' > %t/a.h
+// RUN: echo 'extern int b;' > %t/b.h
+// RUN: echo 'module a { header "a.h" header "b.h" }' > %t/modulemap
+
+// We lazily check that the files referenced by an explicitly-specified .pcm
+// file exist. Test this by removing files and ensuring that the compilation
+// still succeeds.
+//
+// RUN: %clang_cc1 -fmodules -I %t -emit-module -fmodule-name=a -x c++ %t/modulemap -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s
+// RUN: rm %t/modulemap
+// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s
+// RUN: rm %t/b.h
+// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s
+// RUN: rm %t/a.h
+// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -verify
+
+#include "a.h" // expected-error {{file not found}}
+int x = b;
diff --git a/clang/test/Modules/explicit-build.cpp b/clang/test/Modules/explicit-build.cpp
index 01aa5dc68bf..4f125810558 100644
--- a/clang/test/Modules/explicit-build.cpp
+++ b/clang/test/Modules/explicit-build.cpp
@@ -179,6 +179,7 @@
// CHECK-NO-FILE-INDIRECT: error: module file '{{.*}}a.pcm' not found
// CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'b' in '{{.*}}b.pcm'
// CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'c' in '{{.*}}c.pcm'
+// CHECK-NO-FILE-INDIRECT-NOT: note:
// -------------------------------
// Check that we don't get upset if B's timestamp is newer than C's.
@@ -198,4 +199,6 @@
// RUN: -fmodule-file=%t/c.pcm \
// RUN: %s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s
//
-// CHECK-MISMATCHED-B: fatal error: malformed or corrupted AST file: {{.*}}b.pcm": module file out of date
+// CHECK-MISMATCHED-B: fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt
+// CHECK-MISMATCHED-B-NEXT: note: imported by module 'c'
+// CHECK-MISMATCHED-B-NOT: note:
diff --git a/clang/test/Modules/fatal-module-loader-error.m b/clang/test/Modules/fatal-module-loader-error.m
index 99a42c2aff4..6e6131e0001 100644
--- a/clang/test/Modules/fatal-module-loader-error.m
+++ b/clang/test/Modules/fatal-module-loader-error.m
@@ -8,13 +8,13 @@
#ifdef IMPLICIT
-// expected-error@+1{{does not appear to be}}
+// expected-error@+1{{Module.pcm' is not a valid precompiled module file}}
#import <Module/Module.h>
#pragma clang __debug crash;
#else
-// expected-error@+1{{does not appear to be}}
+// expected-error@+1{{Module.pcm' is not a valid precompiled module file}}
@import Module;
#pragma clang __debug crash;
diff --git a/clang/test/Modules/relative-dep-gen.cpp b/clang/test/Modules/relative-dep-gen.cpp
index 5fbfcfa3814..d82b5a18b1e 100644
--- a/clang/test/Modules/relative-dep-gen.cpp
+++ b/clang/test/Modules/relative-dep-gen.cpp
@@ -25,6 +25,6 @@
// CHECK-BUILD: Inputs/relative-dep-gen-1.h
// CHECK-BUILD: Inputs/relative-dep-gen-2.h
// CHECK-USE: use.o:
-// CHECK-USE: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap
-// CHECK-USE: relative-dep-gen.cpp
-// CHECK-USE: Inputs/relative-dep-gen-1.h
+// CHECK-USE-DAG: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap
+// CHECK-USE-DAG: relative-dep-gen.cpp
+// CHECK-USE-DAG: Inputs/relative-dep-gen-1.h
OpenPOWER on IntegriCloud