diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 3167e03ca449..689ecbcd7949 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -59,6 +59,15 @@ Driver::Driver(StringRef ClangExecutable, Name = llvm::sys::path::stem(ClangExecutable); Dir = llvm::sys::path::parent_path(ClangExecutable); + + // Compute the path to the resource directory. + StringRef ClangResourceDir(CLANG_RESOURCE_DIR); + SmallString<128> P(Dir); + if (ClangResourceDir != "") + llvm::sys::path::append(P, ClangResourceDir); + else + llvm::sys::path::append(P, "..", "lib", "clang", CLANG_VERSION_STRING); + ResourceDir = P.str(); } Driver::~Driver() { @@ -282,18 +291,8 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { if (Args->hasArg(options::OPT_nostdlib)) UseStdLib = false; - // Compute the path to the resource directory. We used to do this in - // Driver::Driver(), but that's not right, as command line args (such as - // ccc-install-dir) can change 'Dir'. - StringRef ClangResourceDir(CLANG_RESOURCE_DIR); - SmallString<128> P(Dir); if (const Arg *A = Args->getLastArg(options::OPT_resource_dir)) - P = A->getValue(); - else if (!ClangResourceDir.empty()) - llvm::sys::path::append(P, ClangResourceDir); - else - llvm::sys::path::append(P, "..", "lib", "clang", CLANG_VERSION_STRING); - ResourceDir = P.str(); + ResourceDir = A->getValue(); // Perform the default argument translations. DerivedArgList *TranslatedArgs = TranslateInputArgs(*Args); diff --git a/clang/test/Driver/resource-dir.cpp b/clang/test/Driver/resource-dir.cpp deleted file mode 100644 index 106e88399551..000000000000 --- a/clang/test/Driver/resource-dir.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang %s -fsyntax-only -### 2> %t.log -// RUN: FileCheck %s --check-prefix=CHECK-DEFAULT < %t.log - -// CHECK-DEFAULT: "-resource-dir" "{{.+}}/../lib/clang/{{.+}}" - -// RUN: %clang %s -fsyntax-only -ccc-install-dir /my/install/dir -### 2> %t.log -// RUN: FileCheck %s --check-prefix=CHECK-INSTALL-DIR < %t.log -// CHECK-INSTALL-DIR: "-resource-dir" "/my/install/dir{{[\\/]+}}..{{[\\/]+}}lib{{[\\/]+}}clang{{[\\/]+.+}}" - -void foo(void) {}