[llvm-commits] [llvm] r113921 - /llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Chris Lattner
sabre at nondot.org
Tue Sep 14 20:50:11 PDT 2010
Author: lattner
Date: Tue Sep 14 22:50:11 2010
New Revision: 113921
URL: http://llvm.org/viewvc/llvm-project?rev=113921&view=rev
Log:
Diagnose invalid instructions like "incl" with "too few operands for instruction"
instead of crashing. This fixes:
rdar://8431815 - crash when invalid operand is one that isn't present
Modified:
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=113921&r1=113920&r2=113921&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Tue Sep 14 22:50:11 2010
@@ -1066,12 +1066,14 @@
// Recover location info for the operand if we know which was the problem.
SMLoc ErrorLoc = IDLoc;
if (OrigErrorInfo != ~0U) {
+ if (OrigErrorInfo >= Operands.size())
+ return Error(IDLoc, "too few operands for instruction");
+
ErrorLoc = ((X86Operand*)Operands[OrigErrorInfo])->getStartLoc();
if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;
}
- Error(ErrorLoc, "invalid operand for instruction");
- return true;
+ return Error(ErrorLoc, "invalid operand for instruction");
}
// If one instruction matched with a missing feature, report this as a
More information about the llvm-commits
mailing list