[PATCH] D83347: [ms] [llvm-ml] Add support for line continuations in MASM

Eric Astor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 07:00:23 PDT 2020


epastor updated this revision to Diff 277419.
epastor added a comment.

Add test. (Sorry, Nico, and thanks!)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83347/new/

https://reviews.llvm.org/D83347

Files:
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/test/tools/llvm-ml/line_continuations.test


Index: llvm/test/tools/llvm-ml/line_continuations.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ml/line_continuations.test
@@ -0,0 +1,17 @@
+# RUN: llvm-ml -filetype=asm %s | FileCheck %s
+
+.code
+
+t1:
+mov eax, \
+    ebx
+# CHECK: t1:
+# CHECK-NEXT: mov eax, ebx
+
+t2:
+mov eax, [ebx + \
+          1]
+# CHECK: t2:
+# CHECK-NEXT: mov eax, dword ptr [ebx + 1]
+
+END
Index: llvm/lib/MC/MCParser/MasmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -1099,6 +1099,14 @@
     tok = &Lexer.Lex();
   }
 
+  // Recognize and bypass line continuations.
+  while (tok->is(AsmToken::BackSlash) &&
+         Lexer.peekTok().is(AsmToken::EndOfStatement)) {
+    // Eat both the backslash and the end of statement.
+    Lexer.Lex();
+    tok = &Lexer.Lex();
+  }
+
   if (tok->is(AsmToken::Eof)) {
     // If this is the end of an included file, pop the parent file off the
     // include stack.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83347.277419.patch
Type: text/x-patch
Size: 1070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200713/eab34e76/attachment.bin>


More information about the llvm-commits mailing list