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

David Blaikie dblaikie at gmail.com
Thu Feb 14 10:58:31 PST 2013


On Thu, Feb 14, 2013 at 9:58 AM, Jyotsna Verma <jverma at codeaurora.org>wrote:

> 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
>

Test case?


>
> 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";
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130214/b5d90729/attachment.html>


More information about the llvm-commits mailing list