[PATCH] D92612: [MC] Consume EndOfStatement in .cfi_{sections,endproc}
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 3 14:57:05 PST 2020
scott.linder created this revision.
Herald added a subscriber: hiraditya.
scott.linder requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Previously these directives were always interpreted as having an extra
blank line after them.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92612
Files:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/AsmParser/directive-parse-err.s
llvm/test/MC/AsmParser/round-trip.s
Index: llvm/test/MC/AsmParser/round-trip.s
===================================================================
--- /dev/null
+++ llvm/test/MC/AsmParser/round-trip.s
@@ -0,0 +1,17 @@
+# RUN: llvm-mc -preserve-comments -triple i386-unknown-unknown %s >%t-1.s
+# RUN: llvm-mc -preserve-comments -triple i386-unknown-unknown %t-1.s >%t-2.s
+# RUN: diff %t-1.s %t-2.s
+
+# Test that various assembly round-trips when run through MC; the first
+# transition from hand-written to "canonical" output may introduce some small
+# differences, so we don't include the initial input in the comparison.
+
+.text
+
+# Some of these CFI instructions didn't consume the end of statement
+# consistently, which led to extra empty lines in the output.
+.cfi_sections .debug_frame
+.cfi_startproc
+.cfi_endproc
+.cfi_startproc
+.cfi_endproc
Index: llvm/test/MC/AsmParser/directive-parse-err.s
===================================================================
--- /dev/null
+++ llvm/test/MC/AsmParser/directive-parse-err.s
@@ -0,0 +1,21 @@
+// RUN: not llvm-mc -triple i386-unknown-unknown %s 2>&1 | FileCheck %s
+// RUN: not llvm-mc -triple i386-unknown-unknown %s 2>&1 | grep "error:" | count 6
+
+// Test that we correctly diagnose parse errors.
+
+// CHECK: [[@LINE+1]]:15: error: Expected an identifier
+.cfi_sections $
+// CHECK: [[@LINE+1]]:28: error: unexpected token in '.cfi_sections' directive
+.cfi_sections .debug_frame $
+// CHECK: [[@LINE+1]]:39: error: unexpected token in '.cfi_sections' directive
+.cfi_sections .debug_frame, .eh_frame $
+
+// CHECK: [[@LINE+1]]:16: error: unexpected token in '.cfi_startproc' directive
+.cfi_startproc $
+// CHECK: [[@LINE+1]]:23: error: unexpected token in '.cfi_startproc' directive
+.cfi_startproc simple $
+
+// CHECK: [[@LINE+1]]:14: error: unexpected token in '.cfi_endproc' directive
+.cfi_endproc $
+
+// CHECK-NOT: error:
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -4077,6 +4077,9 @@
Debug = true;
}
+ if (parseToken(AsmToken::EndOfStatement))
+ return addErrorSuffix(" in '.cfi_sections' directive");
+
getStreamer().emitCFISections(EH, Debug);
return false;
}
@@ -4104,6 +4107,8 @@
/// parseDirectiveCFIEndProc
/// ::= .cfi_endproc
bool AsmParser::parseDirectiveCFIEndProc() {
+ if (parseToken(AsmToken::EndOfStatement))
+ return addErrorSuffix(" in '.cfi_endproc' directive");
getStreamer().emitCFIEndProc();
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92612.309377.patch
Type: text/x-patch
Size: 2557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201203/7bdd470e/attachment.bin>
More information about the llvm-commits
mailing list