]> granicus.if.org Git - clang/commitdiff
clang-cl: Don't look up absolute paths in %LIB%.
authorNico Weber <nicolasweber@gmx.de>
Fri, 24 Apr 2015 22:16:53 +0000 (22:16 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 24 Apr 2015 22:16:53 +0000 (22:16 +0000)
Before this patch, passing a non-existent absolute path to clang-cl would cause
stat'ing of impossible paths. For example, `clang-cl -c d:\adsfasdf.txt` would
cause a stat of
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIBd:\asdfadsf.cc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235787 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp
test/Driver/cl-inputs.c

index 07a5e42cb1397ec91fe46df3f7bc2ff830e78426..7e52b1fbca9703bf2d6165294906e82dea159595 100644 (file)
@@ -989,7 +989,8 @@ static bool DiagnoseInputExistence(const Driver &D, const DerivedArgList &Args,
   if (llvm::sys::fs::exists(Twine(Path)))
     return true;
 
-  if (D.IsCLMode() && llvm::sys::Process::FindInEnvPath("LIB", Value))
+  if (D.IsCLMode() && !llvm::sys::path::is_absolute(Twine(Path)) &&
+      llvm::sys::Process::FindInEnvPath("LIB", Value))
     return true;
 
   D.Diag(clang::diag::err_drv_no_such_file) << Path;
index b0265df52f05214ad08a22689666eed1efc567d5..632000990f07799e2dd70104532eb2d91f11349a 100644 (file)
@@ -59,4 +59,9 @@
 // LIBINPUT2: link.exe"
 // LIBINPUT2-NOT: "cl-test2.lib"
 
+// RUN: %clang_cl -### -- %s /nonexisting.lib 2>&1 | FileCheck -check-prefix=LIBINPUT3 %s
+// LIBINPUT3: error: no such file or directory: '/nonexisting.lib'
+// LIBINPUT3: link.exe"
+// LIBINPUT3-NOT: "/nonexisting.lib"
+
 void f();