Changeset 37eb41b


Ignore:
Timestamp:
Jan 31, 2022, 10:20:44 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
d7e9c12
Parents:
0fba0d4
Message:

formatting, remove anonymous namespace

Location:
src/ControlStruct
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/FixLabels.cpp

    r0fba0d4 r37eb41b  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Nov  1 09:39:00 2021
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Nov  8 10:53:00 2021
    13 // Update Count     : 3
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jan 31 22:19:17 2022
     13// Update Count     : 9
    1414//
    1515
     
    2020#include "AST/Stmt.hpp"
    2121#include "ControlStruct/MultiLevelExit.hpp"
     22using namespace ast;
    2223
    2324namespace ControlStruct {
    24 
    25 namespace {
    26 
    27 class FixLabelsCore final : public ast::WithGuards {
     25class FixLabelsCore final : public WithGuards {
    2826        LabelToStmt labelTable;
    29 public:
     27  public:
    3028        FixLabelsCore() : labelTable() {}
    3129
    32         void previsit( const ast::FunctionDecl * );
    33         const ast::FunctionDecl * postvisit( const ast::FunctionDecl * );
    34         void previsit( const ast::Stmt * );
    35         void previsit( const ast::BranchStmt * );
    36         void previsit( const ast::LabelAddressExpr * );
     30        void previsit( const FunctionDecl * );
     31        const FunctionDecl * postvisit( const FunctionDecl * );
     32        void previsit( const Stmt * );
     33        void previsit( const BranchStmt * );
     34        void previsit( const LabelAddressExpr * );
    3735
    38         void setLabelsDef( const std::vector<ast::Label> &, const ast::Stmt * );
    39         void setLabelsUsage( const ast::Label & );
     36        void setLabelsDef( const std::vector<Label> &, const Stmt * );
     37        void setLabelsUsage( const Label & );
    4038};
    4139
    42 void FixLabelsCore::previsit( const ast::FunctionDecl * ) {
     40void FixLabelsCore::previsit( const FunctionDecl * ) {
    4341        GuardValue( labelTable ).clear();
    4442}
    4543
    46 const ast::FunctionDecl * FixLabelsCore::postvisit(
    47                 const ast::FunctionDecl * decl ) {
     44const FunctionDecl * FixLabelsCore::postvisit(
     45        const FunctionDecl * decl ) {
    4846        if ( nullptr == decl->stmts ) return decl;
    4947        for ( auto kvp : labelTable ) {
    5048                if ( nullptr == kvp.second ) {
    5149                        SemanticError( kvp.first.location,
    52                                 "Use of undefined label: " + kvp.first.name );
     50                                                   "Use of undefined label: " + kvp.first.name );
    5351                }
    5452        }
    55         return ast::mutate_field( decl, &ast::FunctionDecl::stmts,
    56                 multiLevelExitUpdate( decl->stmts.get(), labelTable ) );
     53        return mutate_field( decl, &FunctionDecl::stmts,
     54                                                 multiLevelExitUpdate( decl->stmts.get(), labelTable ) );
    5755}
    5856
    59 void FixLabelsCore::previsit( const ast::Stmt * stmt ) {
     57void FixLabelsCore::previsit( const Stmt * stmt ) {
    6058        if ( !stmt->labels.empty() ) {
    6159                setLabelsDef( stmt->labels, stmt );
     
    6361}
    6462
    65 void FixLabelsCore::previsit( const ast::BranchStmt * stmt ) {
     63void FixLabelsCore::previsit( const BranchStmt * stmt ) {
    6664        if ( !stmt->labels.empty() ) {
    6765                setLabelsDef( stmt->labels, stmt );
     
    7270}
    7371
    74 void FixLabelsCore::previsit( const ast::LabelAddressExpr * expr ) {
     72void FixLabelsCore::previsit( const LabelAddressExpr * expr ) {
    7573        assert( !expr->arg.empty() );
    7674        setLabelsUsage( expr->arg );
     
    7876
    7977void FixLabelsCore::setLabelsDef(
    80                 const std::vector<ast::Label> & labels, const ast::Stmt * stmt ) {
     78        const std::vector<Label> & labels, const Stmt * stmt ) {
    8179        assert( !labels.empty() );
    8280        assert( stmt );
     
    8987                        // Duplicate definition, this is an error.
    9088                        SemanticError( label.location,
    91                                 "Duplicate definition of label: " + label.name );
     89                                                   "Duplicate definition of label: " + label.name );
    9290                } else {
    9391                        // Perviously used, but not defined until now.
     
    9896
    9997// Label was used, if it is new add it to the table.
    100 void FixLabelsCore::setLabelsUsage( const ast::Label & label ) {
     98void FixLabelsCore::setLabelsUsage( const Label & label ) {
    10199        if ( labelTable.find( label ) == labelTable.end() ) {
    102100                labelTable[ label ] = nullptr;
     
    104102}
    105103
    106 } // namespace
    107 
    108 void fixLabels( ast::TranslationUnit & translationUnit ) {
    109         ast::Pass<FixLabelsCore>::run( translationUnit );
     104void fixLabels( TranslationUnit & translationUnit ) {
     105        Pass<FixLabelsCore>::run( translationUnit );
    110106}
    111 
    112107} // namespace ControlStruct
    113108
  • src/ControlStruct/FixLabels.hpp

    r0fba0d4 r37eb41b  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Nov  1 09:36:00 2021
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Nov  1 09:40:00 2021
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jan 31 22:18:43 2022
     13// Update Count     : 2
    1414//
    1515
     
    1717
    1818namespace ast {
    19         class TranslationUnit;
     19class TranslationUnit;
    2020}
    2121
    2222namespace ControlStruct {
    23 
    24 /// normalizes label definitions and generates multi-level exit labels
     23// normalizes label definitions and generates multi-level exit labels
    2524void fixLabels( ast::TranslationUnit & translationUnit );
    26 
    2725}
    2826
Note: See TracChangeset for help on using the changeset viewer.