diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-08-30 21:25:42 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-08-30 21:25:42 +0000 |
commit | 6736e199c78d9e6cb33c2a3b03afa13666a6a53b (patch) | |
tree | b3e166e92ef41e4d8e005bd5a2ed3b01e7c46078 | |
parent | c08f5de7bc99536a2c7be21a5842fc4a1f52e188 (diff) | |
download | bcm5719-llvm-6736e199c78d9e6cb33c2a3b03afa13666a6a53b.tar.gz bcm5719-llvm-6736e199c78d9e6cb33c2a3b03afa13666a6a53b.zip |
[Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.
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
7 files changed, 31 insertions, 0 deletions
diff --git a/clang/docs/Modules.rst b/clang/docs/Modules.rst index 418765468c2..e11145ed71c 100644 --- a/clang/docs/Modules.rst +++ b/clang/docs/Modules.rst @@ -413,6 +413,9 @@ cplusplus cplusplus11 C++11 support is available. +gnuinlineasm + GNU inline ASM is available. + objc Objective-C support is available. diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 3d1a40db5ea..b37deb12228 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -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) diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap index 3e40d2c08d8..4654b3de298 100644 --- a/clang/lib/Headers/module.modulemap +++ b/clang/lib/Headers/module.modulemap @@ -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 index 00000000000..7978a767e63 --- /dev/null +++ b/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h @@ -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 index 00000000000..da52f829c37 --- /dev/null +++ b/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h @@ -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 index 00000000000..a9536100d61 --- /dev/null +++ b/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map @@ -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 index 00000000000..80b1b18d074 --- /dev/null +++ b/clang/test/Modules/requires-gnuinlineasm.m @@ -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 |