Changeset 6b6a3b8


Ignore:
Timestamp:
Jan 10, 2020, 11:39:37 AM (21 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
4737d8e
Parents:
50cfa99
Message:

Fixed a memory leak and some line length issues in setLabelsDef.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/LabelFixer.cc

    r50cfa99 r6b6a3b8  
    7575
    7676
    77         // sets the definition of the labelTable entry to be the provided statement for every label in the list
    78         // parameter. Happens for every kind of statement
     77        // Sets the definition of the labelTable entry to be the provided statement for every label in
     78        // the list parameter. Happens for every kind of statement.
    7979        Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) {
    8080                assert( definition != 0 );
    8181                assert( llabel.size() > 0 );
    82 
    83                 Entry * e = new Entry( definition );
    8482
    8583                for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) {
     
    8785                        l.set_statement( definition ); // attach statement to the label to be used later
    8886                        if ( labelTable.find( l ) == labelTable.end() ) {
    89                                 // all labels on this statement need to use the same entry, so this should only be created once
     87                                // All labels on this statement need to use the same entry,
     88                                // so this should only be created once.
    9089                                // undefined and unused until now, add an entry
    91                                 labelTable[ l ] =  e;
     90                                labelTable[ l ] = new Entry( definition );
    9291                        } else if ( labelTable[ l ]->defined() ) {
    9392                                // defined twice, error
    94                                 SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() );
    95                         }       else {
     93                                SemanticError( l.get_statement()->location,
     94                                        "Duplicate definition of label: " + l.get_name() );
     95                        } else {
    9696                                // used previously, but undefined until now -> link with this entry
     97                                // Question: Is changing objects important?
    9798                                delete labelTable[ l ];
    98                                 labelTable[ l ] = e;
     99                                labelTable[ l ] = new Entry( definition );
    99100                        } // if
    100101                } // for
    101102
    102                 // produce one of the labels attached to this statement to be temporarily used as the canonical label
     103                // Produce one of the labels attached to this statement to be temporarily used as the
     104                // canonical label.
    103105                return labelTable[ llabel.front() ]->get_label();
    104106        }
Note: See TracChangeset for help on using the changeset viewer.