summaryrefslogtreecommitdiffstats
path: root/clang/tools/driver/driver.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2016-04-20 00:33:06 +0000
committerStephen Hines <srhines@google.com>2016-04-20 00:33:06 +0000
commita978a076a90be7f659b68959d567653845cf165e (patch)
tree2dcbd6210fbb4fd4e5c2d03f53b16cd4bc58418a /clang/tools/driver/driver.cpp
parentc2dd7da5ca2452f53e8f2880b4a17c8b93a5a62c (diff)
downloadbcm5719-llvm-a978a076a90be7f659b68959d567653845cf165e.tar.gz
bcm5719-llvm-a978a076a90be7f659b68959d567653845cf165e.zip
MarkEOLs should only be true for clang-cl.exe.
Summary: https://llvm.org/bugs/show_bug.cgi?id=27396 This fixes an issue in response files where "\r\n" was being interpreted as two EOL markers (i.e. we consumed the '\r' as terminating the previous token, and then parsed the '\n' as a significant EOL). This breaks response files where joined arguments get split across multiple lines (like "-x\r\nc"). I also fixed an accidental issue in the response-file.c test, where the response file is appended to, instead of being overwritten. Reviewers: rnk Subscribers: danalbert, llvm-commits Differential Revision: http://reviews.llvm.org/D19289 llvm-svn: 266840
Diffstat (limited to 'clang/tools/driver/driver.cpp')
-rw-r--r--clang/tools/driver/driver.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index bd3c533904a..b7097e3faf1 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -338,18 +338,26 @@ int main(int argc_, const char **argv_) {
// have to manually search for a --driver-mode=cl argument the hard way.
// Finally, our -cc1 tools don't care which tokenization mode we use because
// response files written by clang will tokenize the same way in either mode.
- llvm::cl::TokenizerCallback Tokenizer = &llvm::cl::TokenizeGNUCommandLine;
+ bool ClangCLMode = false;
if (TargetAndMode.second == "--driver-mode=cl" ||
std::find_if(argv.begin(), argv.end(), [](const char *F) {
return F && strcmp(F, "--driver-mode=cl") == 0;
}) != argv.end()) {
- Tokenizer = &llvm::cl::TokenizeWindowsCommandLine;
+ ClangCLMode = true;
}
// Determines whether we want nullptr markers in argv to indicate response
- // files end-of-lines. We only use this for the /LINK driver argument.
- bool MarkEOLs = true;
- if (argv.size() > 1 && StringRef(argv[1]).startswith("-cc1"))
+ // files end-of-lines. We only use this for the /LINK driver argument with
+ // clang-cl.exe on Windows.
+ bool MarkEOLs = false;
+
+ llvm::cl::TokenizerCallback Tokenizer = &llvm::cl::TokenizeGNUCommandLine;
+ if (ClangCLMode) {
+ Tokenizer = &llvm::cl::TokenizeWindowsCommandLine;
+ MarkEOLs = true;
+ }
+
+ if (MarkEOLs && argv.size() > 1 && StringRef(argv[1]).startswith("-cc1"))
MarkEOLs = false;
llvm::cl::ExpandResponseFiles(Saver, Tokenizer, argv, MarkEOLs);
OpenPOWER on IntegriCloud