From e5f746e9bb61f06d273c629a06eb598abfbcedc3 Mon Sep 17 00:00:00 2001 From: Sergei Barannikov Date: Mon, 23 Jan 2023 03:10:02 +0300 Subject: [PATCH] [MC] Replace a switch with two 'if's (NFC) This simplifies logic a bit and helps to reduce the future diff. --- llvm/lib/MC/MCParser/AsmParser.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index f16e109..6e9aa1b 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -1901,16 +1901,14 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info, // FIXME: Recurse on local labels? - // See what kind of statement we have. - switch (Lexer.getKind()) { - case AsmToken::Colon: { - if (!getTargetParser().isLabel(ID)) - break; + // Check for a label. + // ::= identifier ':' + // ::= number ':' + if (Lexer.is(AsmToken::Colon) && getTargetParser().isLabel(ID)) { if (checkForValidSection()) return true; - // identifier ':' -> Label. - Lex(); + Lex(); // Consume the ':'. // Diagnose attempt to use '.' as a label. if (IDVal == ".") @@ -1971,16 +1969,11 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info, return false; } - case AsmToken::Equal: - if (!getTargetParser().equalIsAsmAssignment()) - break; - // identifier '=' ... -> assignment statement + // Check for an assignment statement. + // ::= identifier '=' + if (Lexer.is(AsmToken::Equal) && getTargetParser().equalIsAsmAssignment()) { Lex(); - return parseAssignment(IDVal, AssignmentKind::Equal); - - default: // Normal instruction or directive. - break; } // If macros are enabled, check to see if this is a macro instantiation. -- 2.7.4