Skip to content

Commit 989a299

Browse files
authored
Merge pull request swiftlang#15853 from dabelknap/response_file
Enable Response Files for the Swift Driver and Frontend
2 parents 2861db6 + 0e5f88c commit 989a299

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

test/Driver/response-file.swift

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: echo "-DTEST0" > %t.0.resp
2+
// RUN: %target-build-swift -typecheck @%t.0.resp %s 2>&1 | %FileCheck %s -check-prefix=SHORT
3+
// SHORT: warning: result of call to 'abs' is unused
4+
5+
// RUN: python -c 'for a in ["A", "B", "C", "D"]: print "-DTEST1" + a' > %t.1.resp
6+
// RUN: %target-build-swift -typecheck @%t.1.resp %s 2>&1 | %FileCheck %s -check-prefix=MULTIPLE
7+
// MULTIPLE: warning: result of call to 'abs' is unused
8+
9+
// RUN: echo "-DTEST2A -DTEST2B" > %t.2.resp
10+
// RUN: echo "-DTEST2C -DTEST2D" > %t.3.resp
11+
// RUN: %target-build-swift -typecheck @%t.2.resp %s @%t.3.resp 2>&1 | %FileCheck %s -check-prefix=MIXED
12+
// MIXED: warning: result of call to 'abs' is unused
13+
14+
// RUN: echo "-DTEST3A" > %t.4.resp
15+
// RUN: echo "%s" >> %t.4.resp
16+
// RUN: echo "-DTEST3B" >> %t.4.resp
17+
// RUN: %target-build-swift -typecheck @%t.4.resp 2>&1 | %FileCheck %s -check-prefix=RESPONLY
18+
// RESPONLY: warning: result of call to 'abs' is unused
19+
20+
// RUN: echo "-DTEST4A" > %t.5.resp
21+
// RUN: echo "%s" >> %t.5.resp
22+
// RUN: echo "@%t.5.resp" > %t.6.resp
23+
// RUN: echo "-DTEST4B" >> %t.6.resp
24+
// RUN: %target-build-swift -typecheck @%t.6.resp 2>&1 | %FileCheck %s -check-prefix=RECURSIVE
25+
// RECURSIVE: warning: result of call to 'abs' is unused
26+
27+
#if TEST0
28+
abs(-5)
29+
#endif
30+
31+
#if TEST1A && TEST1B && TEST1C && TEST1D
32+
abs(-5)
33+
#endif
34+
35+
#if TEST2A && TEST2B && TEST2C && TEST2D
36+
abs(-5)
37+
#endif
38+
39+
#if TEST3A && TEST3B
40+
abs(-5)
41+
#endif
42+
43+
#if TEST4A && TEST4B
44+
abs(-5)
45+
#endif

tools/driver/driver.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "llvm/Support/Process.h"
3838
#include "llvm/Support/Program.h"
3939
#include "llvm/Support/Signals.h"
40+
#include "llvm/Support/StringSaver.h"
4041
#include "llvm/Support/TargetSelect.h"
4142
#include "llvm/Support/raw_ostream.h"
4243

@@ -121,6 +122,18 @@ int main(int argc_, const char **argv_) {
121122
return 1;
122123
}
123124

125+
// Expand any response files in the command line argument vector - arguments
126+
// may be passed through response files in the event of command line length
127+
// restrictions.
128+
llvm::BumpPtrAllocator Allocator;
129+
llvm::StringSaver Saver(Allocator);
130+
llvm::cl::ExpandResponseFiles(
131+
Saver,
132+
llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows() ?
133+
llvm::cl::TokenizeWindowsCommandLine :
134+
llvm::cl::TokenizeGNUCommandLine,
135+
argv);
136+
124137
// Check if this invocation should execute a subcommand.
125138
StringRef ExecName = llvm::sys::path::stem(argv[0]);
126139
SmallString<256> SubcommandName;

0 commit comments

Comments
 (0)