Ignore:
Timestamp:
Aug 14, 2017, 2:07:34 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
6cfe8bb
Parents:
36a5a77 (diff), bd46af4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/MLEMutator.cc

    r36a5a77 r8217e8f  
    154154                return switchStmt;
    155155        }
     156
     157        void addUnused( Statement * stmt, const Label & originalTarget ) {
     158                // break/continue without a label doesn't need unused attribute
     159                if ( originalTarget == "" ) return;
     160                // add unused attribute to the originalTarget of a labelled break/continue
     161                for ( Label & l : stmt->get_labels() ) {
     162                        // find the label to add unused attribute to
     163                        if ( l == originalTarget ) {
     164                                for ( Attribute * attr : l.get_attributes() ) {
     165                                        // ensure attribute isn't added twice
     166                                        if ( attr->get_name() == "unused" ) return;
     167                                }
     168                                l.get_attributes().push_back( new Attribute( "unused" ) );
     169                                return;
     170                        }
     171                }
     172                assertf( false, "Could not find label '%s' on statement %s", originalTarget.get_name().c_str(), toString( stmt ).c_str() );
     173        }
     174
    156175
    157176        Statement *MLEMutator::mutate( BranchStmt *branchStmt ) throw ( SemanticError ) {
     
    204223                } // switch
    205224
     225                // add unused attribute to label to silence warnings
     226                addUnused( targetEntry->get_controlStructure(), branchStmt->get_originalTarget() );
     227
    206228                // transform break/continue statements into goto to simplify later handling of branches
    207229                delete branchStmt;
Note: See TracChangeset for help on using the changeset viewer.