From c8d6e67d53a0d2a462696acc831e990183cd9d0f Mon Sep 17 00:00:00 2001 From: Eric Astor Date: Wed, 9 Jun 2021 13:34:18 -0400 Subject: [PATCH] [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 --- llvm/lib/MC/MCParser/MasmParser.cpp | 4 ++-- llvm/test/tools/llvm-ml/include.asm | 20 ++++++++++++++++++++ llvm/test/tools/llvm-ml/included.inc | 6 ++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 llvm/test/tools/llvm-ml/include.asm create mode 100644 llvm/test/tools/llvm-ml/included.inc diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp index 6364cac..2c0e3a2 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 0000000..a0057c6 --- /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 0000000..3b43eaa --- /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 -- 2.7.4