From: Elad Cohen Date: Sun, 4 Sep 2016 06:00:42 +0000 (+0000) Subject: [Modules] Add 'freestanding' to the 'requires-declaration' feature-list. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=430938bacf1c5a7a652a77344b932bb28e3b7f29;p=clang [Modules] Add 'freestanding' to the 'requires-declaration' feature-list. This adds support for modules that require (non-)freestanding environment, such as the compiler builtin mm_malloc submodule. Differential Revision: https://reviews.llvm.org/D23871 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280613 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/Modules.rst b/docs/Modules.rst index e11145ed71..ad71a95420 100644 --- a/docs/Modules.rst +++ b/docs/Modules.rst @@ -413,6 +413,9 @@ cplusplus cplusplus11 C++11 support is available. +freestanding + A freestanding environment is available. + gnuinlineasm GNU inline ASM is available. diff --git a/lib/Basic/Module.cpp b/lib/Basic/Module.cpp index b37deb1222..8578947db8 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("freestanding", LangOpts.Freestanding) .Case("gnuinlineasm", LangOpts.GNUAsm) .Case("objc", LangOpts.ObjC1) .Case("objc_arc", LangOpts.ObjCAutoRefCount) diff --git a/lib/Headers/module.modulemap b/lib/Headers/module.modulemap index 4654b3de29..11ef2f9029 100644 --- a/lib/Headers/module.modulemap +++ b/lib/Headers/module.modulemap @@ -63,6 +63,7 @@ module _Builtin_intrinsics [system] [extern_c] { textual header "mwaitxintrin.h" explicit module mm_malloc { + requires !freestanding header "mm_malloc.h" export * // note: for dependency } diff --git a/test/Modules/compiler_builtins_x86.c b/test/Modules/compiler_builtins_x86.c new file mode 100644 index 0000000000..f24bbafbd1 --- /dev/null +++ b/test/Modules/compiler_builtins_x86.c @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding +// expected-no-diagnostics + +#include +