[llvm] c8d6e67 - [ms] [llvm-ml] Fix parity errors in error handling for INCLUDE directive

Eric Astor via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 9 10:34:52 PDT 2021


Author: Eric Astor
Date: 2021-06-09T13:34:36-04:00
New Revision: c8d6e67d53a0d2a462696acc831e990183cd9d0f

URL: https://github.com/llvm/llvm-project/commit/c8d6e67d53a0d2a462696acc831e990183cd9d0f
DIFF: https://github.com/llvm/llvm-project/commit/c8d6e67d53a0d2a462696acc831e990183cd9d0f.diff

LOG: [ms] [llvm-ml] Fix parity errors in error handling for INCLUDE directive

Also adds basic testing for "include" directive.

Differential Revision: https://reviews.llvm.org/D103980

Added: 
    llvm/test/tools/llvm-ml/include.asm
    llvm/test/tools/llvm-ml/included.inc

Modified: 
    llvm/lib/MC/MCParser/MasmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 6364cac445ca..2c0e3a2acaf1 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -5889,9 +5889,9 @@ bool MasmParser::parseDirectiveInclude() {
   std::string Filename;
   SMLoc IncludeLoc = getTok().getLoc();
 
-  if (!parseAngleBracketString(Filename))
+  if (parseAngleBracketString(Filename))
     Filename = parseStringTo(AsmToken::EndOfStatement);
-  if (check(!Filename.empty(), "missing filename in 'include' directive") ||
+  if (check(Filename.empty(), "missing filename in 'include' directive") ||
       check(getTok().isNot(AsmToken::EndOfStatement),
             "unexpected token in 'include' directive") ||
       // Attempt to switch the lexer to the included file before consuming the

diff  --git a/llvm/test/tools/llvm-ml/include.asm b/llvm/test/tools/llvm-ml/include.asm
new file mode 100644
index 000000000000..a0057c6c7fd8
--- /dev/null
+++ b/llvm/test/tools/llvm-ml/include.asm
@@ -0,0 +1,20 @@
+# RUN: llvm-ml -filetype=s %s /I %S /Fo - | FileCheck %s
+
+include included.inc
+
+.code
+
+t1:
+mov eax, Const
+
+; CHECK-LABEL: t1:
+; CHECK-NEXT: mov eax, 8
+
+t2:
+push_pop ebx
+
+; CHECK-LABEL: t2:
+; CHECK-NEXT: push ebx
+; CHECK-NEXT: pop ebx
+
+end

diff  --git a/llvm/test/tools/llvm-ml/included.inc b/llvm/test/tools/llvm-ml/included.inc
new file mode 100644
index 000000000000..3b43eaa186e4
--- /dev/null
+++ b/llvm/test/tools/llvm-ml/included.inc
@@ -0,0 +1,6 @@
+Const equ 00008H
+
+push_pop macro Reg
+  push Reg
+  pop Reg
+endm


        


More information about the llvm-commits mailing list