From: Bruno Cardoso Lopes Date: Tue, 30 Aug 2016 21:25:42 +0000 (+0000) Subject: [Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b69026bf2c3fabafe17600662c9824aed7ce7b5c;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280159 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/Modules.rst b/docs/Modules.rst index 418765468c..e11145ed71 100644 --- a/docs/Modules.rst +++ b/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/lib/Basic/Module.cpp b/lib/Basic/Module.cpp index 3d1a40db5e..b37deb1222 100644 --- a/lib/Basic/Module.cpp +++ b/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/lib/Headers/module.modulemap b/lib/Headers/module.modulemap index 3e40d2c08d..4654b3de29 100644 --- a/lib/Headers/module.modulemap +++ b/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/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h new file mode 100644 index 0000000000..7978a767e6 --- /dev/null +++ b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h @@ -0,0 +1 @@ +// NeedsGNUInlineAsm.h diff --git a/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h new file mode 100644 index 0000000000..da52f829c3 --- /dev/null +++ b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h @@ -0,0 +1 @@ +__asm("foo"); diff --git a/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map new file mode 100644 index 0000000000..a9536100d6 --- /dev/null +++ b/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/test/Modules/requires-gnuinlineasm.m b/test/Modules/requires-gnuinlineasm.m new file mode 100644 index 0000000000..80b1b18d07 --- /dev/null +++ b/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