aboutsummaryrefslogtreecommitdiff
path: root/test/Modules
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-02 18:42:48 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-02 18:42:48 +0000
commit2f04f1843ca0ffca13b8b0d4dadd1f50dffb38b8 (patch)
treef2efcb1a10ca694d4f0e08451848f0b2a13aa649 /test/Modules
parent4f7dcdbdfc50a244c3f3ca66f15b0b39a56f8f64 (diff)
Back out my heinous hack that tricked the module generation mechanism
into using non-absolute system includes (<foo>)... ... and introduce another hack that is simultaneously more heineous and more effective. We whitelist Clang-supplied headers that augment or override system headers (such as float.h, stdarg.h, and tgmath.h). For these headers, Clang does not provide a module mapping. Instead, a system-supplied module map can refer to these headers in a system module, and Clang will look both in its own include directory and wherever the system-supplied module map suggests, then adds either or both headers. The end result is that Clang-supplied headers get merged into the system-supplied module for the C standard library. As a drive-by, fix up a few dependencies in the _Builtin_instrinsics module. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules')
-rw-r--r--test/Modules/Inputs/System/usr/include/module.map21
-rw-r--r--test/Modules/Inputs/System/usr/include/stdbool.h1
-rw-r--r--test/Modules/Inputs/System/usr/include/stdint.h1
-rw-r--r--test/Modules/Inputs/System/usr/include/stdio.h3
-rw-r--r--test/Modules/compiler_builtins.m16
-rw-r--r--test/Modules/cstd.m29
6 files changed, 55 insertions, 16 deletions
diff --git a/test/Modules/Inputs/System/usr/include/module.map b/test/Modules/Inputs/System/usr/include/module.map
new file mode 100644
index 0000000000..884b59c80c
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/module.map
@@ -0,0 +1,21 @@
+module cstd [system] {
+ // Only in compiler support directory
+ module float_constants {
+ header "float.h"
+ }
+
+ // Only in system headers directory
+ module stdio {
+ header "stdio.h"
+ }
+
+ // In both directories (compiler support version wins, does not forward)
+ module stdbool {
+ header "stdbool.h"
+ }
+
+ // In both directories (compiler support version wins, forwards)
+ module stdint {
+ header "stdint.h"
+ }
+}
diff --git a/test/Modules/Inputs/System/usr/include/stdbool.h b/test/Modules/Inputs/System/usr/include/stdbool.h
new file mode 100644
index 0000000000..760d7dc48e
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdbool.h
@@ -0,0 +1 @@
+// Testing hack: does not define bool/true/false.
diff --git a/test/Modules/Inputs/System/usr/include/stdint.h b/test/Modules/Inputs/System/usr/include/stdint.h
new file mode 100644
index 0000000000..e8e50f9029
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdint.h
@@ -0,0 +1 @@
+typedef int my_awesome_nonstandard_integer_type;
diff --git a/test/Modules/Inputs/System/usr/include/stdio.h b/test/Modules/Inputs/System/usr/include/stdio.h
new file mode 100644
index 0000000000..9a7b106303
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdio.h
@@ -0,0 +1,3 @@
+typedef struct { int id; } FILE;
+int fprintf(FILE*restrict, const char* restrict format, ...);
+
diff --git a/test/Modules/compiler_builtins.m b/test/Modules/compiler_builtins.m
index 5ec2e978b3..a4f1dc2132 100644
--- a/test/Modules/compiler_builtins.m
+++ b/test/Modules/compiler_builtins.m
@@ -1,22 +1,6 @@
// RUN: rm -rf %t
// RUN: %clang -fsyntax-only -fmodules -fmodule-cache-path %t -D__need_wint_t %s -Xclang -verify
-@import _Builtin_stdlib.float_constants;
-
-float getFltMax() { return FLT_MAX; }
-
-@import _Builtin_stdlib.limits;
-
-char getCharMax() { return CHAR_MAX; }
-
-// MS limits.h provides size_t.
-// XFAIL: win32
-size_t size; // expected-error{{unknown type name 'size_t'}}
-
-@import _Builtin_stdlib.stdint;
-
-intmax_t value;
-
#ifdef __SSE__
@import _Builtin_intrinsics.intel.sse;
#endif
diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m
new file mode 100644
index 0000000000..8bd5c92cff
--- /dev/null
+++ b/test/Modules/cstd.m
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -isysroot %S/Inputs/System -fmodules -fmodule-cache-path %t -D__need_wint_t %s -Xclang -verify
+
+// Supplied by compiler, but referenced from the "/usr/include" module map.
+@import cstd.float_constants;
+
+float getFltMax() { return FLT_MAX; }
+
+// Supplied by the "/usr/include" module map.
+@import cstd.stdio;
+
+void test_fprintf(FILE *file) {
+ fprintf(file, "Hello, modules\n");
+}
+
+// Supplied by compiler, which forwards to the the "/usr/include" version.
+@import cstd.stdint;
+
+my_awesome_nonstandard_integer_type value;
+
+// Supplied by the compiler; that version wins.
+@import cstd.stdbool;
+
+#ifndef bool
+# error "bool was not defined!"
+#endif
+
+
+