[llvm] fc82507 - [AArch64][MC] Remove unneeded "in .xxx directive" from diagnostics

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun May 23 13:58:20 PDT 2021


Author: Fangrui Song
Date: 2021-05-23T13:58:16-07:00
New Revision: fc82507c895a11c2d3acfcc5fb0e547d7f42f88e

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

LOG: [AArch64][MC] Remove unneeded "in .xxx directive" from diagnostics

The prevailing style does not add the message. The directive name is not useful
because the next line replicates the error line which includes the directive.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
    llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/test/MC/AArch64/directive-variant_pcs-err.s

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h b/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
index c37889cfc509..fc10e33bcf6b 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h
@@ -89,6 +89,7 @@ class MCAsmParserExtension {
                   const Twine &Msg = "unexpected token") {
     return getParser().parseToken(T, Msg);
   }
+  bool parseEOL() { return getParser().parseEOL(); }
 
   bool parseMany(function_ref<bool()> parseOne, bool hasComma = true) {
     return getParser().parseMany(parseOne, hasComma);

diff  --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 396bae6afebd..a7ec6214bb80 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -5594,9 +5594,7 @@ bool AArch64AsmParser::parseDirectiveInst(SMLoc Loc) {
     return false;
   };
 
-  if (parseMany(parseOp))
-    return addErrorSuffix(" in '.inst' directive");
-  return false;
+  return parseMany(parseOp);
 }
 
 // parseDirectiveTLSDescCall:
@@ -5752,9 +5750,7 @@ bool AArch64AsmParser::parseDirectiveUnreq(SMLoc L) {
     return TokError("unexpected input in .unreq directive.");
   RegisterReqs.erase(Parser.getTok().getIdentifier().lower());
   Parser.Lex(); // Eat the identifier.
-  if (parseToken(AsmToken::EndOfStatement))
-    return addErrorSuffix("in '.unreq' directive");
-  return false;
+  return parseToken(AsmToken::EndOfStatement);
 }
 
 bool AArch64AsmParser::parseDirectiveCFINegateRAState() {
@@ -5787,16 +5783,13 @@ bool AArch64AsmParser::parseDirectiveVariantPCS(SMLoc L) {
 
   MCSymbol *Sym = getContext().lookupSymbol(SymbolName);
   if (!Sym)
-    return TokError("unknown symbol in '.variant_pcs' directive");
+    return TokError("unknown symbol");
 
   Parser.Lex(); // Eat the symbol
 
-  // Shouldn't be any more tokens
-  if (parseToken(AsmToken::EndOfStatement))
-    return addErrorSuffix(" in '.variant_pcs' directive");
-
+  if (parseEOL())
+    return true;
   getTargetStreamer().emitDirectiveVariantPCS(Sym);
-
   return false;
 }
 

diff  --git a/llvm/test/MC/AArch64/directive-variant_pcs-err.s b/llvm/test/MC/AArch64/directive-variant_pcs-err.s
index 98cf703b564e..70bb5451d371 100644
--- a/llvm/test/MC/AArch64/directive-variant_pcs-err.s
+++ b/llvm/test/MC/AArch64/directive-variant_pcs-err.s
@@ -1,17 +1,11 @@
 // RUN: not llvm-mc -triple aarch64-unknown-none-eabi -filetype asm -o - %s 2>&1 | FileCheck %s
 
+// CHECK:      [[#@LINE+1]]:13: error: expected symbol name
 .variant_pcs
-// CHECK: error: expected symbol name
-// CHECK-NEXT:   .variant_pcs
-// CHECK-NEXT:               ^
 
+// CHECK:      [[#@LINE+1]]:14: error: unknown symbol
 .variant_pcs foo
-// CHECK: error: unknown symbol in '.variant_pcs' directive
-// CHECK-NEXT:   .variant_pcs foo
-// CHECK-NEXT:                ^
 
 .global foo
+// CHECK:      [[#@LINE+1]]:18: error: expected newline
 .variant_pcs foo bar
-// CHECK: error: unexpected token in '.variant_pcs' directive
-// CHECK-NEXT:   .variant_pcs foo bar
-// CHECK-NEXT:                    ^


        


More information about the llvm-commits mailing list