clang: Only define OBJC_NEW_PROPERTIES when -x objective-c
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 18 Jan 2020 01:15:02 +0000 (17:15 -0800)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 24 Jan 2020 22:55:12 +0000 (14:55 -0800)
Since 2009 (in r63846) we've been `#define`-ing OBJC_NEW_PROPERTIES all
the time on Darwin, but this macro only makes sense for `-x objective-c`
and `-x objective-c++`.  Restrict it to those cases (for which there is
already separate logic).

https://reviews.llvm.org/D72970
rdar://problem/10050342

clang/lib/Basic/Targets/OSTargets.cpp
clang/test/Preprocessor/init.c

index d4ffffc64ba8d0dbd67a49e43071377647c9dbc3..187944146bde13c93087b36a4c03b140a9e1d2ff 100644 (file)
@@ -25,7 +25,7 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
   Builder.defineMacro("__APPLE_CC__", "6000");
   Builder.defineMacro("__APPLE__");
   Builder.defineMacro("__STDC_NO_THREADS__");
-  Builder.defineMacro("OBJC_NEW_PROPERTIES");
+
   // AddressSanitizer doesn't play well with source fortification, which is on
   // by default on Darwin.
   if (Opts.Sanitize.has(SanitizerKind::Address))
index e25946304d0f294c7569e08aecf7e12e5c795748..6c9508e5c634d59ed20d3b8c61344f0ff0cda8d5 100644 (file)
 //
 //
 // RUN: %clang_cc1 -x objective-c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix OBJC %s
+// RUN: %clang_cc1 -x objective-c++ -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix OBJC %s
 //
 // OBJC:#define OBJC_NEW_PROPERTIES 1
 // OBJC:#define __NEXT_RUNTIME__ 1
 // RUN:   -fgnuc-version=4.2.1 -triple=aarch64-apple-macosx10.12 < /dev/null \
 // RUN: | FileCheck -check-prefix=DARWIN %s
 
+// DARWIN-NOT: OBJC_NEW_PROPERTIES
 // DARWIN:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -triple i386-apple-macosx -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix MACOS-32 %s