[cfe-commits] r139496 - in /cfe/trunk: lib/Frontend/InitPreprocessor.cpp test/Preprocessor/init.c test/Preprocessor/predefined-exceptions.m
Douglas Gregor
dgregor at apple.com
Mon Sep 12 08:17:19 PDT 2011
Author: dgregor
Date: Mon Sep 12 10:17:19 2011
New Revision: 139496
URL: http://llvm.org/viewvc/llvm-project?rev=139496&view=rev
Log:
Only predefine the __EXCEPTIONS macro if C++ exceptions are turned on.
Only predefine the OBJC_ZEROCOST_EXCEPTIONS macro if Objective-C
exceptions are turned on. Fixes PR10910.
Added:
cfe/trunk/test/Preprocessor/predefined-exceptions.m
Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Preprocessor/init.c
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=139496&r1=139495&r2=139496&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Sep 12 10:17:19 2011
@@ -426,7 +426,9 @@
if (LangOpts.ObjC1) {
if (LangOpts.ObjCNonFragileABI) {
Builder.defineMacro("__OBJC2__");
- Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
+
+ if (LangOpts.ObjCExceptions)
+ Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
}
if (LangOpts.getGCMode() != LangOptions::NonGC)
@@ -452,7 +454,7 @@
Builder.defineMacro("__BLOCKS__");
}
- if (LangOpts.Exceptions)
+ if (LangOpts.CXXExceptions)
Builder.defineMacro("__EXCEPTIONS");
if (LangOpts.RTTI)
Builder.defineMacro("__GXX_RTTI");
Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=139496&r1=139495&r2=139496&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Sep 12 10:17:19 2011
@@ -94,7 +94,7 @@
// OBJCGC:#define __OBJC_GC__ 1
//
//
-// RUN: %clang_cc1 -x objective-c -fobjc-nonfragile-abi -E -dM < /dev/null | FileCheck -check-prefix NONFRAGILE %s
+// RUN: %clang_cc1 -x objective-c -fobjc-exceptions -fobjc-nonfragile-abi -E -dM < /dev/null | FileCheck -check-prefix NONFRAGILE %s
//
// NONFRAGILE:#define OBJC_ZEROCOST_EXCEPTIONS 1
// NONFRAGILE:#define __OBJC2__ 1
Added: cfe/trunk/test/Preprocessor/predefined-exceptions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-exceptions.m?rev=139496&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/predefined-exceptions.m (added)
+++ cfe/trunk/test/Preprocessor/predefined-exceptions.m Mon Sep 12 10:17:19 2011
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x objective-c -fobjc-exceptions -fobjc-nonfragile-abi -fexceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-NOCXX %s
+// CHECK-OBJC-NOCXX: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-OBJC-NOCXX-NOT: #define __EXCEPTIONS 1
+
+// RUN: %clang_cc1 -x objective-c++ -fobjc-exceptions -fobjc-nonfragile-abi -fexceptions -fcxx-exceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-CXX %s
+// CHECK-OBJC-CXX: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-OBJC-CXX: #define __EXCEPTIONS 1
+
+// RUN: %clang_cc1 -x objective-c++ -fobjc-nonfragile-abi -fexceptions -fcxx-exceptions -E -dM %s | FileCheck -check-prefix=CHECK-NOOBJC-CXX %s
+// CHECK-NOOBJC-CXX-NOT: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-NOOBJC-CXX: #define __EXCEPTIONS 1
+
+// RUN: %clang_cc1 -x objective-c -fobjc-nonfragile-abi -E -dM %s | FileCheck -check-prefix=CHECK-NOOBJC-NOCXX %s
+// CHECK-NOOBJC-NOCXX-NOT: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-NOOBJC-NOCXX-NOT: #define __EXCEPTIONS 1
More information about the cfe-commits
mailing list