[cfe-commits] r90378 - in /cfe/trunk: lib/Lex/PPMacroExpansion.cpp test/Lexer/has_feature_exceptions.cpp

Ted Kremenek kremenek at apple.com
Wed Dec 2 17:34:15 PST 2009


Author: kremenek
Date: Wed Dec  2 19:34:15 2009
New Revision: 90378

URL: http://llvm.org/viewvc/llvm-project?rev=90378&view=rev
Log:
Add 'has_feature(cxx_exceptions)' to allow code to determine via preprocessor logic if C++ exceptions are enabled.

Added:
    cfe/trunk/test/Lexer/has_feature_exceptions.cpp
Modified:
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=90378&r1=90377&r2=90378&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Dec  2 19:34:15 2009
@@ -488,6 +488,9 @@
     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;

Added: cfe/trunk/test/Lexer/has_feature_exceptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_exceptions.cpp?rev=90378&view=auto

==============================================================================
--- cfe/trunk/test/Lexer/has_feature_exceptions.cpp (added)
+++ cfe/trunk/test/Lexer/has_feature_exceptions.cpp Wed Dec  2 19:34:15 2009
@@ -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





More information about the cfe-commits mailing list