Skip to content

Commit cc2fb58

Browse files
authored
[MC,ELF] Use loc from the directive for .abort (#99648)
1 parent ce1a874 commit cc2fb58

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class AsmParser : public MCAsmParser {
658658

659659
bool parseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
660660

661-
bool parseDirectiveAbort(); // ".abort"
661+
bool parseDirectiveAbort(SMLoc DirectiveLoc); // ".abort"
662662
bool parseDirectiveInclude(); // ".include"
663663
bool parseDirectiveIncbin(); // ".incbin"
664664

@@ -2120,7 +2120,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
21202120
case DK_LCOMM:
21212121
return parseDirectiveComm(/*IsLocal=*/true);
21222122
case DK_ABORT:
2123-
return parseDirectiveAbort();
2123+
return parseDirectiveAbort(IDLoc);
21242124
case DK_INCLUDE:
21252125
return parseDirectiveInclude();
21262126
case DK_INCBIN:
@@ -5095,21 +5095,17 @@ bool AsmParser::parseDirectiveComm(bool IsLocal) {
50955095

50965096
/// parseDirectiveAbort
50975097
/// ::= .abort [... message ...]
5098-
bool AsmParser::parseDirectiveAbort() {
5099-
// FIXME: Use loc from directive.
5100-
SMLoc Loc = getLexer().getLoc();
5101-
5098+
bool AsmParser::parseDirectiveAbort(SMLoc DirectiveLoc) {
51025099
StringRef Str = parseStringToEndOfStatement();
51035100
if (parseEOL())
51045101
return true;
51055102

51065103
if (Str.empty())
5107-
return Error(Loc, ".abort detected. Assembly stopping.");
5108-
else
5109-
return Error(Loc, ".abort '" + Str + "' detected. Assembly stopping.");
5110-
// FIXME: Actually abort assembly here.
5104+
return Error(DirectiveLoc, ".abort detected. Assembly stopping");
51115105

5112-
return false;
5106+
// FIXME: Actually abort assembly here.
5107+
return Error(DirectiveLoc,
5108+
".abort '" + Str + "' detected. Assembly stopping");
51135109
}
51145110

51155111
/// parseDirectiveInclude
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t
2-
# RUN: FileCheck -input-file %t %s
1+
// RUN: not llvm-mc -filetype=obj -triple x86_64 %s 2>&1 -o /dev/null | FileCheck %s
32

4-
# CHECK: error: .abort 'please stop assembing'
5-
TEST0:
6-
.abort please stop assembing
3+
.abort
4+
// CHECK: [[#@LINE-1]]:1: error: .abort detected. Assembly stopping
5+
// CHECK-NEXT: abort
6+
7+
.abort "abort message"
8+
// CHECK: [[#@LINE-1]]:1: error: .abort '"abort message"' detected. Assembly stopping
9+
// CHECK-NEXT: abort

0 commit comments

Comments
 (0)