]> granicus.if.org Git - llvm/commitdiff
Fix file name resolution in nested response files
authorSerge Pavlov <sepavloff@gmail.com>
Sun, 20 Nov 2016 06:25:07 +0000 (06:25 +0000)
committerSerge Pavlov <sepavloff@gmail.com>
Sun, 20 Nov 2016 06:25:07 +0000 (06:25 +0000)
If a response file in construct `@file` was specified by relative name,
constructs `@file` nested within it were resolved incorrectly if the
flag RelativeNames in call to ExpandResponseFile was set to true.
This feature is used in configuration files, tests for it are in
respective change (see D24933).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287482 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/CommandLine.cpp

index dccb5d6962f697f80c9520689dceb0807dfe1210..c9751c093d65688165251d980904079c79bdeebf 100644 (file)
@@ -30,6 +30,7 @@
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -911,6 +912,11 @@ static bool ExpandResponseFile(StringRef FName, StringSaver &Saver,
           if (llvm::sys::path::is_relative(FileName)) {
             SmallString<128> ResponseFile;
             ResponseFile.append(1, '@');
+            if (llvm::sys::path::is_relative(FName)) {
+              SmallString<128> curr_dir;
+              llvm::sys::fs::current_path(curr_dir);
+              ResponseFile.append(curr_dir.str());
+            }
             llvm::sys::path::append(
                 ResponseFile, llvm::sys::path::parent_path(FName), FileName);
             NewArgv[I] = Saver.save(ResponseFile.c_str()).data();