Fixing the working-directory option so that it stores the proper directory.

llvm-svn: 150960
This commit is contained in:
Aaron Ballman 2012-02-20 14:13:25 +00:00
parent e550fa2f95
commit 232c4f50ba
1 changed files with 7 additions and 5 deletions

View File

@ -960,14 +960,16 @@ void Driver::BuildInputs(const ToolChain &TC, const DerivedArgList &Args,
// Check that the file exists, if enabled.
if (CheckInputsExist && memcmp(Value, "-", 2) != 0) {
SmallString<64> Path(Value);
if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory))
if (llvm::sys::path::is_absolute(Path.str())) {
Path = WorkDir->getValue(Args);
llvm::sys::path::append(Path, Value);
if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
SmallString<64> Directory(WorkDir->getValue(Args));
if (llvm::sys::path::is_absolute(Directory.str())) {
llvm::sys::path::append(Directory, Value);
Path.assign(Directory);
}
}
bool exists = false;
if (/*error_code ec =*/llvm::sys::fs::exists(Value, exists) || !exists)
if (llvm::sys::fs::exists(Path.c_str(), exists) || !exists)
Diag(clang::diag::err_drv_no_such_file) << Path.str();
else
Inputs.push_back(std::make_pair(Ty, A));