[llvm] c56f5c7 - [AArch64][MC] Change "unexpected tokens in .xxx directive " to "expected newline"

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 5 14:32:37 PDT 2022


Author: Fangrui Song
Date: 2022-06-05T14:32:31-07:00
New Revision: c56f5c71cf987bd38b71a442677b7af4d1af41a1

URL: https://github.com/llvm/llvm-project/commit/c56f5c71cf987bd38b71a442677b7af4d1af41a1
DIFF: https://github.com/llvm/llvm-project/commit/c56f5c71cf987bd38b71a442677b7af4d1af41a1.diff

LOG: [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".

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/test/MC/AArch64/arm64-directive_loh.s
    llvm/test/MC/AArch64/dot-req-diagnostics.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index c0ca07fdc0fd6..58247fc70b96b 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -6230,8 +6230,7 @@ bool AArch64AsmParser::parseDirectiveArchExtension(SMLoc L) {
 
   StringRef Name = getParser().parseStringToEndOfStatement().trim();
 
-  if (parseToken(AsmToken::EndOfStatement,
-                 "unexpected token in '.arch_extension' directive"))
+  if (parseEOL())
     return true;
 
   bool EnableFeature = true;
@@ -6412,12 +6411,10 @@ bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) {
 
     if (Idx + 1 == NbArgs)
       break;
-    if (parseToken(AsmToken::Comma,
-                   "unexpected token in '" + Twine(IDVal) + "' directive"))
+    if (parseComma())
       return true;
   }
-  if (parseToken(AsmToken::EndOfStatement,
-                 "unexpected token in '" + Twine(IDVal) + "' directive"))
+  if (parseEOL())
     return true;
 
   getStreamer().emitLOHDirective((MCLOHType)Kind, Args);
@@ -6427,7 +6424,7 @@ bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) {
 /// parseDirectiveLtorg
 ///  ::= .ltorg | .pool
 bool AArch64AsmParser::parseDirectiveLtorg(SMLoc L) {
-  if (parseToken(AsmToken::EndOfStatement, "unexpected token in directive"))
+  if (parseEOL())
     return true;
   getTargetStreamer().emitCurrentConstantPool();
   return false;
@@ -6485,8 +6482,7 @@ bool AArch64AsmParser::parseDirectiveReq(StringRef Name, SMLoc L) {
     return Error(SRegLoc, "register name or alias expected");
 
   // Shouldn't be anything else.
-  if (parseToken(AsmToken::EndOfStatement,
-                 "unexpected input in .req directive"))
+  if (parseEOL())
     return true;
 
   auto pair = std::make_pair(RegisterKind, (unsigned) RegNum);
@@ -6507,7 +6503,7 @@ bool AArch64AsmParser::parseDirectiveUnreq(SMLoc L) {
 }
 
 bool AArch64AsmParser::parseDirectiveCFINegateRAState() {
-  if (parseToken(AsmToken::EndOfStatement, "unexpected token in directive"))
+  if (parseEOL())
     return true;
   getStreamer().emitCFINegateRAState();
   return false;
@@ -6516,8 +6512,7 @@ bool AArch64AsmParser::parseDirectiveCFINegateRAState() {
 /// parseDirectiveCFIBKeyFrame
 /// ::= .cfi_b_key
 bool AArch64AsmParser::parseDirectiveCFIBKeyFrame() {
-  if (parseToken(AsmToken::EndOfStatement,
-                 "unexpected token in '.cfi_b_key_frame'"))
+  if (parseEOL())
     return true;
   getStreamer().emitCFIBKeyFrame();
   return false;

diff  --git a/llvm/test/MC/AArch64/arm64-directive_loh.s b/llvm/test/MC/AArch64/arm64-directive_loh.s
index 44f9539ba52eb..c80444bed4934 100644
--- a/llvm/test/MC/AArch64/arm64-directive_loh.s
+++ b/llvm/test/MC/AArch64/arm64-directive_loh.s
@@ -73,25 +73,25 @@ _fct1:
 .loh 153, L1
 
 # Too much arguments.
-# CHECK-ERRORS: error: unexpected token in '.loh' directive
+# CHECK-ERRORS: error: expected newline
 # CHECK-ERRORS-NEXT: .loh AdrpAdrp L1, L2, L3
 # CHECK-ERRORS-NEXT:                     ^
 .loh AdrpAdrp L1, L2, L3
 
 # Too much arguments with alternative syntax.
-# CHECK-ERRORS: error: unexpected token in '.loh' directive
+# CHECK-ERRORS: error: expected newline
 # CHECK-ERRORS-NEXT: .loh 1 L1, L2, L3
 # CHECK-ERRORS-NEXT:              ^
 .loh 1 L1, L2, L3
 
 # Too few arguments.
-# CHECK-ERRORS: error: unexpected token in '.loh' directive
+# CHECK-ERRORS: error: expected comma
 # CHECK-ERRORS-NEXT: .loh AdrpAdrp L1
 # CHECK-ERRORS-NEXT:                 ^
 .loh AdrpAdrp L1
 
 # Too few arguments with alternative syntax.
-# CHECK-ERRORS: error: unexpected token in '.loh' directive
+# CHECK-ERRORS: error: expected comma
 # CHECK-ERRORS-NEXT: .loh 1 L1
 # CHECK-ERRORS-NEXT:          ^
 .loh 1 L1

diff  --git a/llvm/test/MC/AArch64/dot-req-diagnostics.s b/llvm/test/MC/AArch64/dot-req-diagnostics.s
index 44065f8d19466..826f3be8ecc47 100644
--- a/llvm/test/MC/AArch64/dot-req-diagnostics.s
+++ b/llvm/test/MC/AArch64/dot-req-diagnostics.s
@@ -18,7 +18,7 @@ bar:
 // CHECK-ERROR:           ^
 
         lisa .req x1, 23
-// CHECK-ERROR: error: unexpected input in .req directive
+// CHECK-ERROR: error: expected newline
 // CHECK-ERROR: lisa .req x1, 23
 // CHECK-ERROR:             ^
 


        


More information about the llvm-commits mailing list