diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 4c153bf3348b..a57c66403a28 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4437,6 +4437,11 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
   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;
 
diff --git a/clang/test/Driver/print-file-name.c b/clang/test/Driver/print-file-name.c
new file mode 100644
index 000000000000..9447c04a5ea9
--- /dev/null
+++ b/clang/test/Driver/print-file-name.c
@@ -0,0 +1,19 @@
+// Test that -print-file-name finds the correct file.
+
+// RUN: %clang -print-file-name=share/asan_blacklist.txt 2>&1 \
+// RUN:     -resource-dir=%S/Inputs/resource_dir \
+// RUN:     --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-RESOURCE-DIR %s
+// CHECK-RESOURCE-DIR: resource_dir{{/|\\\\}}share{{/|\\\\}}asan_blacklist.txt
+
+// RUN: %clang -print-file-name=libclang_rt.builtins.a 2>&1 \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:     --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-COMPILER-RT %s
+// CHECK-COMPILER-RT: resource_dir_with_per_target_subdir{{/|\\\\}}lib{{/|\\\\}}x86_64-linux-gnu{{/|\\\\}}libclang_rt.builtins.a
+
+// RUN: %clang -print-file-name=include/c++/v1 2>&1 \
+// RUN:     -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN:     --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR %s
+// CHECK-INSTALL-DIR: basic_linux_libcxx_tree{{/|\\\\}}usr{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1