summaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorJan Korous <jkorous@apple.com>2019-10-15 17:51:59 +0000
committerJan Korous <jkorous@apple.com>2019-10-15 17:51:59 +0000
commit92d65244d538fe82dc83492b2521e757bb84e96f (patch)
treed65c20c0c9e8a8bd92c319ddf142a5a44d24935c /lib/Driver/Driver.cpp
parent943e5a44883539848588e33bffbe2a1773dc4b43 (diff)
downloadclang-92d65244d538fe82dc83492b2521e757bb84e96f.tar.gz
Reland [Driver] Fix -working-directory issues
Don't change the default VFS in Driver, update tests & reland. This reverts commit 999f8a7416f8edc54ef92e715fd23c532bcc74d4. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 222efd5249..7a0defe0ba 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -1012,6 +1012,11 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
}
}
+ // Check for working directory option before accessing any files
+ if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
+ if (VFS->setCurrentWorkingDirectory(WD->getValue()))
+ Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
+
// FIXME: This stuff needs to go into the Compilation, not the driver.
bool CCCPrintPhases;
@@ -1993,20 +1998,11 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value,
if (Value == "-")
return true;
- SmallString<64> Path(Value);
- if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
- if (!llvm::sys::path::is_absolute(Path)) {
- SmallString<64> Directory(WorkDir->getValue());
- llvm::sys::path::append(Directory, Value);
- Path.assign(Directory);
- }
- }
-
- if (getVFS().exists(Path))
+ if (getVFS().exists(Value))
return true;
if (IsCLMode()) {
- if (!llvm::sys::path::is_absolute(Twine(Path)) &&
+ if (!llvm::sys::path::is_absolute(Twine(Value)) &&
llvm::sys::Process::FindInEnvPath("LIB", Value))
return true;
@@ -2032,12 +2028,12 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value,
if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
ExcludedFlagsBitmask) <= 1) {
Diag(clang::diag::err_drv_no_such_file_with_suggestion)
- << Path << Nearest;
+ << Value << Nearest;
return false;
}
}
- Diag(clang::diag::err_drv_no_such_file) << Path;
+ Diag(clang::diag::err_drv_no_such_file) << Value;
return false;
}