[Driver] Search the toolchain dir with -print-file-name
This is useful when looking for directories or files relative to the
toolchain root, e.g. include/c++/v1. This change also adds a test
to make sure this functionality doesn't regress in the future.
Differential Revision: https://reviews.llvm.org/D62558
llvm-svn: 361903
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 4c153bf..a57c664 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4437,6 +4437,11 @@
if (llvm::sys::fs::exists(Twine(P)))
return P.str();
+ SmallString<128> D(Dir);
+ llvm::sys::path::append(D, "..", Name);
+ if (llvm::sys::fs::exists(Twine(D)))
+ return D.str();
+
if (auto P = SearchPaths(TC.getLibraryPaths()))
return *P;