Use CLANG_RESOURCE_DIR define if one is provided, otherwise use the default of
'../lib/clang/<version>'. Actually use '..' rather than removing the trailing
component to correctly handle paths containing '.' or symlinks in the presence
of -no-canonical-prefixes, etc. This shouldn't change any existing behavior.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116803 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index b32dac0..1355206 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -81,11 +81,16 @@
Dir = Executable.getDirname();
// Compute the path to the resource directory.
+ llvm::StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
llvm::sys::Path P(Dir);
- P.eraseComponent(); // Remove /bin from foo/bin
- P.appendComponent("lib");
- P.appendComponent("clang");
- P.appendComponent(CLANG_VERSION_STRING);
+ if (ClangResourceDir != "") {
+ P.appendComponent(ClangResourceDir);
+ } else {
+ P.appendComponent(".."); // Walk up from a 'bin' subdirectory.
+ P.appendComponent("lib");
+ P.appendComponent("clang");
+ P.appendComponent(CLANG_VERSION_STRING);
+ }
ResourceDir = P.str();
}