From d7dfd98f07f6af9416b342825217022f2e970a66 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 19 Dec 2012 23:41:50 +0000 Subject: [PATCH] [driver] Have -isysroot warn on nonexistent paths. rdar://12282267 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170611 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticDriverKinds.td | 2 ++ lib/Driver/ToolChains.cpp | 7 ++++++- test/Driver/warning-options.cpp | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index 4b43035175..a8b21173db 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -136,6 +136,8 @@ def warn_drv_objc_gc_unsupported : Warning< "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>; def note_drv_command_failed_diag_msg : Note< "diagnostic msg: %0">; diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 251467c75e..b84a96953a 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -397,7 +397,12 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { // 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. diff --git a/test/Driver/warning-options.cpp b/test/Driver/warning-options.cpp index cce88e65c2..c3a0214aa6 100644 --- a/test/Driver/warning-options.cpp +++ b/test/Driver/warning-options.cpp @@ -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' -- 2.40.0