[Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 30 Aug 2016 21:25:42 +0000 (21:25 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 30 Aug 2016 21:25:42 +0000 (21:25 +0000)
This adds support for modules that require (no-)gnu-inline-asm
environment, such as the compiler builtin cpuid submodule.

This is the gnu-inline-asm variant of https://reviews.llvm.org/D23871

Differential Revision: https://reviews.llvm.org/D23905

rdar://problem/26931199

llvm-svn: 280159

clang/docs/Modules.rst
clang/lib/Basic/Module.cpp
clang/lib/Headers/module.modulemap
clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h [new file with mode: 0644]
clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h [new file with mode: 0644]
clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map [new file with mode: 0644]
clang/test/Modules/requires-gnuinlineasm.m [new file with mode: 0644]

index 4187654..e11145e 100644 (file)
@@ -413,6 +413,9 @@ cplusplus
 cplusplus11
   C++11 support is available.
 
+gnuinlineasm
+  GNU inline ASM is available.
+
 objc
   Objective-C support is available.
 
index 3d1a40d..b37deb1 100644 (file)
@@ -64,6 +64,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
                         .Case("blocks", LangOpts.Blocks)
                         .Case("cplusplus", LangOpts.CPlusPlus)
                         .Case("cplusplus11", LangOpts.CPlusPlus11)
+                        .Case("gnuinlineasm", LangOpts.GNUAsm)
                         .Case("objc", LangOpts.ObjC1)
                         .Case("objc_arc", LangOpts.ObjCAutoRefCount)
                         .Case("opencl", LangOpts.OpenCL)
index 3e40d2c..4654b3d 100644 (file)
@@ -68,6 +68,7 @@ module _Builtin_intrinsics [system] [extern_c] {
     }
 
     explicit module cpuid {
+      requires gnuinlineasm
       header "cpuid.h"
     }
 
diff --git a/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h b/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h
new file mode 100644 (file)
index 0000000..7978a76
--- /dev/null
@@ -0,0 +1 @@
+// NeedsGNUInlineAsm.h
diff --git a/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h b/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h
new file mode 100644 (file)
index 0000000..da52f82
--- /dev/null
@@ -0,0 +1 @@
+__asm("foo");
diff --git a/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map b/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map
new file mode 100644 (file)
index 0000000..a953610
--- /dev/null
@@ -0,0 +1,8 @@
+framework module NeedsGNUInlineAsm {
+  header "NeedsGNUInlineAsm.h"
+
+  explicit module Asm {
+    requires gnuinlineasm
+    header "asm.h"
+  }
+}
diff --git a/clang/test/Modules/requires-gnuinlineasm.m b/clang/test/Modules/requires-gnuinlineasm.m
new file mode 100644 (file)
index 0000000..80b1b18
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules \
+// RUN:     -fimplicit-module-maps -F %S/Inputs/GNUAsm %s \
+// RUN:     -fno-gnu-inline-asm -DNO_ASM_INLINE -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules \
+// RUN:     -fimplicit-module-maps -F %S/Inputs/GNUAsm %s \
+// RUN:     -DASM_INLINE -verify
+
+#ifdef NO_ASM_INLINE
+@import NeedsGNUInlineAsm.Asm; // expected-error{{module 'NeedsGNUInlineAsm.Asm' requires feature 'gnuinlineasm'}}
+#endif
+
+#ifdef ASM_INLINE
+@import NeedsGNUInlineAsm.Asm; // expected-no-diagnostics
+#endif