aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-07-19 00:44:04 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-07-19 00:44:04 +0000
commit0bbad519aa068206f1e158d5073f72a39fbe83c5 (patch)
treece7571947d165a433786d1b2cdfb16399cd14145 /lib/Driver/Driver.cpp
parente9122a36c4c951c4cdce842dc8caf20874908cfd (diff)
Driver: Change the driver to take the path to the main executable, instead of
taking it in pieces. - Fixes a problem where the Clang executable path was not initialized properly on Win32, because sys::Path::getBasename() doesn't do what I always think it does. Imagine that, a sys::Path interface that is confusing! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108667 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 2fc0a5354d..182320a4c5 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -39,13 +39,13 @@
using namespace clang::driver;
using namespace clang;
-Driver::Driver(llvm::StringRef _Name, llvm::StringRef _Dir,
+Driver::Driver(llvm::StringRef _ClangExecutable,
llvm::StringRef _DefaultHostTriple,
llvm::StringRef _DefaultImageName,
bool IsProduction, bool CXXIsProduction,
Diagnostic &_Diags)
: Opts(createDriverOptTable()), Diags(_Diags),
- Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple),
+ ClangExecutable(_ClangExecutable), DefaultHostTriple(_DefaultHostTriple),
DefaultImageName(_DefaultImageName),
DriverTitle("clang \"gcc-compatible\" driver"),
Host(0),
@@ -68,6 +68,10 @@ Driver::Driver(llvm::StringRef _Name, llvm::StringRef _Dir,
CCCUseClangCXX = false;
}
+ llvm::sys::Path Executable(ClangExecutable);
+ Name = Executable.getBasename();
+ Dir = Executable.getDirname();
+
// Compute the path to the resource directory.
llvm::sys::Path P(Dir);
P.eraseComponent(); // Remove /bin from foo/bin
@@ -75,11 +79,6 @@ Driver::Driver(llvm::StringRef _Name, llvm::StringRef _Dir,
P.appendComponent("clang");
P.appendComponent(CLANG_VERSION_STRING);
ResourceDir = P.str();
-
- // Save the original clang executable path.
- P = Dir;
- P.appendComponent(Name);
- ClangExecutable = P.str();
}
Driver::~Driver() {