[cfe-commits] r170611 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.td lib/Driver/ToolChains.cpp test/Driver/warning-options.cpp

Chad Rosier mcrosier at apple.com
Wed Dec 19 15:41:51 PST 2012


Author: mcrosier
Date: Wed Dec 19 17:41:50 2012
New Revision: 170611

URL: http://llvm.org/viewvc/llvm-project?rev=170611&view=rev
Log:
[driver] Have -isysroot warn on nonexistent paths.
rdar://12282267

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/test/Driver/warning-options.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=170611&r1=170610&r2=170611&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Dec 19 17:41:50 2012
@@ -136,6 +136,8 @@
   "Objective-C garbage collection is not supported on this platform, ignoring '%0'">;
 def warn_drv_pch_not_first_include : Warning<
   "precompiled header '%0' was ignored because '%1' is not first '-include'">;
+def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,
+  InGroup<DiagGroup<"missing-sysroot">>;
 
 def note_drv_command_failed_diag_msg : Note<
   "diagnostic msg: %0">;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=170611&r1=170610&r2=170611&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Dec 19 17:41:50 2012
@@ -397,7 +397,12 @@
   // Support allowing the SDKROOT environment variable used by xcrun and other
   // Xcode tools to define the default sysroot, by making it the default for
   // isysroot.
-  if (!Args.hasArg(options::OPT_isysroot)) {
+  if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+    // Warn if the path does not exist.
+    bool Exists;
+    if (llvm::sys::fs::exists(A->getValue(), Exists) || !Exists)
+      getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
+  } else {
     if (char *env = ::getenv("SDKROOT")) {
       // We only use this value as the default if it is an absolute path and
       // exists.

Modified: cfe/trunk/test/Driver/warning-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/warning-options.cpp?rev=170611&r1=170610&r2=170611&view=diff
==============================================================================
--- cfe/trunk/test/Driver/warning-options.cpp (original)
+++ cfe/trunk/test/Driver/warning-options.cpp Wed Dec 19 17:41:50 2012
@@ -13,3 +13,7 @@
 // RUN: %clang -### -Warc-abi -Wno-arc-abi %s 2>&1 | FileCheck -check-prefix=ARCABI %s
 // ARCABI-NOT: unknown warning option '-Warc-abi'
 // ARCABI-NOT: unknown warning option '-Wno-arc-abi'
+
+// Check that -isysroot warns on non-existant paths.
+// RUN: %clang -### -c -target i386-apple-darwin10 -isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-ISYSROOT %s
+// CHECK-ISYSROOT: warning: no such sysroot directory: '/FOO'





More information about the cfe-commits mailing list