forked from OSchip/llvm-project
Add 'has_feature(cxx_exceptions)' to allow code to determine via preprocessor logic if C++ exceptions are enabled.
llvm-svn: 90378
This commit is contained in:
parent
26ada867ba
commit
5ef26fb4fd
|
@ -488,6 +488,9 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
|
|||
return false;
|
||||
case 8:
|
||||
if (II->isStr("cxx_rtti")) return LangOpts.RTTI;
|
||||
return false;
|
||||
case 14:
|
||||
if (II->isStr("cxx_exceptions")) return LangOpts.Exceptions;
|
||||
return false;
|
||||
case 19:
|
||||
if (II->isStr("objc_nonfragile_abi")) return LangOpts.ObjCNonFragileABI;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: clang -E -fexceptions %s -o - | FileCheck --check-prefix=CHECK-EXCEPTIONS %s
|
||||
// RUN: clang -E -fno-exceptions %s -o - | FileCheck --check-prefix=CHECK-NO-EXCEPTIONS %s
|
||||
|
||||
#if __has_feature(cxx_exceptions)
|
||||
int foo();
|
||||
#else
|
||||
int bar();
|
||||
#endif
|
||||
|
||||
// CHECK-EXCEPTIONS: foo
|
||||
// CHECK-NO-EXCEPTIONS: bar
|
Loading…
Reference in New Issue