[Modules] Add testcase for builtins used in umbrella headers
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 28 Oct 2016 02:30:45 +0000 (02:30 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 28 Oct 2016 02:30:45 +0000 (02:30 +0000)
This used to work before r284797 + r285152, which exposed something
interesting; some users include builtins from umbrella headers.

Clang should emit a warning to warn users this is not a good practice
and umbrella headers shouldn't get the
implicitly-add-the-builtin-version behavior for builtin header names.

While we're not there, add the testcase to represent the way it
currently works.

llvm-svn: 285377

clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h [new file with mode: 0644]
clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h [new file with mode: 0644]
clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap [new file with mode: 0644]
clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h [new file with mode: 0644]
clang/test/Modules/umbrella-header-include-builtin.mm [new file with mode: 0644]

diff --git a/clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h b/clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h
new file mode 100644 (file)
index 0000000..2ee00c1
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __my_a
+#define __my_a
+
+#include <A/int.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef int_fast32_t my_a;
+}
+
+#endif
diff --git a/clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h b/clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h
new file mode 100644 (file)
index 0000000..340315e
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __my_int
+#define __my_int
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef int_fast32_t myint;
+}
+
+#endif
diff --git a/clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap b/clang/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap
new file mode 100644 (file)
index 0000000..1e91233
--- /dev/null
@@ -0,0 +1,4 @@
+framework module A [extern_c] {
+    umbrella header "A.h"
+    export *
+}
index c352f4a..b06142a 100644 (file)
@@ -3,5 +3,8 @@ module "libc++" {
   module stdlib { header "stdlib.h" export * }
   module stddef { header "stddef.h" export * }
   module stdio { textual header "stdio.h" export * }
+  // FIXME: remove "textual" from stdint module below once the issue
+  // between umbrella headers and builtins is resolved.
+  module stdint { textual header "stdint.h" export * }
   module __config { header "__config" export * }
 }
diff --git a/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h b/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h
new file mode 100644 (file)
index 0000000..7a68441
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef LIBCXX_STDINT_H
+#define LIBCXX_STDINT_H
+
+#include_next "stdint.h"
+
+#endif
diff --git a/clang/test/Modules/umbrella-header-include-builtin.mm b/clang/test/Modules/umbrella-header-include-builtin.mm
new file mode 100644 (file)
index 0000000..09e1cf9
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: rm -rf %t
+// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
+
+#include <A/A.h>