aboutsummaryrefslogtreecommitdiff
path: root/tools/driver
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-21 16:45:57 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-21 16:45:57 +0000
commitfbfd180495e7800975c6d9bdc6d24e706ef70e34 (patch)
tree8b9c57bb01c6f17bd37ff34ef8f93e3ddc5e32d2 /tools/driver
parent06a8dc616ec8324694d45cd4d724634a899be9a3 (diff)
Replace all uses of PathV1::makeAbsolute with PathV2::fs::make_absolute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122340 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver')
-rw-r--r--tools/driver/driver.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index c88a7a3054..594b07bd2c 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -23,6 +23,7 @@
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Config/config.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
@@ -309,19 +310,22 @@ int main(int argc_, const char **argv_) {
// Attempt to find the original path used to invoke the driver, to determine
// the installed path. We do this manually, because we want to support that
// path being a symlink.
- llvm::sys::Path InstalledPath(argv[0]);
-
- // Do a PATH lookup, if there are no directory components.
- if (llvm::sys::path::filename(InstalledPath.str()) == InstalledPath.str()) {
- llvm::sys::Path Tmp = llvm::sys::Program::FindProgramByName(
- llvm::sys::path::filename(InstalledPath.str()));
- if (!Tmp.empty())
- InstalledPath = Tmp;
+ {
+ llvm::SmallString<128> InstalledPath(argv[0]);
+
+ // Do a PATH lookup, if there are no directory components.
+ if (llvm::sys::path::filename(InstalledPath) == InstalledPath) {
+ llvm::sys::Path Tmp = llvm::sys::Program::FindProgramByName(
+ llvm::sys::path::filename(InstalledPath.str()));
+ if (!Tmp.empty())
+ InstalledPath = Tmp.str();
+ }
+ llvm::sys::fs::make_absolute(InstalledPath);
+ InstalledPath = llvm::sys::path::parent_path(InstalledPath);
+ bool exists;
+ if (!llvm::sys::fs::exists(InstalledPath.str(), exists) && exists)
+ TheDriver.setInstalledDir(InstalledPath);
}
- InstalledPath.makeAbsolute();
- InstalledPath.eraseComponent();
- if (InstalledPath.exists())
- TheDriver.setInstalledDir(InstalledPath.str());
// Check for ".*++" or ".*++-[^-]*" to determine if we are a C++
// compiler. This matches things like "c++", "clang++", and "clang++-1.1".