aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/CodeEmitterGen.cpp
diff options
context:
space:
mode:
authorEvandro Menezes <emenezes@codeaurora.org>2012-11-09 20:29:37 +0000
committerEvandro Menezes <emenezes@codeaurora.org>2012-11-09 20:29:37 +0000
commit567698a6ca828a7cbb9ad5b978656e5e437ebed6 (patch)
tree72855995e963bd3020e127fd0260e47ad1395e5b /llvm/utils/TableGen/CodeEmitterGen.cpp
parenta305ea55114a33601aec1021f496ff3d7cc08038 (diff)
downloadllvm-567698a6ca828a7cbb9ad5b978656e5e437ebed6.zip
llvm-567698a6ca828a7cbb9ad5b978656e5e437ebed6.tar.gz
llvm-567698a6ca828a7cbb9ad5b978656e5e437ebed6.tar.bz2
Fix issue with invalid flat operand number
Avoid iterating over list of operands beyond the number of operands in it. llvm-svn: 167634
Diffstat (limited to 'llvm/utils/TableGen/CodeEmitterGen.cpp')
-rw-r--r--llvm/utils/TableGen/CodeEmitterGen.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp
index e60aec95..bcca15c 100644
--- a/llvm/utils/TableGen/CodeEmitterGen.cpp
+++ b/llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -134,10 +134,15 @@ AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName,
assert(!CGI.Operands.isFlatOperandNotEmitted(OpIdx) &&
"Explicitly used operand also marked as not emitted!");
} else {
+ unsigned NumberOps = CGI.Operands.size();
/// If this operand is not supposed to be emitted by the
/// generated emitter, skip it.
- while (CGI.Operands.isFlatOperandNotEmitted(NumberedOp))
+ while (NumberedOp < NumberOps &&
+ CGI.Operands.isFlatOperandNotEmitted(NumberedOp))
++NumberedOp;
+ // If this operand has not been found, ignore it.
+ if (NumberedOp >= NumberOps)
+ return;
OpIdx = NumberedOp++;
}