r285377 - [Modules] Add testcase for builtins used in umbrella headers

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 19:30:46 PDT 2016


Author: bruno
Date: Thu Oct 27 21:30:45 2016
New Revision: 285377

URL: http://llvm.org/viewvc/llvm-project?rev=285377&view=rev
Log:
[Modules] Add testcase for builtins used in umbrella headers

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.

Added:
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h
    cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
Modified:
    cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap

Added: cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h?rev=285377&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h Thu Oct 27 21:30:45 2016
@@ -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

Added: cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h?rev=285377&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h (added)
+++ cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h Thu Oct 27 21:30:45 2016
@@ -0,0 +1,14 @@
+#ifndef __my_int
+#define __my_int
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef int_fast32_t myint;
+}
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap?rev=285377&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap Thu Oct 27 21:30:45 2016
@@ -0,0 +1,4 @@
+framework module A [extern_c] {
+    umbrella header "A.h"
+    export *
+}

Modified: cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c%2B%2B/v1/module.modulemap?rev=285377&r1=285376&r2=285377&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap Thu Oct 27 21:30:45 2016
@@ -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 * }
 }

Added: cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c%2B%2B/v1/stdint.h?rev=285377&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h (added)
+++ cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h Thu Oct 27 21:30:45 2016
@@ -0,0 +1,6 @@
+#ifndef LIBCXX_STDINT_H
+#define LIBCXX_STDINT_H
+
+#include_next "stdint.h"
+
+#endif

Added: cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/umbrella-header-include-builtin.mm?rev=285377&view=auto
==============================================================================
--- cfe/trunk/test/Modules/umbrella-header-include-builtin.mm (added)
+++ cfe/trunk/test/Modules/umbrella-header-include-builtin.mm Thu Oct 27 21:30:45 2016
@@ -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>




More information about the cfe-commits mailing list