[llvm] [MC,ELF] Use loc from the directive for `.abort` (PR #99648)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 19 06:16:43 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
Author: Dmitriy Chestnykh (chestnykh)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/99648.diff
2 Files Affected:
- (modified) llvm/lib/MC/MCParser/AsmParser.cpp (+6-8)
- (added) llvm/test/MC/ELF/abort.s (+9)
``````````diff
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index d05712bca73cd..e96c78b771588 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -658,7 +658,7 @@ class AsmParser : public MCAsmParser {
bool parseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
- bool parseDirectiveAbort(); // ".abort"
+ bool parseDirectiveAbort(SMLoc DirectiveLoc); // ".abort"
bool parseDirectiveInclude(); // ".include"
bool parseDirectiveIncbin(); // ".incbin"
@@ -2120,7 +2120,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
case DK_LCOMM:
return parseDirectiveComm(/*IsLocal=*/true);
case DK_ABORT:
- return parseDirectiveAbort();
+ return parseDirectiveAbort(IDLoc);
case DK_INCLUDE:
return parseDirectiveInclude();
case DK_INCBIN:
@@ -5095,18 +5095,16 @@ bool AsmParser::parseDirectiveComm(bool IsLocal) {
/// parseDirectiveAbort
/// ::= .abort [... message ...]
-bool AsmParser::parseDirectiveAbort() {
- // FIXME: Use loc from directive.
- SMLoc Loc = getLexer().getLoc();
-
+bool AsmParser::parseDirectiveAbort(SMLoc DirectiveLoc) {
StringRef Str = parseStringToEndOfStatement();
if (parseEOL())
return true;
if (Str.empty())
- return Error(Loc, ".abort detected. Assembly stopping.");
+ return Error(DirectiveLoc, ".abort detected. Assembly stopping.");
else
- return Error(Loc, ".abort '" + Str + "' detected. Assembly stopping.");
+ return Error(DirectiveLoc,
+ ".abort '" + Str + "' detected. Assembly stopping.");
// FIXME: Actually abort assembly here.
return false;
diff --git a/llvm/test/MC/ELF/abort.s b/llvm/test/MC/ELF/abort.s
new file mode 100644
index 0000000000000..808555973cd8d
--- /dev/null
+++ b/llvm/test/MC/ELF/abort.s
@@ -0,0 +1,9 @@
+// RUN: not llvm-mc -filetype=obj -triple x86_64 %s 2>&1 -o /dev/null | FileCheck %s
+
+.abort
+// CHECK: [[#@LINE-1]]:1: error: .abort detected. Assembly stopping.
+// CHECK-NEXT: abort
+
+.abort "abort message"
+// CHECK: [[#@LINE-1]]:1: error: .abort '"abort message"' detected. Assembly stopping.
+// CHECK-NEXT: abort
``````````
</details>
https://github.com/llvm/llvm-project/pull/99648
More information about the llvm-commits
mailing list