aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Chestnykh <dm.chestnykh@gmail.com>2024-07-20 22:33:39 +0300
committerGitHub <noreply@github.com>2024-07-20 22:33:39 +0300
commitcc2fb58639a6b87f155e6052f5ef2bbe05d5c378 (patch)
tree42451a42aa5fbe1a51a5303d3ba6da1dccd8b8d5
parentce1a87437cc143889665c41046107e84cdf6246e (diff)
downloadllvm-cc2fb58639a6b87f155e6052f5ef2bbe05d5c378.zip
llvm-cc2fb58639a6b87f155e6052f5ef2bbe05d5c378.tar.gz
llvm-cc2fb58639a6b87f155e6052f5ef2bbe05d5c378.tar.bz2
[MC,ELF] Use loc from the directive for `.abort` (#99648)
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp18
-rw-r--r--llvm/test/MC/AsmParser/directive_abort.s13
2 files changed, 15 insertions, 16 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index d05712b..992b69f 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -658,7 +658,7 @@ private:
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,21 +5095,17 @@ 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.");
- else
- return Error(Loc, ".abort '" + Str + "' detected. Assembly stopping.");
- // FIXME: Actually abort assembly here.
+ return Error(DirectiveLoc, ".abort detected. Assembly stopping");
- return false;
+ // FIXME: Actually abort assembly here.
+ return Error(DirectiveLoc,
+ ".abort '" + Str + "' detected. Assembly stopping");
}
/// parseDirectiveInclude
diff --git a/llvm/test/MC/AsmParser/directive_abort.s b/llvm/test/MC/AsmParser/directive_abort.s
index 86e6267..f4dda22 100644
--- a/llvm/test/MC/AsmParser/directive_abort.s
+++ b/llvm/test/MC/AsmParser/directive_abort.s
@@ -1,6 +1,9 @@
-# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t
-# RUN: FileCheck -input-file %t %s
+// RUN: not llvm-mc -filetype=obj -triple x86_64 %s 2>&1 -o /dev/null | FileCheck %s
-# CHECK: error: .abort 'please stop assembing'
-TEST0:
- .abort please stop assembing
+.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