Skip to content

Commit c56f5c7

Browse files
committed
[AArch64][MC] Change "unexpected tokens in .xxx directive " to "expected newline"
The directive name is not useful because the next line replicates the error line which includes the directive. The prevailing style uses "expected newline".
1 parent a739f4d commit c56f5c7

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6230,8 +6230,7 @@ bool AArch64AsmParser::parseDirectiveArchExtension(SMLoc L) {
62306230

62316231
StringRef Name = getParser().parseStringToEndOfStatement().trim();
62326232

6233-
if (parseToken(AsmToken::EndOfStatement,
6234-
"unexpected token in '.arch_extension' directive"))
6233+
if (parseEOL())
62356234
return true;
62366235

62376236
bool EnableFeature = true;
@@ -6412,12 +6411,10 @@ bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) {
64126411

64136412
if (Idx + 1 == NbArgs)
64146413
break;
6415-
if (parseToken(AsmToken::Comma,
6416-
"unexpected token in '" + Twine(IDVal) + "' directive"))
6414+
if (parseComma())
64176415
return true;
64186416
}
6419-
if (parseToken(AsmToken::EndOfStatement,
6420-
"unexpected token in '" + Twine(IDVal) + "' directive"))
6417+
if (parseEOL())
64216418
return true;
64226419

64236420
getStreamer().emitLOHDirective((MCLOHType)Kind, Args);
@@ -6427,7 +6424,7 @@ bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) {
64276424
/// parseDirectiveLtorg
64286425
/// ::= .ltorg | .pool
64296426
bool AArch64AsmParser::parseDirectiveLtorg(SMLoc L) {
6430-
if (parseToken(AsmToken::EndOfStatement, "unexpected token in directive"))
6427+
if (parseEOL())
64316428
return true;
64326429
getTargetStreamer().emitCurrentConstantPool();
64336430
return false;
@@ -6485,8 +6482,7 @@ bool AArch64AsmParser::parseDirectiveReq(StringRef Name, SMLoc L) {
64856482
return Error(SRegLoc, "register name or alias expected");
64866483

64876484
// Shouldn't be anything else.
6488-
if (parseToken(AsmToken::EndOfStatement,
6489-
"unexpected input in .req directive"))
6485+
if (parseEOL())
64906486
return true;
64916487

64926488
auto pair = std::make_pair(RegisterKind, (unsigned) RegNum);
@@ -6507,7 +6503,7 @@ bool AArch64AsmParser::parseDirectiveUnreq(SMLoc L) {
65076503
}
65086504

65096505
bool AArch64AsmParser::parseDirectiveCFINegateRAState() {
6510-
if (parseToken(AsmToken::EndOfStatement, "unexpected token in directive"))
6506+
if (parseEOL())
65116507
return true;
65126508
getStreamer().emitCFINegateRAState();
65136509
return false;
@@ -6516,8 +6512,7 @@ bool AArch64AsmParser::parseDirectiveCFINegateRAState() {
65166512
/// parseDirectiveCFIBKeyFrame
65176513
/// ::= .cfi_b_key
65186514
bool AArch64AsmParser::parseDirectiveCFIBKeyFrame() {
6519-
if (parseToken(AsmToken::EndOfStatement,
6520-
"unexpected token in '.cfi_b_key_frame'"))
6515+
if (parseEOL())
65216516
return true;
65226517
getStreamer().emitCFIBKeyFrame();
65236518
return false;

llvm/test/MC/AArch64/arm64-directive_loh.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@ _fct1:
7373
.loh 153, L1
7474

7575
# Too much arguments.
76-
# CHECK-ERRORS: error: unexpected token in '.loh' directive
76+
# CHECK-ERRORS: error: expected newline
7777
# CHECK-ERRORS-NEXT: .loh AdrpAdrp L1, L2, L3
7878
# CHECK-ERRORS-NEXT: ^
7979
.loh AdrpAdrp L1, L2, L3
8080

8181
# Too much arguments with alternative syntax.
82-
# CHECK-ERRORS: error: unexpected token in '.loh' directive
82+
# CHECK-ERRORS: error: expected newline
8383
# CHECK-ERRORS-NEXT: .loh 1 L1, L2, L3
8484
# CHECK-ERRORS-NEXT: ^
8585
.loh 1 L1, L2, L3
8686

8787
# Too few arguments.
88-
# CHECK-ERRORS: error: unexpected token in '.loh' directive
88+
# CHECK-ERRORS: error: expected comma
8989
# CHECK-ERRORS-NEXT: .loh AdrpAdrp L1
9090
# CHECK-ERRORS-NEXT: ^
9191
.loh AdrpAdrp L1
9292

9393
# Too few arguments with alternative syntax.
94-
# CHECK-ERRORS: error: unexpected token in '.loh' directive
94+
# CHECK-ERRORS: error: expected comma
9595
# CHECK-ERRORS-NEXT: .loh 1 L1
9696
# CHECK-ERRORS-NEXT: ^
9797
.loh 1 L1

llvm/test/MC/AArch64/dot-req-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bar:
1818
// CHECK-ERROR: ^
1919

2020
lisa .req x1, 23
21-
// CHECK-ERROR: error: unexpected input in .req directive
21+
// CHECK-ERROR: error: expected newline
2222
// CHECK-ERROR: lisa .req x1, 23
2323
// CHECK-ERROR: ^
2424

0 commit comments

Comments
 (0)