Ignore:
Timestamp:
Sep 6, 2023, 12:15:17 PM (11 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
cb0bcf1, f3f009f
Parents:
92d8cda
Message:

Clean-up in MultiLevelExit?. Primary purpose is to remove some uneeded fill code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/MultiLevelExit.cpp

    r92d8cda r4a40fca7  
    1010// Created On       : Mon Nov  1 13:48:00 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Mar 28  9:42:00 2022
    13 // Update Count     : 34
     12// Last Modified On : Wed Sep  6 12:00:00 2023
     13// Update Count     : 35
    1414//
    1515
     
    1818#include "AST/Pass.hpp"
    1919#include "AST/Stmt.hpp"
    20 #include "Common/CodeLocationTools.hpp"
    2120#include "LabelGeneratorNew.hpp"
    2221
     
    2625
    2726namespace ControlStruct {
     27
     28namespace {
     29
    2830class Entry {
    2931  public:
     
    3537                bool used = false;
    3638                Target( const Label & label ) : label( label ) {}
    37                 Target() : label( CodeLocation() ) {}
     39                Target() : label( CodeLocation(), "" ) {}
    3840        };
    3941        Target firstTarget;
     
    524526        // if continue is used insert a continue label into the back of the body of the loop
    525527        if ( entry.isContUsed() ) {
    526                 CompoundStmt * new_body = new CompoundStmt( body->location );
    527                 // {}
    528                 new_body->kids.push_back( body );
    529528                // {
    530529                //  body
     530                //  ContinueLabel: ;
    531531                // }
    532                 new_body->kids.push_back(
    533                         labelledNullStmt( body->location, entry.useContExit() ) );
    534                 // {
    535                 //  body
    536                 //  ContinueLabel: {}
    537                 // }
    538                 return new_body;
     532                return new CompoundStmt( body->location, {
     533                        body,
     534                        labelledNullStmt( body->location, entry.useContExit() ),
     535                } );
    539536        }
    540537
     
    620617}
    621618
     619} // namespace
     620
    622621const CompoundStmt * multiLevelExitUpdate(
    623         const CompoundStmt * stmt,
    624         const LabelToStmt & labelTable ) {
     622                const CompoundStmt * stmt, const LabelToStmt & labelTable ) {
    625623        // Must start in the body, so FunctionDecls can be a stopping point.
    626624        Pass<MultiLevelExitCore> visitor( labelTable );
    627         const CompoundStmt * ret = stmt->accept( visitor );
    628         // There are some unset code locations slipping in, possibly by Labels.
    629         const Node * node = localFillCodeLocations( ret->location, ret );
    630         return strict_dynamic_cast<const CompoundStmt *>( node );
    631 }
     625        return stmt->accept( visitor );
     626}
     627
    632628} // namespace ControlStruct
    633629
Note: See TracChangeset for help on using the changeset viewer.