From fb6358d2b5b25601a3172011238e229995f1b1a4 Mon Sep 17 00:00:00 2001 From: Elad Cohen Date: Sun, 4 Sep 2016 06:00:42 +0000 Subject: [PATCH] [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 llvm-svn: 280613 --- clang/docs/Modules.rst | 3 +++ clang/lib/Basic/Module.cpp | 1 + clang/lib/Headers/module.modulemap | 1 + clang/test/Modules/compiler_builtins_x86.c | 6 ++++++ 4 files changed, 11 insertions(+) create mode 100644 clang/test/Modules/compiler_builtins_x86.c diff --git a/clang/docs/Modules.rst b/clang/docs/Modules.rst index e11145ed71c8..ad71a95420b2 100644 --- a/clang/docs/Modules.rst +++ b/clang/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/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index b37deb122282..8578947db82c 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("freestanding", LangOpts.Freestanding) .Case("gnuinlineasm", LangOpts.GNUAsm) .Case("objc", LangOpts.ObjC1) .Case("objc_arc", LangOpts.ObjCAutoRefCount) diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap index 4654b3de2987..11ef2f902945 100644 --- a/clang/lib/Headers/module.modulemap +++ b/clang/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/clang/test/Modules/compiler_builtins_x86.c b/clang/test/Modules/compiler_builtins_x86.c new file mode 100644 index 000000000000..f24bbafbd13b --- /dev/null +++ b/clang/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 + -- 2.34.1