[driver] Before applying the working directory check if the input path
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 26 Oct 2012 20:09:24 +0000 (20:09 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 26 Oct 2012 20:09:24 +0000 (20:09 +0000)
is absolute.

llvm-svn: 166808

clang/lib/Driver/Driver.cpp
clang/test/Driver/working-directory-and-abs.c [new file with mode: 0644]

index 31492a7..43e9e5d 100644 (file)
@@ -1018,8 +1018,8 @@ void Driver::BuildInputs(const ToolChain &TC, const DerivedArgList &Args,
       if (CheckInputsExist && memcmp(Value, "-", 2) != 0) {
         SmallString<64> 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())) {
+          if (!llvm::sys::path::is_absolute(Path.str())) {
+            SmallString<64> Directory(WorkDir->getValue(Args));
             llvm::sys::path::append(Directory, Value);
             Path.assign(Directory);
           }
diff --git a/clang/test/Driver/working-directory-and-abs.c b/clang/test/Driver/working-directory-and-abs.c
new file mode 100644 (file)
index 0000000..6738c77
--- /dev/null
@@ -0,0 +1 @@
+// RUN: %clang -working-directory=%S %S/working-directory-and-abs.c -fsyntax-only