From: Akira Hatanaka Date: Tue, 13 Oct 2015 18:55:34 +0000 (+0000) Subject: [AArch64] Check the size of the vector before accessing its elements. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=881068713cacd18998309d2c15f3c43e5c324830;p=oota-llvm.git [AArch64] Check the size of the vector before accessing its elements. This fixes an assert in AArch64AsmParser::MatchAndEmitInstruction. rdar://problem/23081753 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250207 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index e3af43d1948..3980d3698c1 100644 --- a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -3967,7 +3967,7 @@ bool AArch64AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, // suffix token operand. The short-form match failure is probably more // relevant: use it instead. if (MatchResult == Match_InvalidOperand && ErrorInfo == 1 && - ((AArch64Operand &)*Operands[1]).isToken() && + Operands.size() > 1 && ((AArch64Operand &)*Operands[1]).isToken() && ((AArch64Operand &)*Operands[1]).isTokenSuffix()) { MatchResult = ShortFormNEONMatchResult; ErrorInfo = ShortFormNEONErrorInfo; diff --git a/test/MC/AArch64/arm64-diags.s b/test/MC/AArch64/arm64-diags.s index e368d50f3b2..3510193a71f 100644 --- a/test/MC/AArch64/arm64-diags.s +++ b/test/MC/AArch64/arm64-diags.s @@ -480,3 +480,12 @@ tlbi vale3 ; CHECK-ERRORS: error: invalid operand for instruction ; CHECK-ERRORS: b.eq 0, 0 ; CHECK-ERRORS: ^ + +; Check that we give the proper "too few operands" diagnostic instead of +; asserting. + + ldr + +; CHECK-ERRORS: error: too few operands for instruction +; CHECK-ERRORS: ldr +; CHECK-ERRORS: ^