Add clang option `-Wundef-prefix=TARGET_OS_` and `-Werror=undef-prefix`
to Darwin driver.
Differential Revision: https://reviews.llvm.org/D83250
: Darwin(D, Triple, Args) {}
void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
+ // Always error about undefined 'TARGET_OS_*' macros.
+ CC1Args.push_back("-Wundef-prefix=TARGET_OS_");
+ CC1Args.push_back("-Werror=undef-prefix");
+
// For modern targets, promote certain warnings to errors.
if (isTargetWatchOSBased() || getTriple().isArch64Bit()) {
// Always enable -Wdeprecated-objc-isa-usage and promote it
--- /dev/null
+// REQUIRES: system-darwin
+
+// Always error about undefined 'TARGET_OS_*' macros on Darwin.
+// RUN: %clang -### %s 2>&1 | FileCheck %s
+
+// CHECK-DAG: "-Wundef-prefix=TARGET_OS_"
+// CHECK-DAG: "-Werror=undef-prefix"