Fix for bug 15246 -- out-of-bound error in the TableGen backend, CodeGenMapTable.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jyotsna Verma 2013-02-14 17:58:13 +00:00
parent 7867885737
commit 1912c7624a

View File

@ -533,12 +533,11 @@ static void emitEnums(raw_ostream &OS, RecordKeeper &Records) {
II = ColFieldValueMap.begin(), IE = ColFieldValueMap.end();
II != IE; II++) {
std::vector<Init*> FieldValues = (*II).second;
unsigned FieldSize = FieldValues.size();
// Delete duplicate entries from ColFieldValueMap
for (unsigned i = 0; i < FieldSize - 1; i++) {
for (unsigned i = 0; i < FieldValues.size() - 1; i++) {
Init *CurVal = FieldValues[i];
for (unsigned j = i+1; j < FieldSize; j++) {
for (unsigned j = i+1; j < FieldValues.size(); j++) {
if (CurVal == FieldValues[j]) {
FieldValues.erase(FieldValues.begin()+j);
}
@ -547,9 +546,9 @@ static void emitEnums(raw_ostream &OS, RecordKeeper &Records) {
// Emit enumerated values for the column fields.
OS << "enum " << (*II).first << " {\n";
for (unsigned i = 0; i < FieldSize; i++) {
for (unsigned i = 0, endFV = FieldValues.size(); i < endFV; i++) {
OS << "\t" << (*II).first << "_" << FieldValues[i]->getAsUnquotedString();
if (i != FieldValues.size() - 1)
if (i != endFV - 1)
OS << ",\n";
else
OS << "\n};\n\n";