diff options
Diffstat (limited to 'llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp')
-rw-r--r-- | llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 23cfd365f97..23e36770ed6 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -2702,6 +2702,7 @@ bool AArch64AsmParser::parseSysAlias(StringRef Name, SMLoc NameLoc, } if (getLexer().isNot(AsmToken::EndOfStatement)) { + Parser.eatToEndOfStatement(); return TokError("unexpected token in argument list"); } @@ -3321,6 +3322,8 @@ bool AArch64AsmParser::ParseInstruction(ParseInstructionInfo &Info, // IC, DC, AT, and TLBI instructions are aliases for the SYS instruction. if (Head == "ic" || Head == "dc" || Head == "at" || Head == "tlbi") { bool IsError = parseSysAlias(Head, NameLoc, Operands); + if (IsError && getLexer().isNot(AsmToken::EndOfStatement)) + Parser.eatToEndOfStatement(); return IsError; } @@ -3377,6 +3380,7 @@ bool AArch64AsmParser::ParseInstruction(ParseInstructionInfo &Info, if (getLexer().isNot(AsmToken::EndOfStatement)) { // Read the first operand. if (parseOperand(Operands, false, false)) { + Parser.eatToEndOfStatement(); return true; } @@ -3389,6 +3393,7 @@ bool AArch64AsmParser::ParseInstruction(ParseInstructionInfo &Info, (N == 3 && condCodeThirdOperand) || (N == 2 && condCodeSecondOperand), condCodeSecondOperand || condCodeThirdOperand)) { + Parser.eatToEndOfStatement(); return true; } @@ -3420,6 +3425,7 @@ bool AArch64AsmParser::ParseInstruction(ParseInstructionInfo &Info, if (getLexer().isNot(AsmToken::EndOfStatement)) { SMLoc Loc = Parser.getTok().getLoc(); + Parser.eatToEndOfStatement(); return Error(Loc, "unexpected token in argument list"); } @@ -4177,10 +4183,8 @@ bool AArch64AsmParser::ParseDirective(AsmToken DirectiveID) { if (IDVal == ".inst") return parseDirectiveInst(Loc); } - if (IDVal == MCLOHDirectiveName()) - return parseDirectiveLOH(IDVal, Loc); - return true; + return parseDirectiveLOH(IDVal, Loc); } static const struct { @@ -4341,6 +4345,7 @@ bool AArch64AsmParser::parseDirectiveWord(unsigned Size, SMLoc L) { bool AArch64AsmParser::parseDirectiveInst(SMLoc Loc) { MCAsmParser &Parser = getParser(); if (getLexer().is(AsmToken::EndOfStatement)) { + Parser.eatToEndOfStatement(); Error(Loc, "expected expression following directive"); return false; } @@ -4398,6 +4403,8 @@ bool AArch64AsmParser::parseDirectiveTLSDescCall(SMLoc L) { /// ::= .loh <lohName | lohId> label1, ..., labelN /// The number of arguments depends on the loh identifier. bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) { + if (IDVal != MCLOHDirectiveName()) + return true; MCLOHType Kind; if (getParser().getTok().isNot(AsmToken::Identifier)) { if (getParser().getTok().isNot(AsmToken::Integer)) @@ -4405,10 +4412,8 @@ bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) { // We successfully get a numeric value for the identifier. // Check if it is valid. int64_t Id = getParser().getTok().getIntVal(); - if (Id <= -1U && !isValidMCLOHType(Id)) { - TokError("invalid numeric identifier in directive"); - return false; - } + if (Id <= -1U && !isValidMCLOHType(Id)) + return TokError("invalid numeric identifier in directive"); Kind = (MCLOHType)Id; } else { StringRef Name = getTok().getIdentifier(); @@ -4466,18 +4471,25 @@ bool AArch64AsmParser::parseDirectiveReq(StringRef Name, SMLoc L) { if (RegNum == static_cast<unsigned>(-1)) { StringRef Kind; RegNum = tryMatchVectorRegister(Kind, false); - if (!Kind.empty()) - return Error(SRegLoc, "vector register without type specifier expected"); + if (!Kind.empty()) { + Error(SRegLoc, "vector register without type specifier expected"); + return false; + } IsVector = true; } - if (RegNum == static_cast<unsigned>(-1)) - return Error(SRegLoc, "register name or alias expected"); + if (RegNum == static_cast<unsigned>(-1)) { + Parser.eatToEndOfStatement(); + Error(SRegLoc, "register name or alias expected"); + return false; + } // Shouldn't be anything else. - if (Parser.getTok().isNot(AsmToken::EndOfStatement)) - return Error(Parser.getTok().getLoc(), - "unexpected input in .req directive"); + if (Parser.getTok().isNot(AsmToken::EndOfStatement)) { + Error(Parser.getTok().getLoc(), "unexpected input in .req directive"); + Parser.eatToEndOfStatement(); + return false; + } Parser.Lex(); // Consume the EndOfStatement @@ -4485,7 +4497,7 @@ bool AArch64AsmParser::parseDirectiveReq(StringRef Name, SMLoc L) { if (RegisterReqs.insert(std::make_pair(Name, pair)).first->second != pair) Warning(L, "ignoring redefinition of register alias '" + Name + "'"); - return false; + return true; } /// parseDirectiveUneq @@ -4494,6 +4506,7 @@ bool AArch64AsmParser::parseDirectiveUnreq(SMLoc L) { MCAsmParser &Parser = getParser(); if (Parser.getTok().isNot(AsmToken::Identifier)) { Error(Parser.getTok().getLoc(), "unexpected input in .unreq directive."); + Parser.eatToEndOfStatement(); return false; } RegisterReqs.erase(Parser.getTok().getIdentifier().lower()); |