Skip to content

Commit 247823a

Browse files
brooksdavisresistor
authored andcommitted
Add __has_feature(cheri)
This is intended to replace __has_feature(capabilities) which is almost certainly too generic to upstream. We'll support them side by side for the long term in our tree, but projects should generally migrate to __has_feature(cheri) as their need for older compilers passes.
1 parent 4f4f13d commit 247823a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/include/clang/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
319319

320320
// CHERI features:
321321
FEATURE(capabilities, PP.getTargetInfo().SupportsCapabilities())
322+
FEATURE(cheri, PP.getTargetInfo().SupportsCapabilities())
322323
FEATURE(pointer_interpretation, PP.getTargetInfo().SupportsCapabilities())
323324
FEATURE(cheri_casts, PP.getTargetInfo().SupportsCapabilities())
324325
// CHERI typed sealed pointers

clang/test/Preprocessor/cheri-features.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-MIPS %s
66

77

8+
#if __has_feature(cheri)
9+
#pragma message("__has_feature(cheri)")
10+
// CHECK-CHERI: warning: __has_feature(cheri)
11+
void* __capability w = 0;
12+
#else
13+
#pragma message("no cheri")
14+
// CHECK-MIPS: warning: no cheri
15+
#endif
16+
817
#if __has_feature(capabilities)
918
#pragma message("__has_feature(capabilities)")
1019
// CHECK-CHERI: warning: __has_feature(capabilities)

0 commit comments

Comments
 (0)