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

Eric Astor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 11:40:55 PDT 2020


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

Sync to HEAD


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86943

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
@@ -1094,6 +1094,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: D86943.289237.patch
Type: text/x-patch
Size: 1070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200901/68ac9b38/attachment.bin>


More information about the llvm-commits mailing list