]> granicus.if.org Git - clang/commitdiff
Use CLANG_RESOURCE_DIR define if one is provided, otherwise use the default of
authorChandler Carruth <chandlerc@gmail.com>
Tue, 19 Oct 2010 08:47:51 +0000 (08:47 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 19 Oct 2010 08:47:51 +0000 (08:47 +0000)
'../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

lib/Driver/Driver.cpp

index b32dac0b880f61b5eb279750d4af1725b73fe19b..135520606592b651f63ebe05d30dbf9317850ca4 100644 (file)
@@ -81,11 +81,16 @@ Driver::Driver(llvm::StringRef _ClangExecutable,
   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();
 }