zixuw updated this revision to Diff 275821. zixuw added a comment. Add a test case.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83250/new/ https://reviews.llvm.org/D83250 Files: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/darwin-warning-options.c Index: clang/test/Driver/darwin-warning-options.c =================================================================== --- /dev/null +++ clang/test/Driver/darwin-warning-options.c @@ -0,0 +1,7 @@ +// 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" Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -954,6 +954,10 @@ : 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
Index: clang/test/Driver/darwin-warning-options.c =================================================================== --- /dev/null +++ clang/test/Driver/darwin-warning-options.c @@ -0,0 +1,7 @@ +// 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" Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -954,6 +954,10 @@ : 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits