Skip to content

Commit f47b885

Browse files
committed
[clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver
Add clang option `-Wundef-prefix=TARGET_OS_` and `-Werror=undef-prefix` to Darwin driver. Differential Revision: https://reviews.llvm.org/D83250
1 parent 7c63804 commit f47b885

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎clang/lib/Driver/ToolChains/Darwin.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,10 @@ DarwinClang::DarwinClang(const Driver &D, const llvm::Triple &Triple,
954954
: Darwin(D, Triple, Args) {}
955955

956956
void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
957+
// Always error about undefined 'TARGET_OS_*' macros.
958+
CC1Args.push_back("-Wundef-prefix=TARGET_OS_");
959+
CC1Args.push_back("-Werror=undef-prefix");
960+
957961
// For modern targets, promote certain warnings to errors.
958962
if (isTargetWatchOSBased() || getTriple().isArch64Bit()) {
959963
// Always enable -Wdeprecated-objc-isa-usage and promote it
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// REQUIRES: system-darwin
2+
3+
// Always error about undefined 'TARGET_OS_*' macros on Darwin.
4+
// RUN: %clang -### %s 2>&1 | FileCheck %s
5+
6+
// CHECK-DAG: "-Wundef-prefix=TARGET_OS_"
7+
// CHECK-DAG: "-Werror=undef-prefix"

0 commit comments

Comments
 (0)