summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2015-10-13 18:55:34 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2015-10-13 18:55:34 +0000
commit5a4e4f8d8abcd2d6928f03ad1615949911d67305 (patch)
treeca21b4e5586c66e05f3c5e5be5e12a70aa8781fa /llvm
parent08be61407b774cdd98e445697b3ada69fc06da11 (diff)
downloadbcm5719-llvm-5a4e4f8d8abcd2d6928f03ad1615949911d67305.tar.gz
bcm5719-llvm-5a4e4f8d8abcd2d6928f03ad1615949911d67305.zip
[AArch64] Check the size of the vector before accessing its elements.
This fixes an assert in AArch64AsmParser::MatchAndEmitInstruction. rdar://problem/23081753 llvm-svn: 250207
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp2
-rw-r--r--llvm/test/MC/AArch64/arm64-diags.s9
2 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index e3af43d1948..3980d3698c1 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/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/llvm/test/MC/AArch64/arm64-diags.s b/llvm/test/MC/AArch64/arm64-diags.s
index e368d50f3b2..3510193a71f 100644
--- a/llvm/test/MC/AArch64/arm64-diags.s
+++ b/llvm/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: ^
OpenPOWER on IntegriCloud