From: Aaron Ballman Date: Mon, 20 Feb 2012 14:13:25 +0000 (+0000) Subject: Fixing the working-directory option so that it stores the proper directory. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1367c9b0ff3f657d2f2d471365a69e8f6d2ccbd0;p=clang Fixing the working-directory option so that it stores the proper directory. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150960 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index e105e99246..da1a40d1e6 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -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));