Make --reproduce to not produce undesired whitespace.

Fixes bug 27648.

llvm-svn: 268569
This commit is contained in:
Rui Ueyama 2016-05-04 23:12:55 +00:00
parent fc1214fee2
commit af2312feb7
2 changed files with 15 additions and 5 deletions

View File

@ -17,6 +17,7 @@
#include "Error.h"
#include "lld/Config/Version.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@ -173,6 +174,16 @@ static std::string rewritePath(StringRef S) {
return S;
}
static std::string stringize(opt::Arg *Arg) {
std::string K = Arg->getSpelling();
if (Arg->getNumValues() == 0)
return K;
std::string V = quote(Arg->getValue());
if (Arg->getOption().getRenderStyle() == opt::Option::RenderJoinedStyle)
return K + V;
return K + " " + V;
}
// Copies all input files to Config->Reproduce directory and
// create a response file as "response.txt", so that you can re-run
// the same command with the same inputs just by executing
@ -198,10 +209,7 @@ void elf::createResponseFile(const opt::InputArgList &Args) {
<< quote(rewritePath(Arg->getValue())) << "\n";
break;
default:
OS << Arg->getSpelling();
if (Arg->getNumValues() > 0)
OS << " " << quote(Arg->getValue());
OS << "\n";
OS << stringize(Arg) << "\n";
}
}

View File

@ -32,7 +32,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o 'foo bar'
# RUN: ld.lld --reproduce repro2 'foo bar' -L"foo bar" -Lfile \
# RUN: --dynamic-list dyn -rpath file --script file --version-script ver \
# RUN: --dynamic-linker "some unusual/path"
# RUN: --dynamic-linker "some unusual/path" -soname 'foo bar' -soname='foo bar'
# RUN: cpio -id < repro2.cpio
# RUN: FileCheck %s --check-prefix=RSP2 < repro2/response.txt
# RSP2: "{{.*}}foo bar"
@ -43,6 +43,8 @@
# RSP2-NEXT: --script {{.+}}file
# RSP2-NEXT: --version-script {{.+}}ver
# RSP2-NEXT: --dynamic-linker "some unusual/path"
# RSP2-NEXT: -soname="foo bar"
# RSP2-NEXT: -soname="foo bar"
.globl _start
_start: