]> granicus.if.org Git - clang/commitdiff
[Modules] Add 'freestanding' to the 'requires-declaration' feature-list.
authorElad Cohen <elad2.cohen@intel.com>
Sun, 4 Sep 2016 06:00:42 +0000 (06:00 +0000)
committerElad Cohen <elad2.cohen@intel.com>
Sun, 4 Sep 2016 06:00:42 +0000 (06:00 +0000)
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

docs/Modules.rst
lib/Basic/Module.cpp
lib/Headers/module.modulemap
test/Modules/compiler_builtins_x86.c [new file with mode: 0644]

index e11145ed71c8ce092d071fc25618081067b434e8..ad71a95420b245242b8dc07aa22b187e9f22c486 100644 (file)
@@ -413,6 +413,9 @@ cplusplus
 cplusplus11
   C++11 support is available.
 
+freestanding
+  A freestanding environment is available.
+
 gnuinlineasm
   GNU inline ASM is available.
 
index b37deb122282fbbe8331e26680382e871347c172..8578947db82cee6fc0f708a49d9812d74454bb65 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("freestanding", LangOpts.Freestanding)
                         .Case("gnuinlineasm", LangOpts.GNUAsm)
                         .Case("objc", LangOpts.ObjC1)
                         .Case("objc_arc", LangOpts.ObjCAutoRefCount)
index 4654b3de2987b2057495742cf72892da8cd17532..11ef2f902945b9a49d38930f435f4de3b01a1ed8 100644 (file)
@@ -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 <stdlib.h> dependency
     }
diff --git a/test/Modules/compiler_builtins_x86.c b/test/Modules/compiler_builtins_x86.c
new file mode 100644 (file)
index 0000000..f24bbaf
--- /dev/null
@@ -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<x86intrin.h>
+