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

Jyotsna Verma jverma at codeaurora.org
Thu Feb 14 09:58:13 PST 2013


Author: jverma
Date: Thu Feb 14 11:58:13 2013
New Revision: 175185

URL: http://llvm.org/viewvc/llvm-project?rev=175185&view=rev
Log:
Fix for bug 15246 -- out-of-bound error in the TableGen backend, CodeGenMapTable.cpp.

Modified:
    llvm/trunk/utils/TableGen/CodeGenMapTable.cpp

Modified: llvm/trunk/utils/TableGen/CodeGenMapTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenMapTable.cpp?rev=175185&r1=175184&r2=175185&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenMapTable.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenMapTable.cpp Thu Feb 14 11:58:13 2013
@@ -533,12 +533,11 @@ static void emitEnums(raw_ostream &OS, R
        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, R
 
     // 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";





More information about the llvm-commits mailing list