Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 430938b

Browse files
author
Elad Cohen
committed
[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
1 parent 6916520 commit 430938b

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

docs/Modules.rst

+3
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ cplusplus
413413
cplusplus11
414414
C++11 support is available.
415415

416+
freestanding
417+
A freestanding environment is available.
418+
416419
gnuinlineasm
417420
GNU inline ASM is available.
418421

lib/Basic/Module.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
6464
.Case("blocks", LangOpts.Blocks)
6565
.Case("cplusplus", LangOpts.CPlusPlus)
6666
.Case("cplusplus11", LangOpts.CPlusPlus11)
67+
.Case("freestanding", LangOpts.Freestanding)
6768
.Case("gnuinlineasm", LangOpts.GNUAsm)
6869
.Case("objc", LangOpts.ObjC1)
6970
.Case("objc_arc", LangOpts.ObjCAutoRefCount)

lib/Headers/module.modulemap

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module _Builtin_intrinsics [system] [extern_c] {
6363
textual header "mwaitxintrin.h"
6464

6565
explicit module mm_malloc {
66+
requires !freestanding
6667
header "mm_malloc.h"
6768
export * // note: for <stdlib.h> dependency
6869
}

test/Modules/compiler_builtins_x86.c

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: rm -rf %t
2+
// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
3+
// expected-no-diagnostics
4+
5+
#include<x86intrin.h>
6+

0 commit comments

Comments
 (0)