diff options
author | Nico Weber <nicolasweber@gmx.de> | 2016-04-25 21:15:49 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2016-04-25 21:15:49 +0000 |
commit | 3d299b5bbdd7713c52dd495ec818100ceba1f80e (patch) | |
tree | d72288beb85cf1114a2da98aba0cfdad08738676 /tools/driver | |
parent | 15a13f4ca1516737c5e4d1d8d72ba56a6a77005e (diff) |
driver: Add a `--rsp-quoting` flag to pick response file quoting.
Currently, clang-cl always uses Windows style for unquoting, and clang always
uses POSIX style for unquoting.
With this flag, it's possible to change these defaults.
In general, response file quoting should match the shell the response file is
used in. On Windows, it's possible to run clang-cl in a bash shell, or clang in
cmd.exe, so a flag for overriding the default behavior is natural there.
On non-Windows, Windows quoting probably never makes sense (except maybe in
Wine), but having clang-cl behave differently based on the host OS seems
strange too. So require that people who want to use posix-style response
files with clang-cl on non-Windows pass --rsp-quoting=posix.
http://reviews.llvm.org/D19425
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267474 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver')
-rw-r--r-- | tools/driver/driver.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index b7097e3faf..b74de08199 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -345,17 +345,24 @@ int main(int argc_, const char **argv_) { }) != argv.end()) { ClangCLMode = true; } + enum { Default, POSIX, Windows } RSPQuoting = Default; + for (const char *F : argv) { + if (strcmp(F, "--rsp-quoting=posix") == 0) + RSPQuoting = POSIX; + else if (strcmp(F, "--rsp-quoting=windows") == 0) + RSPQuoting = Windows; + } // Determines whether we want nullptr markers in argv to indicate response // files end-of-lines. We only use this for the /LINK driver argument with // clang-cl.exe on Windows. - bool MarkEOLs = false; + bool MarkEOLs = ClangCLMode; - llvm::cl::TokenizerCallback Tokenizer = &llvm::cl::TokenizeGNUCommandLine; - if (ClangCLMode) { + llvm::cl::TokenizerCallback Tokenizer; + if (RSPQuoting == Windows || (RSPQuoting == Default && ClangCLMode)) Tokenizer = &llvm::cl::TokenizeWindowsCommandLine; - MarkEOLs = true; - } + else + Tokenizer = &llvm::cl::TokenizeGNUCommandLine; if (MarkEOLs && argv.size() > 1 && StringRef(argv[1]).startswith("-cc1")) MarkEOLs = false; |