[PATCH] D52014: [LLD] [COFF] Allow embedded directives to be separated by null bytes

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 13 23:10:52 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342204: [Support] Treat null bytes as separator in windows command line strings (authored by mstorsjo, committed by ).
Herald added a subscriber: kristina.

Changed prior to commit:
  https://reviews.llvm.org/D52014?vs=165206&id=165429#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52014

Files:
  llvm/trunk/lib/Support/CommandLine.cpp


Index: llvm/trunk/lib/Support/CommandLine.cpp
===================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp
+++ llvm/trunk/lib/Support/CommandLine.cpp
@@ -693,6 +693,10 @@
   return C == ' ' || C == '\t' || C == '\r' || C == '\n';
 }
 
+static bool isWhitespaceOrNull(char C) {
+  return isWhitespace(C) || C == '\0';
+}
+
 static bool isQuote(char C) { return C == '\"' || C == '\''; }
 
 void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
@@ -808,7 +812,7 @@
     // INIT state indicates that the current input index is at the start of
     // the string or between tokens.
     if (State == INIT) {
-      if (isWhitespace(C)) {
+      if (isWhitespaceOrNull(C)) {
         // Mark the end of lines in response files
         if (MarkEOLs && C == '\n')
           NewArgv.push_back(nullptr);
@@ -832,7 +836,7 @@
     // quotes.
     if (State == UNQUOTED) {
       // Whitespace means the end of the token.
-      if (isWhitespace(C)) {
+      if (isWhitespaceOrNull(C)) {
         NewArgv.push_back(Saver.save(StringRef(Token)).data());
         Token.clear();
         State = INIT;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52014.165429.patch
Type: text/x-patch
Size: 1153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180914/27c53a0b/attachment.bin>


More information about the llvm-commits mailing list