Changes in / [4c03e63:e1c1829]


Ignore:
Files:
2 deleted
52 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r4c03e63 re1c1829  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun Jun 18 20:32:32 2017
    14 %% Update Count     : 319
     13%% Last Modified On : Mon May 15 18:03:29 2017
     14%% Update Count     : 302
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3636% Names used in the document.
    3737
    38 \newcommand{\CFAIcon}{\textrm{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
    39 \newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption
     38\newcommand{\CFA}{\textrm{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
    4039\newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name
    4140\newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name
     
    242241belowskip=3pt,
    243242% replace/adjust listing characters that look bad in sanserif
    244 literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
     243literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1
    245244        {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
    246         {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2,
     245        {__}{\_\,\_}2 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2
     246        {___}{\_\,\_\,\_}3,
    247247moredelim=**[is][\color{red}]{®}{®},                                    % red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
    248248moredelim=**[is][\color{blue}]{ß}{ß},                                   % blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
  • doc/proposals/tagged-struct.txt

    r4c03e63 re1c1829  
    1414say which of the possible values is currently stored in the union. The idea
    1515here is similar, however the possibilities are more open ended.
    16 
    17 Alternate names include virtual structure and abstract structure.
    1816
    1917
     
    3836their parent's fields to their field list so they can be upcast.
    3937
    40 The type field may be public, if it is then it can be accessed through a
    41 simple field access "instance.type". The type field would then be able to be
    42 used to access the type object, which contains the information for the type.
    43 It may just be a pointer to the type object "*instance.type", although a
    44 lookup function could also be used.
    45 
    46 
    47 Usage:
    48 
    49 The central feature for tagged structs is a checked cast between pointer types
    50 to the structures. A cast is successful if the true type of the pointed object
    51 is of the type being cast to or any of its children, otherwise the cast
    52 returns null.
    53 
    54 The type field should also allow for equality comparison of types.
    55 
    56 Currently, with only these operations (and similar features) the type field
    57 could be hidden and the operations given through helper functions. However
    58 if the type object has more complex (or even open ended) information in it
    59 than providing direct access becomes very valuable.
    60 
    6138
    6239Implemenation:
    6340
    64 Adding to the field list would have to be handled during translation. The
    65 simple act of adding declarations should not be difficult, althought it might
    66 take a bit of work to find the parent's declarations.
     41Adding to the field list is a simple matter, should be doable during
     42translation. The type field is just a pointer to a type object. With proper
     43linking we can create a single unique instance of the type object for each
     44declared tagged struct. The instance's address is used as an id for the type.
     45It also holds data about the type, such as its parent's id/a pointer to the
     46parent type object.
    6747
    68 Type objects are also simple in to generate, they should just be global
    69 (program lifetime) structures. Getting there to be exactly one instance of
    70 each allows the pointer to the structure to be used as the type id, and that
    71 should be possible to do during linking.
     48The type field could be hidden (as best as C can hide it) or it could be
     49visible to the user with easy access to allow the user to examine the type
     50object directly.
     51
     52Direct access is more useful if the data on the type-objects can change, other
     53wise the build in function could handle all cases. Perhaps each root object
     54can specify a type object to use or the type objects are themselves tagged,
     55although there may not be a base case with the latter.
     56
     57In the simplest case the type object is a pointer to the parent type object.
     58Additional data could be added, such as a name, or a function pointer to the
     59destructor.
    7260
    7361
     
    10694If unions are declared tagged instead of creating a new tagged type, all
    10795possible values of the union must be of that tagged type or a child type.
    108 
    109 
    110 Custom Type Objects (Extention):
    111 
    112 Some method to define type objects used within a tree of types. One option is
    113 to allow the tree's type object to be specified by the tree root. It would
    114 then have to be filled in for each type in the tree, including the root.
    115 
    116 The only required field is the parent field, a pointer to the type object's
    117 type. (This is also the only required field on the tagged structure itself.)
    118 
    119 A further extention could allow expanding type objects, so child types could
    120 append fields to their parent's feild list. They might need their own type
    121 objects at that point, or maybe static checks will be enough to see the
    122 minimum field list.
  • doc/rob_thesis/intro.tex

    r4c03e63 re1c1829  
    33%======================================================================
    44
    5 \section{\protect\CFA Background}
     5\section{\CFA Background}
    66\label{s:background}
    77\CFA \footnote{Pronounced ``C-for-all'', and written \CFA or Cforall.} is a modern non-object-oriented extension to the C programming language.
     
    370370    \end{tabular}
    371371  \end{center}
    372   \caption{\label{table:types} The different kinds of type parameters in \protect\CFA}
     372  \caption{\label{table:types} The different kinds of type parameters in \CFA}
    373373\end{table}
    374374
  • doc/rob_thesis/thesis.tex

    r4c03e63 re1c1829  
    6666% ,monochrome % toggle black and white mode
    6767}{xcolor}
    68 \PassOptionsToPackage{pdftex}{graphicx}
    6968\documentclass[letterpaper,12pt,titlepage,oneside,final]{book}
    7069
  • doc/working/exception/translate.c

    r4c03e63 re1c1829  
    11/* Translation rules for exception handling code, from Cforall to C.
    22 *
    3  * Reminder: This is not final. Besides names and things it is also going very
    4  * much for correctness and simplisity over efficiency.
    5  *
    6  * The first section is the shared definitions, not generated by the local
    7  * translations but used by the translated code.
     3 * Note that these are not final. Names, syntax and the exact translation
     4 * will be updated. The first section is the shared definitions, not generated
     5 * by the local translations but used by the translated code.
    86 *
    97 * Most of these exist only after translation (in C code). The first (the
     
    1715// Currently it is a typedef for int, but later it will be a new type.
    1816typedef int exception;
    19 
    20 // Will have to be availibe to user. Consider new name. Requires tagged types.
    21 forall(dtype parent | tagged(parent), dtype child | tagged(child))
    22 parent *dynamic_cast(child *);
    2317
    2418void __throw_terminate(exception except) __attribute__((noreturn));
     
    122116                }
    123117                int match1(exception except) {
    124                         {
    125                                 if (dynamic_cast__SomeException(except)) {
    126                                         return 1;
    127                                 }
    128                         }
    129                         {
    130                                 OtherException err;
    131                                 if ( (err = dynamic_cast__OtherException(except)) &&
    132                                                 err.priority > 3) {
    133                                         return 2;
    134                                 }
    135                         }
    136                         return 0;
     118                        OtherException inner_except;
     119                        if (dynamic_cast__SomeException(except)) {
     120                                return 1;
     121                        }
     122                        else if ( (inner_except = dynamic_cast__OtherException(except)) &&
     123                                        inner_except.priority > 3) {
     124                                return 2;
     125                        }
     126                        else return 0;
    137127                }
    138128                __try_terminate(try1, catch1, match1);
     
    161151        {
    162152                bool handle1(exception except) {
    163                         {
    164                                 if (dynamic_cast__SomeException(except)) {
    165                                         fiddleThing();
    166                                         return true;
    167                                 }
    168                         }
    169                         {
    170                                 OtherException err;
    171                                 if ( ( err = dynamic_cast__OtherException(except) ) &&
    172                                                 err.priority > 3) {
    173                                         twiddleWidget();
    174                                         return true;
    175                                 }
    176                         }
    177                         return false;
     153                        OtherException inner_except;
     154                        if (dynamic_cast__SomeException(except)) {
     155                                fiddleThing();
     156                                return true;
     157                        } else if (dynamic_cast__OtherException(except) &&
     158                                        inner_except.priority > 3) {
     159                                twiddleWidget();
     160                                return true;
     161                        } else {
     162                                return false;
     163                        }
    178164                }
    179165                struct __try_resume_node data =
     
    244230                }
    245231                bool handle1(exception except) {
    246                         {
    247                                 if (dynamic_cast__SomeException(except)) {
    248                                         fiddleThing();
    249                                         return true;
    250                                 }
    251                         }
    252                         return false;
     232                        if (dynamic_cast__SomeException(except)) {
     233                                fiddleThing();
     234                                return true;
     235                        } else {
     236                                return false;
     237                        }
    253238                }
    254239                struct __cleanup_hook generated_name
     
    288273        {
    289274                bool handle1() {
    290                         {
    291                                 if (dynamic_cast__OtherException(except)) {
    292                                         twiddleWidget();
    293                                         return true;
    294                                 }
     275                        if (dynamic_cast__OtherException(except)) {
     276                                twiddleWidget();
     277                                return true;
    295278                        }
    296279                        return false;
     
    314297                }
    315298                int match1(exception except) {
    316                         {
    317                                 if (dynamic_cast__SomeException(except)) {
    318                                         return 1;
    319                                 }
     299                        if (dynamic_cast__SomeException(except)) {
     300                                return 1;
    320301                        }
    321302                        return 0;
  • src/CodeGen/FixNames.cc

    r4c03e63 re1c1829  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 14:22:59 2017
    13 // Update Count     : 19
     12// Last Modified On : Thu Mar 16 07:50:30 2017
     13// Update Count     : 16
    1414//
    1515
     
    114114                                throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl);
    115115                        }
    116                         functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );
     116                        functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), "0") ) ) );
    117117                        CodeGen::FixMain::registerMain( functionDecl );
    118118                }
  • src/Common/PassVisitor.h

    r4c03e63 re1c1829  
    1818// Templated visitor type
    1919// To use declare a PassVisitor< YOUR VISITOR TYPE >
    20 // The visitor type should specify the previsit/postvisit/premutate/postmutate for types that are desired.
    21 // Note: previsit/postvisit/premutate/postmutate must be **public** members
    22 //
    23 // Several additional features are available through inheritance
    24 // | WithTypeSubstitution - provides polymorphic TypeSubstitution * env for the current expression
    25 // | WithStmtsToAdd       - provides the ability to insert statements before or after the current statement by adding new statements into
    26 //                          stmtsToAddBefore or stmtsToAddAfter respectively.
    27 // | WithShortCircuiting  - provides the ability to skip visiting child nodes; set visit_children to false in pre{visit,mutate} to skip visiting children
    28 // | WithScopes           - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable
    29 //                          will automatically be restored to its previous value after the corresponding postvisit/postmutate teminates.
     20// The visitor type should specify the previsit/postvisit for types that are desired.
    3021//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    3122template< typename pass_type >
     
    3728        PassVisitor(Args &&... args)
    3829                : pass( std::forward<Args>( args )... )
    39         {
    40                 typedef PassVisitor<pass_type> this_t;
    41                 this_t * const * visitor = visitor_impl(pass, 0);
    42                 if(visitor) {
    43                         *const_cast<this_t **>( visitor ) = this;
    44                 }
    45         }
     30        {}
    4631
    4732        virtual ~PassVisitor() = default;
     
    10186        virtual void visit( ConstructorExpr * ctorExpr ) override final;
    10287        virtual void visit( CompoundLiteralExpr *compLitExpr ) override final;
     88        virtual void visit( UntypedValofExpr *valofExpr ) override final;
    10389        virtual void visit( RangeExpr *rangeExpr ) override final;
    10490        virtual void visit( UntypedTupleExpr *tupleExpr ) override final;
     
    186172        virtual Expression* mutate( ConstructorExpr *ctorExpr ) override final;
    187173        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ) override final;
     174        virtual Expression* mutate( UntypedValofExpr *valofExpr ) override final;
    188175        virtual Expression* mutate( RangeExpr *rangeExpr ) override final;
    189176        virtual Expression* mutate( UntypedTupleExpr *tupleExpr ) override final;
     
    220207
    221208private:
    222         template<typename pass_t> friend void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );
    223         template<typename pass_t> friend void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );
    224 
    225209        template<typename node_type> void call_previsit ( node_type * node ) { previsit_impl ( pass, node, 0 ); }
    226210        template<typename node_type> void call_postvisit( node_type * node ) { postvisit_impl( pass, node, 0 ); }
     
    234218        void set_env( TypeSubstitution * env ) { set_env_impl( pass, env, 0); }
    235219
    236         template< typename func_t >
    237         void handleStatementList( std::list< Statement * > & statements, func_t func );
    238         void visitStatementList ( std::list< Statement* > &statements );
     220        void visitStatementList( std::list< Statement* > &statements );
    239221        void mutateStatementList( std::list< Statement* > &statements );
    240222
    241         template< typename func_t >
    242         Statement * handleStatement( Statement * stmt, func_t func );
    243         Statement * visitStatement ( Statement * stmt );
     223        Statement * visitStatement( Statement * stmt );
    244224        Statement * mutateStatement( Statement * stmt );
    245225
    246         template< typename func_t >
    247         Expression * handleExpression( Expression * expr, func_t func );
    248         Expression * visitExpression ( Expression * expr );
     226        void visitExpression( Expression * expr );
    249227        Expression * mutateExpression( Expression * expr );
    250228
     
    253231        std::list< Statement* > *       get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); }
    254232        std::list< Statement* > *       get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); }
    255         std::list< Declaration* > *     get_beforeDecls() { return declsToAddBefore_impl( pass, 0); }
    256         std::list< Declaration* > *     get_afterDecls () { return declsToAddAfter_impl ( pass, 0); }
    257 
    258         void set_visit_children( bool& ref ) { bool_ref * ptr = visit_children_impl(pass, 0); if(ptr) ptr->set( ref ); }
     233        bool visit_children() { bool* skip = skip_children_impl(pass, 0); return ! (skip && *skip); }
     234        void reset_visit() { bool* skip = skip_children_impl(pass, 0); if(skip) *skip = false; }
    259235
    260236        guard_value_impl init_guard() {
     
    295271        std::list< Statement* > stmtsToAddAfter;
    296272};
     273
    297274class WithShortCircuiting {
    298275protected:
     
    301278
    302279public:
    303         bool_ref visit_children;
     280        bool skip_children;
    304281};
    305282
     
    320297};
    321298
    322 template<typename pass_type>
    323 class WithVisitorRef {
    324 protected:
    325         WithVisitorRef() = default;
    326         ~WithVisitorRef() = default;
    327 
    328 public:
    329         PassVisitor<pass_type> * const visitor;
    330 };
    331299
    332300#include "PassVisitor.impl.h"
  • src/Common/PassVisitor.impl.h

    r4c03e63 re1c1829  
    44        __attribute__((unused))                   \
    55        const auto & guard = init_guard();        \
    6         bool visit_children = true;               \
    7         set_visit_children( visit_children );   \
    86        call_previsit( node );                    \
    9         if( visit_children ) {                    \
     7        if( visit_children() ) {                  \
     8                reset_visit();                      \
    109
    1110#define VISIT_END( node )                       \
     
    1615        __attribute__((unused))                   \
    1716        const auto & guard = init_guard();        \
    18         bool visit_children = true;               \
    19         set_visit_children( visit_children );   \
    2017        call_premutate( node );                   \
    21         if( visit_children ) {                    \
     18        if( visit_children() ) {                  \
     19                reset_visit();                      \
    2220
    2321#define MUTATE_END( type, node )                \
     
    4442}
    4543
    46 typedef std::list< Statement   * > StmtList_t;
    47 typedef std::list< Declaration * > DeclList_t;
    48 
    49 template<typename iterator_t>
    50 static inline void splice( iterator_t it, DeclList_t * decls ) {
    51         std::transform(
    52                 decls->begin(),
    53                 decls->end(),
    54                 it,
    55                 [](Declaration * decl) -> auto {
    56                         return new DeclStmt( noLabels, decl );
    57                 }
    58         );
    59         decls->clear();
    60 }
    61 
    62 template< typename pass_type >
    63 static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
    64 
    65         DeclList_t* beforeDecls = visitor.get_beforeDecls();
    66         DeclList_t* afterDecls  = visitor.get_afterDecls();
    67 
    68         for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
    69                 // splice in new declarations after previous decl
    70                 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
    71 
    72                 if ( i == decls.end() ) break;
    73 
    74                 // run mutator on declaration
    75                 maybeAccept( *i, visitor );
    76 
    77                 // splice in new declarations before current decl
    78                 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
    79         }
    80 }
    81 
    82 template< typename pass_type >
    83 static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
    84 
    85         DeclList_t* beforeDecls = mutator.get_beforeDecls();
    86         DeclList_t* afterDecls  = mutator.get_afterDecls();
    87 
    88         for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
    89                 // splice in new declarations after previous decl
    90                 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
    91 
    92                 if ( i == decls.end() ) break;
    93 
    94                 // run mutator on declaration
    95                 *i = maybeMutate( *i, mutator );
    96 
    97                 // splice in new declarations before current decl
    98                 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
    99         }
    100 }
    101 
    102 template< typename pass_type >
    103 template< typename func_t >
    104 void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
     44typedef std::list< Statement * > StmtList_t;
     45
     46template< typename pass_type >
     47void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
    10548        SemanticError errors;
    10649
    10750        StmtList_t* beforeStmts = get_beforeStmts();
    10851        StmtList_t* afterStmts  = get_afterStmts();
    109         DeclList_t* beforeDecls = get_beforeDecls();
    110         DeclList_t* afterDecls  = get_afterDecls();
    11152
    11253        for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
    113 
    114                 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
    11554                if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
    116 
    11755                try {
    118                         func( *i );
    119                         assert(( empty( beforeStmts ) && empty( afterStmts ))
    120                             || ( empty( beforeDecls ) && empty( afterDecls )) );
    121 
     56                        (*i)->accept( *this );
    12257                } catch ( SemanticError &e ) {
    12358                        errors.append( e );
    12459                }
    125 
    126                 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
    12760                if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
    12861        }
    12962
    130         if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
    13163        if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
    13264        if ( !errors.isEmpty() ) { throw errors; }
     
    13466
    13567template< typename pass_type >
    136 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
    137         handleStatementList( statements, [this]( Statement * stmt) {
    138                 stmt->accept( *this );
    139         });
    140 }
    141 
    142 template< typename pass_type >
    14368void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
    144         handleStatementList( statements, [this]( Statement *& stmt) {
    145                 stmt = stmt->acceptMutator( *this );
    146         });
    147 }
    148 
    149 
    150 template< typename pass_type >
    151 template< typename func_t >
    152 Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
    153         // don't want statements from outer CompoundStmts to be added to this CompoundStmt
    154         ValueGuardPtr< TypeSubstitution * >  oldEnv        ( get_env_ptr    () );
    155         ValueGuardPtr< DeclList_t >          oldBeforeDecls( get_beforeDecls() );
    156         ValueGuardPtr< DeclList_t >          oldAfterDecls ( get_afterDecls () );
    157         ValueGuardPtr< StmtList_t >          oldBeforeStmts( get_beforeStmts() );
    158         ValueGuardPtr< StmtList_t >          oldAfterStmts ( get_afterStmts () );
    159 
    160         Statement *newStmt = func( stmt );
     69        SemanticError errors;
    16170
    16271        StmtList_t* beforeStmts = get_beforeStmts();
    16372        StmtList_t* afterStmts  = get_afterStmts();
    164         DeclList_t* beforeDecls = get_beforeDecls();
    165         DeclList_t* afterDecls  = get_afterDecls();
    166 
    167         if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
    168         assert(( empty( beforeStmts ) && empty( afterStmts ))
    169             || ( empty( beforeDecls ) && empty( afterDecls )) );
     73
     74        for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
     75                if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
     76                try {
     77                        *i = (*i)->acceptMutator( *this );
     78                } catch ( SemanticError &e ) {
     79                        errors.append( e );
     80                }
     81                if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
     82        }
     83
     84        if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
     85        if ( !errors.isEmpty() ) { throw errors; }
     86}
     87
     88template< typename pass_type >
     89Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
     90        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
     91        ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     92        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
     93        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
     94
     95        maybeAccept( stmt, *this );
     96
     97        StmtList_t* beforeStmts = get_beforeStmts();
     98        StmtList_t* afterStmts  = get_afterStmts();
     99
     100        if( empty(beforeStmts) && empty(afterStmts) ) { return stmt; }
    170101
    171102        CompoundStmt *compound = new CompoundStmt( noLabels );
    172         if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
     103        if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
     104        compound->get_kids().push_back( stmt );
     105        if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
     106        return compound;
     107}
     108
     109template< typename pass_type >
     110Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
     111        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
     112        ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     113        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
     114        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
     115
     116        Statement *newStmt = maybeMutate( stmt, *this );
     117
     118        StmtList_t* beforeStmts = get_beforeStmts();
     119        StmtList_t* afterStmts  = get_afterStmts();
     120
     121        if( empty(beforeStmts) && empty(afterStmts) ) { return newStmt; }
     122
     123        CompoundStmt *compound = new CompoundStmt( noLabels );
    173124        if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
    174125        compound->get_kids().push_back( newStmt );
    175         if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
    176126        if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
    177127        return compound;
    178128}
    179129
    180 template< typename pass_type >
    181 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
    182         return handleStatement( stmt, [this]( Statement * stmt ) {
    183                 maybeAccept( stmt, *this );
    184                 return stmt;
    185         });
    186 }
    187 
    188 template< typename pass_type >
    189 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
    190         return handleStatement( stmt, [this]( Statement * stmt ) {
    191                 return maybeMutate( stmt, *this );
    192         });
    193 }
    194 
    195 template< typename pass_type >
    196 template< typename func_t >
    197 Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
    198         if( !expr ) return nullptr;
     130
     131
     132template< typename pass_type >
     133void PassVisitor< pass_type >::visitExpression( Expression * expr ) {
     134        if( !expr ) return;
    199135
    200136        auto env_ptr = get_env_ptr();
     
    202138                *env_ptr = expr->get_env();
    203139        }
    204 
    205         // should env be cloned (or moved) onto the result of the mutate?
    206         return func( expr );
    207 }
    208 
    209 template< typename pass_type >
    210 Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
    211         return handleExpression(expr, [this]( Expression * expr ) {
    212                 expr->accept( *this );
    213                 return expr;
    214         });             
     140        // xxx - should env be cloned (or moved) onto the result of the mutate?
     141        expr->accept( *this );
    215142}
    216143
    217144template< typename pass_type >
    218145Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
    219         return handleExpression(expr, [this]( Expression * expr ) {
    220                 return expr->acceptMutator( *this );
    221         });
    222 }
     146        if( !expr ) return nullptr;
     147
     148        auto env_ptr = get_env_ptr();
     149        if ( env_ptr && expr->get_env() ) {
     150                *env_ptr = expr->get_env();
     151        }
     152        // xxx - should env be cloned (or moved) onto the result of the mutate?
     153        return expr->acceptMutator( *this );
     154}
     155
    223156
    224157//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    226159template< typename pass_type >
    227160void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
    228         VISIT_BODY( node );
     161        VISIT_BODY( node ); 
    229162}
    230163
    231164template< typename pass_type >
    232165void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
    233         VISIT_BODY( node );
     166        VISIT_BODY( node ); 
    234167}
    235168
    236169template< typename pass_type >
    237170void PassVisitor< pass_type >::visit( StructDecl * node ) {
    238         VISIT_BODY( node );
     171        VISIT_BODY( node ); 
    239172}
    240173
    241174template< typename pass_type >
    242175void PassVisitor< pass_type >::visit( UnionDecl * node ) {
    243         VISIT_BODY( node );
     176        VISIT_BODY( node ); 
    244177}
    245178
    246179template< typename pass_type >
    247180void PassVisitor< pass_type >::visit( EnumDecl * node ) {
    248         VISIT_BODY( node );
     181        VISIT_BODY( node ); 
    249182}
    250183
    251184template< typename pass_type >
    252185void PassVisitor< pass_type >::visit( TraitDecl * node ) {
    253         VISIT_BODY( node );
     186        VISIT_BODY( node ); 
    254187}
    255188
    256189template< typename pass_type >
    257190void PassVisitor< pass_type >::visit( TypeDecl * node ) {
    258         VISIT_BODY( node );
     191        VISIT_BODY( node ); 
    259192}
    260193
    261194template< typename pass_type >
    262195void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
    263         VISIT_BODY( node );
     196        VISIT_BODY( node ); 
    264197}
    265198
    266199template< typename pass_type >
    267200void PassVisitor< pass_type >::visit( AsmDecl * node ) {
    268         VISIT_BODY( node );
     201        VISIT_BODY( node ); 
    269202}
    270203
     
    298231void PassVisitor< pass_type >::visit( ExprStmt * node ) {
    299232        VISIT_START( node );
     233        call_beginScope();
    300234
    301235        visitExpression( node->get_expr() );
    302236
     237        call_endScope();
    303238        VISIT_END( node );
    304239}
     
    313248}
    314249
    315 //--------------------------------------------------------------------------
    316 // AsmStmt
    317250template< typename pass_type >
    318251void PassVisitor< pass_type >::visit( AsmStmt * node ) {
    319         VISIT_BODY( node );
    320 }
    321 
    322 template< typename pass_type >
    323 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
    324         MUTATE_BODY( Statement, node );
     252        VISIT_BODY( node );
    325253}
    326254
     
    329257template< typename pass_type >
    330258void PassVisitor< pass_type >::visit( IfStmt * node ) {
    331         VISIT_START( node );
     259        VISIT_START( node ); 
    332260
    333261        visitExpression( node->get_condition() );
     
    340268template< typename pass_type >
    341269Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
    342         MUTATE_START( node );
     270        MUTATE_START( node ); 
    343271
    344272        node->set_condition( mutateExpression( node->get_condition() ) );
     
    353281template< typename pass_type >
    354282void PassVisitor< pass_type >::visit( WhileStmt * node ) {
    355         VISIT_START( node );
     283        VISIT_START( node ); 
    356284
    357285        visitExpression( node->get_condition() );
     
    363291template< typename pass_type >
    364292Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
    365         MUTATE_START( node );
     293        MUTATE_START( node ); 
    366294
    367295        node->set_condition( mutateExpression( node->get_condition() ) );
     
    372300
    373301//--------------------------------------------------------------------------
    374 // ForStmt
     302// WhileStmt
    375303template< typename pass_type >
    376304void PassVisitor< pass_type >::visit( ForStmt * node ) {
    377         VISIT_START( node );
     305        VISIT_START( node ); 
    378306
    379307        acceptAll( node->get_initialization(), *this );
     
    387315template< typename pass_type >
    388316Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
    389         MUTATE_START( node );
     317        MUTATE_START( node ); 
    390318
    391319        mutateAll( node->get_initialization(), *this );
     
    401329template< typename pass_type >
    402330void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
    403         VISIT_START( node );
     331        VISIT_START( node ); 
    404332
    405333        visitExpression( node->get_condition() );
     
    411339template< typename pass_type >
    412340Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
    413         MUTATE_START( node );
    414 
     341        MUTATE_START( node ); 
     342       
    415343        node->set_condition( mutateExpression( node->get_condition() ) );
    416344        mutateStatementList( node->get_statements() );
    417 
     345       
    418346        MUTATE_END( Statement, node );
    419347}
    420348
    421349//--------------------------------------------------------------------------
    422 // CaseStmt
     350// SwitchStmt
    423351template< typename pass_type >
    424352void PassVisitor< pass_type >::visit( CaseStmt * node ) {
    425         VISIT_START( node );
    426 
     353        VISIT_START( node ); 
     354       
    427355        visitExpression( node->get_condition() );
    428356        visitStatementList( node->get_statements() );
    429 
     357       
    430358        VISIT_END( node );
    431359}
     
    433361template< typename pass_type >
    434362Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
    435         MUTATE_START( node );
    436 
     363        MUTATE_START( node ); 
     364       
    437365        node->set_condition(  mutateExpression( node->get_condition() ) );
    438366        mutateStatementList( node->get_statements() );
    439 
     367       
    440368        MUTATE_END( Statement, node );
    441369}
    442370
    443 //--------------------------------------------------------------------------
    444 // BranchStmt
    445371template< typename pass_type >
    446372void PassVisitor< pass_type >::visit( BranchStmt * node ) {
    447         VISIT_BODY( node );
    448 }
    449 
    450 template< typename pass_type >
    451 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
    452         MUTATE_BODY( Statement, node );
     373        VISIT_BODY( node );
    453374}
    454375
     
    494415        maybeAccept( node->get_block(), *this );
    495416        acceptAll( node->get_catchers(), *this );
    496         maybeAccept( node->get_finally(), *this );
    497417
    498418        VISIT_END( node );
     
    505425        node->set_block(  maybeMutate( node->get_block(), *this ) );
    506426        mutateAll( node->get_catchers(), *this );
    507         node->set_finally( maybeMutate( node->get_finally(), *this ) );
    508 
     427       
    509428        MUTATE_END( Statement, node );
    510429}
     
    516435        VISIT_START( node );
    517436
     437        node->set_body( visitStatement( node->get_body() ) );
    518438        maybeAccept( node->get_decl(), *this );
    519         node->set_cond( visitExpression( node->get_cond() ) );
    520         node->set_body( visitStatement( node->get_body() ) );
    521439
    522440        VISIT_END( node );
     
    526444Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
    527445        MUTATE_START( node );
    528 
    529         node->set_decl( maybeMutate( node->get_decl(), *this ) );
    530         node->set_cond( mutateExpression( node->get_cond() ) );
    531         node->set_body( mutateStatement( node->get_body() ) );
    532 
     446       
     447        node->set_body(  mutateStatement( node->get_body() ) );
     448        node->set_decl(  maybeMutate( node->get_decl(), *this ) );
     449       
    533450        MUTATE_END( Statement, node );
    534451}
     
    536453template< typename pass_type >
    537454void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
    538         VISIT_BODY( node );
     455        VISIT_BODY( node ); 
    539456}
    540457
    541458template< typename pass_type >
    542459void PassVisitor< pass_type >::visit( NullStmt * node ) {
    543         VISIT_BODY( node );
     460        VISIT_BODY( node ); 
    544461}
    545462
    546463template< typename pass_type >
    547464void PassVisitor< pass_type >::visit( DeclStmt * node ) {
    548         VISIT_BODY( node );
     465        VISIT_BODY( node ); 
    549466}
    550467
    551468template< typename pass_type >
    552469void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
    553         VISIT_BODY( node );
     470        VISIT_BODY( node ); 
    554471}
    555472
    556473template< typename pass_type >
    557474void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
    558         VISIT_BODY( node );
     475        VISIT_BODY( node ); 
    559476}
    560477
     
    585502template< typename pass_type >
    586503void PassVisitor< pass_type >::visit( NameExpr * node ) {
    587         VISIT_BODY( node );
     504        VISIT_BODY( node ); 
    588505}
    589506
    590507template< typename pass_type >
    591508void PassVisitor< pass_type >::visit( CastExpr * node ) {
    592         VISIT_BODY( node );
     509        VISIT_BODY( node ); 
    593510}
    594511
    595512template< typename pass_type >
    596513void PassVisitor< pass_type >::visit( AddressExpr * node ) {
    597         VISIT_BODY( node );
     514        VISIT_BODY( node ); 
    598515}
    599516
    600517template< typename pass_type >
    601518void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
    602         VISIT_BODY( node );
     519        VISIT_BODY( node ); 
    603520}
    604521
    605522template< typename pass_type >
    606523void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
    607         VISIT_BODY( node );
     524        VISIT_BODY( node ); 
    608525}
    609526
    610527template< typename pass_type >
    611528void PassVisitor< pass_type >::visit( MemberExpr * node ) {
    612         VISIT_BODY( node );
     529        VISIT_BODY( node ); 
    613530}
    614531
    615532template< typename pass_type >
    616533void PassVisitor< pass_type >::visit( VariableExpr * node ) {
    617         VISIT_BODY( node );
     534        VISIT_BODY( node ); 
    618535}
    619536
    620537template< typename pass_type >
    621538void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
    622         VISIT_BODY( node );
     539        VISIT_BODY( node ); 
    623540}
    624541
    625542template< typename pass_type >
    626543void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
    627         VISIT_BODY( node );
     544        VISIT_BODY( node ); 
    628545}
    629546
    630547template< typename pass_type >
    631548void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
    632         VISIT_BODY( node );
     549        VISIT_BODY( node ); 
    633550}
    634551
    635552template< typename pass_type >
    636553void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
    637         VISIT_BODY( node );
     554        VISIT_BODY( node ); 
    638555}
    639556
    640557template< typename pass_type >
    641558void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
    642         VISIT_BODY( node );
     559        VISIT_BODY( node ); 
    643560}
    644561
    645562template< typename pass_type >
    646563void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
    647         VISIT_BODY( node );
     564        VISIT_BODY( node ); 
    648565}
    649566
    650567template< typename pass_type >
    651568void PassVisitor< pass_type >::visit( AttrExpr * node ) {
    652         VISIT_BODY( node );
     569        VISIT_BODY( node ); 
    653570}
    654571
    655572template< typename pass_type >
    656573void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
    657         VISIT_BODY( node );
     574        VISIT_BODY( node ); 
    658575}
    659576
    660577template< typename pass_type >
    661578void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
    662         VISIT_BODY( node );
     579        VISIT_BODY( node ); 
    663580}
    664581
    665582template< typename pass_type >
    666583void PassVisitor< pass_type >::visit( CommaExpr * node ) {
    667         VISIT_BODY( node );
     584        VISIT_BODY( node ); 
    668585}
    669586
    670587template< typename pass_type >
    671588void PassVisitor< pass_type >::visit( TypeExpr * node ) {
    672         VISIT_BODY( node );
     589        VISIT_BODY( node ); 
    673590}
    674591
    675592template< typename pass_type >
    676593void PassVisitor< pass_type >::visit( AsmExpr * node ) {
    677         VISIT_BODY( node );
     594        VISIT_BODY( node ); 
    678595}
    679596
    680597template< typename pass_type >
    681598void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
    682         VISIT_BODY( node );
     599        VISIT_BODY( node ); 
    683600}
    684601
    685602template< typename pass_type >
    686603void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
    687         VISIT_BODY( node );
     604        VISIT_BODY( node ); 
    688605}
    689606
    690607template< typename pass_type >
    691608void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
    692         VISIT_BODY( node );
     609        VISIT_BODY( node );
     610}
     611
     612template< typename pass_type >
     613void PassVisitor< pass_type >::visit( UntypedValofExpr * node ) {
     614        VISIT_BODY( node );
    693615}
    694616
    695617template< typename pass_type >
    696618void PassVisitor< pass_type >::visit( RangeExpr * node ) {
    697         VISIT_BODY( node );
     619        VISIT_BODY( node ); 
    698620}
    699621
    700622template< typename pass_type >
    701623void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
    702         VISIT_BODY( node );
     624        VISIT_BODY( node ); 
    703625}
    704626
    705627template< typename pass_type >
    706628void PassVisitor< pass_type >::visit( TupleExpr * node ) {
    707         VISIT_BODY( node );
     629        VISIT_BODY( node ); 
    708630}
    709631
    710632template< typename pass_type >
    711633void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
    712         VISIT_BODY( node );
     634        VISIT_BODY( node ); 
    713635}
    714636
    715637template< typename pass_type >
    716638void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
    717         VISIT_BODY( node );
     639        VISIT_BODY( node ); 
    718640}
    719641
     
    737659Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
    738660        MUTATE_START( node );
    739 
     661       
    740662        // don't want statements from outer CompoundStmts to be added to this StmtExpr
    741663        ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     
    750672template< typename pass_type >
    751673void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
    752         VISIT_BODY( node );
     674        VISIT_BODY( node ); 
    753675}
    754676
    755677template< typename pass_type >
    756678void PassVisitor< pass_type >::visit( VoidType * node ) {
    757         VISIT_BODY( node );
     679        VISIT_BODY( node ); 
    758680}
    759681
    760682template< typename pass_type >
    761683void PassVisitor< pass_type >::visit( BasicType * node ) {
    762         VISIT_BODY( node );
     684        VISIT_BODY( node ); 
    763685}
    764686
    765687template< typename pass_type >
    766688void PassVisitor< pass_type >::visit( PointerType * node ) {
    767         VISIT_BODY( node );
     689        VISIT_BODY( node ); 
    768690}
    769691
    770692template< typename pass_type >
    771693void PassVisitor< pass_type >::visit( ArrayType * node ) {
    772         VISIT_BODY( node );
     694        VISIT_BODY( node ); 
    773695}
    774696
    775697template< typename pass_type >
    776698void PassVisitor< pass_type >::visit( FunctionType * node ) {
    777         VISIT_BODY( node );
     699        VISIT_BODY( node ); 
    778700}
    779701
    780702template< typename pass_type >
    781703void PassVisitor< pass_type >::visit( StructInstType * node ) {
    782         VISIT_BODY( node );
     704        VISIT_BODY( node ); 
    783705}
    784706
    785707template< typename pass_type >
    786708void PassVisitor< pass_type >::visit( UnionInstType * node ) {
    787         VISIT_BODY( node );
     709        VISIT_BODY( node ); 
    788710}
    789711
    790712template< typename pass_type >
    791713void PassVisitor< pass_type >::visit( EnumInstType * node ) {
    792         VISIT_BODY( node );
     714        VISIT_BODY( node ); 
    793715}
    794716
    795717template< typename pass_type >
    796718void PassVisitor< pass_type >::visit( TraitInstType * node ) {
    797         VISIT_BODY( node );
     719        VISIT_BODY( node ); 
    798720}
    799721
    800722template< typename pass_type >
    801723void PassVisitor< pass_type >::visit( TypeInstType * node ) {
    802         VISIT_BODY( node );
     724        VISIT_BODY( node ); 
    803725}
    804726
    805727template< typename pass_type >
    806728void PassVisitor< pass_type >::visit( TupleType * node ) {
    807         VISIT_BODY( node );
     729        VISIT_BODY( node ); 
    808730}
    809731
    810732template< typename pass_type >
    811733void PassVisitor< pass_type >::visit( TypeofType * node ) {
    812         VISIT_BODY( node );
     734        VISIT_BODY( node ); 
    813735}
    814736
    815737template< typename pass_type >
    816738void PassVisitor< pass_type >::visit( AttrType * node ) {
    817         VISIT_BODY( node );
     739        VISIT_BODY( node ); 
    818740}
    819741
    820742template< typename pass_type >
    821743void PassVisitor< pass_type >::visit( VarArgsType * node ) {
    822         VISIT_BODY( node );
     744        VISIT_BODY( node ); 
    823745}
    824746
    825747template< typename pass_type >
    826748void PassVisitor< pass_type >::visit( ZeroType * node ) {
    827         VISIT_BODY( node );
     749        VISIT_BODY( node ); 
    828750}
    829751
    830752template< typename pass_type >
    831753void PassVisitor< pass_type >::visit( OneType * node ) {
    832         VISIT_BODY( node );
     754        VISIT_BODY( node ); 
    833755}
    834756
     
    855777template< typename pass_type >
    856778void PassVisitor< pass_type >::visit( ListInit * node ) {
    857         VISIT_BODY( node );
     779        VISIT_BODY( node ); 
    858780}
    859781
    860782template< typename pass_type >
    861783void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
    862         VISIT_BODY( node );
     784        VISIT_BODY( node ); 
    863785}
    864786
    865787template< typename pass_type >
    866788void PassVisitor< pass_type >::visit( Subrange * node ) {
    867         VISIT_BODY( node );
     789        VISIT_BODY( node ); 
    868790}
    869791
    870792template< typename pass_type >
    871793void PassVisitor< pass_type >::visit( Constant * node ) {
    872         VISIT_BODY( node );
     794        VISIT_BODY( node ); 
    873795}
    874796
     
    921843
    922844template< typename pass_type >
     845Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
     846        MUTATE_BODY( Statement, node );
     847}
     848
     849template< typename pass_type >
     850Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
     851        MUTATE_BODY( Statement, node );
     852}
     853
     854template< typename pass_type >
    923855Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
    924856        MUTATE_BODY( Statement, node );
     
    1056988
    1057989template< typename pass_type >
     990Expression * PassVisitor< pass_type >::mutate( UntypedValofExpr * node ) {
     991        MUTATE_BODY( Expression, node );
     992}
     993
     994template< typename pass_type >
    1058995Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
    1059996        MUTATE_BODY( Expression, node );
  • src/Common/PassVisitor.proto.h

    r4c03e63 re1c1829  
    11#pragma once
    2 
    3 template<typename pass_type>
    4 class PassVisitor;
    52
    63typedef std::function<void( void * )> cleanup_func_t;
     
    3431
    3532typedef std::function< void( cleanup_func_t, void * ) > at_cleanup_t;
    36 
    37 class bool_ref {
    38 public:
    39         bool_ref() = default;
    40         ~bool_ref() = default;
    41 
    42         operator bool() { return *m_ref; }
    43         bool operator=( bool val ) { return *m_ref = val; }
    44 
    45 private:
    46 
    47         template<typename pass>
    48         friend class PassVisitor;
    49 
    50         void set( bool & val ) { m_ref = &val; };
    51 
    52         bool * m_ref;
    53 };
    5433
    5534//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    133112FIELD_PTR( std::list< Statement* >, stmtsToAddBefore )
    134113FIELD_PTR( std::list< Statement* >, stmtsToAddAfter  )
    135 FIELD_PTR( std::list< Declaration* >, declsToAddBefore )
    136 FIELD_PTR( std::list< Declaration* >, declsToAddAfter  )
    137 FIELD_PTR( bool_ref, visit_children )
     114FIELD_PTR( bool, skip_children )
    138115FIELD_PTR( at_cleanup_t, at_cleanup )
    139 FIELD_PTR( PassVisitor<pass_type> * const, visitor )
  • src/GenPoly/Box.cc

    r4c03e63 re1c1829  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 15:49:59 2017
    13 // Update Count     : 346
     12// Last Modified On : Sat May 13 09:26:38 2017
     13// Update Count     : 341
    1414//
    1515
     
    6262namespace GenPoly {
    6363        namespace {
     64                const std::list<Label> noLabels;
     65
    6466                FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars );
    6567
     
    341343        Statement *makeAlignTo( Expression *lhs, Expression *rhs ) {
    342344                // check that the lhs is zeroed out to the level of rhs
    343                 Expression *ifCond = makeOp( "?&?", lhs, makeOp( "?-?", rhs, new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
     345                Expression *ifCond = makeOp( "?&?", lhs, makeOp( "?-?", rhs, new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "1" ) ) ) );
    344346                // if not aligned, increment to alignment
    345347                Expression *ifExpr = makeOp( "?+=?", lhs->clone(), makeOp( "?-?", rhs->clone(), ifCond->clone() ) );
     
    384386
    385387                // initialize size and alignment to 0 and 1 (will have at least one member to re-edit size)
    386                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant::from_ulong( 0 ) ) ) );
    387                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
     388                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "0" ) ) ) );
     389                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
    388390                unsigned long n_members = 0;
    389391                bool firstMember = true;
     
    441443
    442444                // calculate union layout in function body
    443                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    444                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
     445                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
     446                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
    445447                for ( std::list< Declaration* >::const_iterator member = unionDecl->get_members().begin(); member != unionDecl->get_members().end(); ++member ) {
    446448                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );
     
    15641566                /// Returns an index expression into the offset array for a type
    15651567                Expression *makeOffsetIndex( Type *objectType, long i ) {
    1566                         ConstantExpr *fieldIndex = new ConstantExpr( Constant::from_ulong( i ) );
     1568                        std::stringstream offset_namer;
     1569                        offset_namer << i;
     1570                        ConstantExpr *fieldIndex = new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), offset_namer.str() ) );
    15671571                        UntypedExpr *fieldOffset = new UntypedExpr( new NameExpr( "?[?]" ) );
    15681572                        fieldOffset->get_args().push_back( new NameExpr( offsetofName( mangleType( objectType ) ) ) );
     
    17771781                                // all union members are at offset zero
    17781782                                delete offsetofExpr;
    1779                                 return new ConstantExpr( Constant::from_ulong( 0 ) );
     1783                                return new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "0" ) );
    17801784                        } else return offsetofExpr;
    17811785                }
  • src/GenPoly/CopyParams.cc

    r4c03e63 re1c1829  
    4545
    4646        CopyParams::CopyParams() : namer( "_cp" ) {}
     47
     48        static const std::list< Label > noLabels;
    4749
    4850        void CopyParams::visit( FunctionDecl *funcDecl ) {
  • src/GenPoly/DeclMutator.cc

    r4c03e63 re1c1829  
    99// Author           : Aaron B. Moss
    1010// Created On       : Fri Nov 27 14:44:00 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jun 22 13:49:00 2017
    13 // Update Count     : 4
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Aug  4 11:16:43 2016
     13// Update Count     : 3
    1414//
    1515
     
    2020
    2121namespace GenPoly {
     22        namespace {
     23                const std::list<Label> noLabels;
     24        }
     25
    2226        DeclMutator::DeclMutator() : Mutator(), declsToAdd(1), declsToAddAfter(1) {}
    2327
    2428        DeclMutator::~DeclMutator() {}
    25 
     29       
    2630        void DeclMutator::mutateDeclarationList( std::list< Declaration* > &decls ) {
    2731                for ( std::list< Declaration* >::iterator decl = decls.begin(); ; ++decl ) {
     
    3034
    3135                        if ( decl == decls.end() ) break;
    32 
     36                       
    3337                        // run mutator on declaration
    3438                        *decl = maybeMutate( *decl, *this );
     
    5155                newBack->splice( newBack->end(), *back );
    5256                declsToAdd.pop_back();
    53 
     57               
    5458                back = declsToAddAfter.rbegin();
    5559                newBack = back + 1;
     
    6266                CompoundStmt *compoundStmt = dynamic_cast< CompoundStmt* >(stmt);
    6367                if ( compoundStmt ) return mutate( compoundStmt );
    64 
     68               
    6569                doBeginScope();
    66 
     70               
    6771                // run mutator on statement
    6872                stmt = maybeMutate( stmt, *this );
     
    98102                doBeginScope();
    99103
    100 
     104               
    101105                for ( std::list< Statement* >::iterator stmt = stmts.begin(); ; ++stmt ) {
    102106                        // add any new declarations after the previous statement
     
    108112
    109113                        if ( stmt == stmts.end() ) break;
    110 
     114                       
    111115                        // run mutator on statement
    112116                        *stmt = maybeMutate( *stmt, *this );
     
    119123                        declsToAdd.back().clear();
    120124                }
    121 
     125               
    122126                doEndScope();
    123127        }
     
    135139                return compoundStmt;
    136140        }
    137 
     141       
    138142        Statement* DeclMutator::mutate(IfStmt *ifStmt) {
    139143                ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) );
     
    142146                return ifStmt;
    143147        }
    144 
     148       
    145149        Statement* DeclMutator::mutate(WhileStmt *whileStmt) {
    146150                whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) );
     
    148152                return whileStmt;
    149153        }
    150 
     154       
    151155        Statement* DeclMutator::mutate(ForStmt *forStmt) {
    152156                mutateAll( forStmt->get_initialization(), *this );
     
    156160                return forStmt;
    157161        }
    158 
     162       
    159163        Statement* DeclMutator::mutate(SwitchStmt *switchStmt) {
    160164                switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
     
    162166                return switchStmt;
    163167        }
    164 
     168       
    165169        Statement* DeclMutator::mutate(CaseStmt *caseStmt) {
    166170                caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
     
    168172                return caseStmt;
    169173        }
    170 
     174       
    171175        Statement* DeclMutator::mutate(TryStmt *tryStmt) {
    172176                tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
     
    175179                return tryStmt;
    176180        }
    177 
     181       
    178182        Statement* DeclMutator::mutate(CatchStmt *catchStmt) {
    179183                catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
    180                 catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
    181184                catchStmt->set_body( mutateStatement( catchStmt->get_body() ) );
    182185                return catchStmt;
  • src/GenPoly/Lvalue.cc

    r4c03e63 re1c1829  
    3535namespace GenPoly {
    3636        namespace {
     37                const std::list<Label> noLabels;
     38
    3739                /// Replace uses of lvalue returns with appropriate pointers
    3840                class Pass1 : public Mutator {
  • src/GenPoly/PolyMutator.cc

    r4c03e63 re1c1829  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jun 22 13:47:00 2017
    13 // Update Count     : 17
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Aug  4 11:26:22 2016
     13// Update Count     : 16
    1414//
    1515
     
    123123
    124124        Statement * PolyMutator::mutate(TryStmt *tryStmt) {
    125                 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
     125                tryStmt->set_block(  maybeMutate( tryStmt->get_block(), *this ) );
    126126                mutateAll( tryStmt->get_catchers(), *this );
    127                 tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
    128127                return tryStmt;
    129128        }
    130129
    131130        Statement * PolyMutator::mutate(CatchStmt *cathStmt) {
    132                 cathStmt->set_body( mutateStatement( cathStmt->get_body() ) );
    133                 cathStmt->set_cond( maybeMutate( cathStmt->get_cond(), *this ) );
    134                 cathStmt->set_decl( maybeMutate( cathStmt->get_decl(), *this ) );
     131                cathStmt->set_body(  mutateStatement( cathStmt->get_body() ) );
     132                cathStmt->set_decl(  maybeMutate( cathStmt->get_decl(), *this ) );
    135133                return cathStmt;
    136134        }
  • src/GenPoly/Specialize.cc

    r4c03e63 re1c1829  
    9999                if ( FunctionType * fftype = getFunctionType( formalType ) ) {
    100100                        if ( fftype->isTtype() ) return true;
    101                         // conversion of 0 (null) to function type does not require tuple specialization
    102                         if ( dynamic_cast< ZeroType * >( actualType ) ) return false;
    103101                        FunctionType * aftype = getFunctionType( actualType );
    104102                        assertf( aftype, "formal type is a function type, but actual type is not." );
  • src/InitTweak/FixGlobalInit.cc

    r4c03e63 re1c1829  
    2626
    2727namespace InitTweak {
     28        namespace {
     29                const std::list<Label> noLabels;
     30        }
     31
    2832        class GlobalFixer : public Visitor {
    2933          public:
  • src/InitTweak/FixInit.cc

    r4c03e63 re1c1829  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 17:35:05 2017
    13 // Update Count     : 74
     12// Last Modified On : Fri Mar 17 09:13:47 2017
     13// Update Count     : 71
    1414//
    1515
     
    5656                typedef std::unordered_map< int, int > UnqCount;
    5757
    58                 class InsertImplicitCalls : public WithTypeSubstitution {
     58                class InsertImplicitCalls {
    5959                public:
    6060                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
     
    6969                        // collects environments for relevant nodes
    7070                        EnvMap & envMap;
     71                        TypeSubstitution * env; //Magically populated by the PassVisitor
    7172                };
    7273
     
    191192                };
    192193
    193                 class FixInit : public WithStmtsToAdd {
     194                class FixInit {
    194195                  public:
    195196                        /// expand each object declaration to use its constructor after it is declared.
     
    199200
    200201                        std::list< Declaration * > staticDtorDecls;
     202                        std::list< Statement * > stmtsToAddAfter; // found by PassVisitor
    201203                };
    202204
     
    724726                                                // static bool __objName_uninitialized = true
    725727                                                BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
    726                                                 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant::from_int( 1 ) ), noDesignators );
     728                                                SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators );
    727729                                                ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );
    728730                                                isUninitializedVar->fixUniqueId();
     
    731733                                                UntypedExpr * setTrue = new UntypedExpr( new NameExpr( "?=?" ) );
    732734                                                setTrue->get_args().push_back( new VariableExpr( isUninitializedVar ) );
    733                                                 setTrue->get_args().push_back( new ConstantExpr( Constant::from_int( 0 ) ) );
     735                                                setTrue->get_args().push_back( new ConstantExpr( Constant( boolType->clone(), "0" ) ) );
    734736
    735737                                                // generate body of if
  • src/InitTweak/GenInit.cc

    r4c03e63 re1c1829  
    2121
    2222#include "Common/PassVisitor.h"
    23 
    24 #include "GenPoly/DeclMutator.h"
    25 #include "GenPoly/PolyMutator.h"
    26 #include "GenPoly/ScopedSet.h"
    27 
    28 #include "ResolvExpr/typeops.h"
    2923
    3024#include "SynTree/Declaration.h"
     
    3731#include "SymTab/Autogen.h"
    3832#include "SymTab/Mangler.h"
     33
     34#include "GenPoly/DeclMutator.h"
     35#include "GenPoly/PolyMutator.h"
     36#include "GenPoly/ScopedSet.h"
     37
     38#include "ResolvExpr/typeops.h"
    3939
    4040namespace InitTweak {
  • src/InitTweak/InitTweak.cc

    r4c03e63 re1c1829  
    474474        public:
    475475                ConstExprChecker() : isConstExpr( true ) {}
    476 
    477                 using Visitor::visit;
    478476
    479477                virtual void visit( __attribute((unused)) ApplicationExpr *applicationExpr ) { isConstExpr = false; }
  • src/Parser/ExpressionNode.cc

    r4c03e63 re1c1829  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 16:44:46 2017
    13 // Update Count     : 541
     12// Last Modified On : Wed May 17 21:31:01 2017
     13// Update Count     : 527
    1414//
    1515
     
    6262        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
    6363        int size;                                                                                       // 0 => int, 1 => long, 2 => long long
    64         unsigned long long int v;                                                               // converted integral value
     64        unsigned long long v;                                                           // converted integral value
    6565        size_t last = str.length() - 1;                                         // last character of constant
    6666
     
    118118        } // if
    119119
    120         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str, v ) );
     120        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str ) );
    121121        delete &str;                                                                            // created by lex
    122122        return ret;
     
    133133        // floating-point constant has minimum of 2 characters: 1. or .1
    134134        size_t last = str.length() - 1;
    135         double v;
    136 
    137         sscanf( str.c_str(), "%lg", &v );
    138135
    139136        if ( checkI( str[last] ) ) {                                            // imaginary ?
     
    153150        } // if
    154151
    155         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str, v ) );
     152        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str ) );
    156153        delete &str;                                                                            // created by lex
    157154        return ret;
     
    159156
    160157Expression *build_constantChar( const std::string & str ) {
    161         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
     158        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str ) );
    162159        delete &str;                                                                            // created by lex
    163160        return ret;
     
    167164        // string should probably be a primitive type
    168165        ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    169                                                                    new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ),  // +1 for '\0' and -2 for '"'
     166                                new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::UnsignedInt ),
     167                                                                                        toString( str.size()+1-2 ) ) ),  // +1 for '\0' and -2 for '"'
    170168                                                                   false, false );
    171         // constant 0 is ignored for pure string value
    172         ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) );
     169        ConstantExpr * ret = new ConstantExpr( Constant( at, str ) );
    173170        delete &str;                                                                            // created by lex
    174171        return ret;
     
    176173
    177174Expression *build_constantZeroOne( const std::string & str ) {
    178         Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str,
    179                                                                                                    str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
     175        Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str ) );
    180176        delete &str;                                                                            // created by lex
    181177        return ret;
     
    188184        std::stringstream ss( str );
    189185        ss >> a >> dot >> b;
    190         UntypedMemberExpr * ret = new UntypedMemberExpr( new ConstantExpr( Constant::from_int( b ) ), new ConstantExpr( Constant::from_int( a ) ) );
     186        UntypedMemberExpr * ret = new UntypedMemberExpr(
     187                new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( b ) ) ),
     188                new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( a ) ) ) );
    191189        delete &str;
    192190        return ret;
     
    348346
    349347Expression *build_valexpr( StatementNode *s ) {
    350         return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) );
     348        return new UntypedValofExpr( maybeMoveBuild< Statement >(s), nullptr );
    351349}
    352350Expression *build_typevalue( DeclarationNode *decl ) {
  • src/Parser/ParseNode.h

    r4c03e63 re1c1829  
    415415                                result->location = cur->location;
    416416                                * out++ = result;
    417                         } else {
    418                                 assertf(false, "buildList unknown type");
    419417                        } // if
    420418                } catch( SemanticError &e ) {
  • src/Parser/StatementNode.cc

    r4c03e63 re1c1829  
    168168
    169169Statement *build_resume_at( ExpressionNode *ctl, ExpressionNode *target ) {
    170         (void)ctl;
    171         (void)target;
    172         assertf( false, "resume at (non-local throw) is not yet supported," );
     170        std::list< Expression * > exps;
     171        buildMoveList( ctl, exps );
     172        assertf( exps.size() < 2, "This means we are leaking memory");
     173        return new ThrowStmt( noLabels, ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr );
    173174}
    174175
    175176Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
    176         std::list< CatchStmt * > branches;
    177         buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
     177        std::list< Statement * > branches;
     178        buildMoveList< Statement, StatementNode >( catch_stmt, branches );
    178179        CompoundStmt *tryBlock = safe_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    179180        FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
  • src/Parser/parseutility.cc

    r4c03e63 re1c1829  
    1010// Created On       : Sat May 16 15:30:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 15:33:41 2017
    13 // Update Count     : 5
     12// Last Modified On : Sun Aug 14 23:45:03 2016
     13// Update Count     : 3
    1414//
    1515
     
    2626        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    2727        comparison->get_args().push_back( orig );
    28         comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0", (unsigned long long int)0 ) ) );
     28        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) ) );
    2929        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    3030}
  • src/SymTab/Autogen.h

    r4c03e63 re1c1829  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 17:25:26 2017
    13 // Update Count     : 14
     12// Last Modified On : Fri Mar 17 09:10:41 2017
     13// Update Count     : 9
    1414//
    1515
     
    2525
    2626namespace SymTab {
    27     /// Generates assignment operators, constructors, and destructor for aggregate types as required
    28     void autogenerateRoutines( std::list< Declaration * > &translationUnit );
     27        /// Generates assignment operators, constructors, and destructor for aggregate types as required
     28        void autogenerateRoutines( std::list< Declaration * > &translationUnit );
    2929
    30     /// returns true if obj's name is the empty string and it has a bitfield width
    31     bool isUnnamedBitfield( ObjectDecl * obj );
     30        /// returns true if obj's name is the empty string and it has a bitfield width
     31        bool isUnnamedBitfield( ObjectDecl * obj );
    3232
    33     /// size_t type - set when size_t typedef is seen. Useful in a few places,
    34     /// such as in determining array dimension type
    35     extern Type * SizeType;
     33        /// size_t type - set when size_t typedef is seen. Useful in a few places,
     34        /// such as in determining array dimension type
     35        extern Type * SizeType;
    3636
    37     /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    38     template< typename OutputIterator >
     37        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
     38        template< typename OutputIterator >
    3939        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true );
    4040
    41     /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
    42     /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
    43     template< typename OutputIterator >
     41        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
     42        /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
     43        template< typename OutputIterator >
    4444        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {
    45         // want to be able to generate assignment, ctor, and dtor generically,
    46         // so fname is either ?=?, ?{}, or ^?{}
    47         UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
     45                // want to be able to generate assignment, ctor, and dtor generically,
     46                // so fname is either ?=?, ?{}, or ^?{}
     47                UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
    4848
    49         // do something special for unnamed members
    50         dstParam = new AddressExpr( dstParam );
    51         if ( addCast ) {
    52             // cast to T* with qualifiers removed, so that qualified objects can be constructed
    53             // and destructed with the same functions as non-qualified objects.
    54             // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
    55             // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
    56             // remove lvalue as a qualifier, this can change to
    57             //   type->get_qualifiers() = Type::Qualifiers();
    58             assert( type );
    59             Type * castType = type->clone();
     49                // do something special for unnamed members
     50                dstParam = new AddressExpr( dstParam );
     51                if ( addCast ) {
     52                        // cast to T* with qualifiers removed, so that qualified objects can be constructed
     53                        // and destructed with the same functions as non-qualified objects.
     54                        // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
     55                        // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
     56                        // remove lvalue as a qualifier, this can change to
     57                        //   type->get_qualifiers() = Type::Qualifiers();
     58                        assert( type );
     59                        Type * castType = type->clone();
    6060//                      castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
    61             castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    62             castType->set_lvalue( true ); // xxx - might not need this
    63             dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
    64         }
    65         fExpr->get_args().push_back( dstParam );
     61                        castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
     62                        castType->set_lvalue( true ); // xxx - might not need this
     63                        dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
     64                }
     65                fExpr->get_args().push_back( dstParam );
    6666
    67         Statement * listInit = srcParam.buildListInit( fExpr );
     67                Statement * listInit = srcParam.buildListInit( fExpr );
    6868
    69         std::list< Expression * > args = *++srcParam;
    70         fExpr->get_args().splice( fExpr->get_args().end(), args );
     69                std::list< Expression * > args = *++srcParam;
     70                fExpr->get_args().splice( fExpr->get_args().end(), args );
    7171
    72         *out++ = new ExprStmt( noLabels, fExpr );
     72                *out++ = new ExprStmt( noLabels, fExpr );
    7373
    74         srcParam.clearArrayIndices();
     74                srcParam.clearArrayIndices();
    7575
    76         return listInit;
    77     }
    78 
    79     /// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments.
    80     /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
    81     template< typename OutputIterator >
    82         void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
    83         static UniqueName indexName( "_index" );
    84 
    85         // for a flexible array member nothing is done -- user must define own assignment
    86         if ( ! array->get_dimension() ) return ;
    87 
    88         Expression * begin, * end, * update, * cmp;
    89         if ( forward ) {
    90             // generate: for ( int i = 0; i < N; ++i )
    91             begin = new ConstantExpr( Constant::from_int( 0 ) );
    92             end = array->get_dimension()->clone();
    93             cmp = new NameExpr( "?<?" );
    94             update = new NameExpr( "++?" );
    95         } else {
    96             // generate: for ( int i = N-1; i >= 0; --i )
    97             begin = new UntypedExpr( new NameExpr( "?-?" ) );
    98             ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() );
    99             ((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant::from_int( 1 ) ) );
    100             end = new ConstantExpr( Constant::from_int( 0 ) );
    101             cmp = new NameExpr( "?>=?" );
    102             update = new NameExpr( "--?" );
     76                return listInit;
    10377        }
    10478
    105         ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
     79        /// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments.
     80        /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
     81        template< typename OutputIterator >
     82        void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
     83                static UniqueName indexName( "_index" );
    10684
    107         UntypedExpr *cond = new UntypedExpr( cmp );
    108         cond->get_args().push_back( new VariableExpr( index ) );
    109         cond->get_args().push_back( end );
     85                // for a flexible array member nothing is done -- user must define own assignment
     86                if ( ! array->get_dimension() ) return ;
    11087
    111         UntypedExpr *inc = new UntypedExpr( update );
    112         inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
     88                Expression * begin, * end, * update, * cmp;
     89                if ( forward ) {
     90                        // generate: for ( int i = 0; i < 0; ++i )
     91                        begin = new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) );
     92                        end = array->get_dimension()->clone();
     93                        cmp = new NameExpr( "?<?" );
     94                        update = new NameExpr( "++?" );
     95                } else {
     96                        // generate: for ( int i = N-1; i >= 0; --i )
     97                        begin = new UntypedExpr( new NameExpr( "?-?" ) );
     98                        ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() );
     99                        ((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant( new OneType( emptyQualifiers ), "1" ) ) );
     100                        end = new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) );
     101                        cmp = new NameExpr( "?>=?" );
     102                        update = new NameExpr( "--?" );
     103                }
    113104
    114         UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
    115         dstIndex->get_args().push_back( dstParam );
    116         dstIndex->get_args().push_back( new VariableExpr( index ) );
    117         dstParam = dstIndex;
     105                ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
    118106
    119         // srcParam must keep track of the array indices to build the
    120         // source parameter and/or array list initializer
    121         srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() );
     107                UntypedExpr *cond = new UntypedExpr( cmp );
     108                cond->get_args().push_back( new VariableExpr( index ) );
     109                cond->get_args().push_back( end );
    122110
    123         // for stmt's body, eventually containing call
    124         CompoundStmt * body = new CompoundStmt( noLabels );
    125         Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward );
     111                UntypedExpr *inc = new UntypedExpr( update );
     112                inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
    126113
    127         // block containing for stmt and index variable
    128         std::list<Statement *> initList;
    129         CompoundStmt * block = new CompoundStmt( noLabels );
    130         block->get_kids().push_back( new DeclStmt( noLabels, index ) );
    131         if ( listInit ) block->get_kids().push_back( listInit );
    132         block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) );
     114                UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
     115                dstIndex->get_args().push_back( dstParam );
     116                dstIndex->get_args().push_back( new VariableExpr( index ) );
     117                dstParam = dstIndex;
    133118
    134         *out++ = block;
    135     }
     119                // srcParam must keep track of the array indices to build the
     120                // source parameter and/or array list initializer
     121                srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() );
    136122
    137     template< typename OutputIterator >
     123                // for stmt's body, eventually containing call
     124                CompoundStmt * body = new CompoundStmt( noLabels );
     125                Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward );
     126
     127                // block containing for stmt and index variable
     128                std::list<Statement *> initList;
     129                CompoundStmt * block = new CompoundStmt( noLabels );
     130                block->get_kids().push_back( new DeclStmt( noLabels, index ) );
     131                if ( listInit ) block->get_kids().push_back( listInit );
     132                block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) );
     133
     134                *out++ = block;
     135        }
     136
     137        template< typename OutputIterator >
    138138        Statement * genCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {
    139         if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
    140             genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
    141             return 0;
    142         } else {
    143             return genScalarCall( srcParam, dstParam, fname, out, type, addCast );
     139                if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
     140                        genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
     141                        return 0;
     142                } else {
     143                        return genScalarCall( srcParam, dstParam, fname, out, type, addCast );
     144                }
    144145        }
    145     }
    146146
    147     /// inserts into out a generated call expression to function fname with arguments dstParam
    148     /// and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. decl is the
    149     /// object being constructed. The function wraps constructor and destructor calls in an
    150     /// ImplicitCtorDtorStmt node.
    151     template< typename OutputIterator >
     147        /// inserts into out a generated call expression to function fname with arguments dstParam
     148        /// and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. decl is the
     149        /// object being constructed. The function wraps constructor and destructor calls in an
     150        /// ImplicitCtorDtorStmt node.
     151        template< typename OutputIterator >
    152152        void genImplicitCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, DeclarationWithType * decl, bool forward = true ) {
    153         ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl );
    154         assert( obj );
    155         // unnamed bit fields are not copied as they cannot be accessed
    156         if ( isUnnamedBitfield( obj ) ) return;
     153                ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl );
     154                assert( obj );
     155                // unnamed bit fields are not copied as they cannot be accessed
     156                if ( isUnnamedBitfield( obj ) ) return;
    157157
    158         bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) );
    159         std::list< Statement * > stmts;
    160         genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward );
     158                bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) );
     159                std::list< Statement * > stmts;
     160                genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward );
    161161
    162         // currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call
    163         assert( stmts.size() <= 1 );
    164         if ( stmts.size() == 1 ) {
    165             Statement * callStmt = stmts.front();
    166             if ( addCast ) {
    167                 // implicitly generated ctor/dtor calls should be wrapped
    168                 // so that later passes are aware they were generated.
    169                 // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield,
    170                 // because this causes the address to be taken at codegen, which is illegal in C.
    171                 callStmt = new ImplicitCtorDtorStmt( callStmt );
    172             }
    173             *out++ = callStmt;
     162                // currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call
     163                assert( stmts.size() <= 1 );
     164                if ( stmts.size() == 1 ) {
     165                        Statement * callStmt = stmts.front();
     166                        if ( addCast ) {
     167                                // implicitly generated ctor/dtor calls should be wrapped
     168                                // so that later passes are aware they were generated.
     169                                // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield,
     170                                // because this causes the address to be taken at codegen, which is illegal in C.
     171                                callStmt = new ImplicitCtorDtorStmt( callStmt );
     172                        }
     173                        *out++ = callStmt;
     174                }
    174175        }
    175     }
    176176} // namespace SymTab
    177177#endif // AUTOGEN_H
  • src/SymTab/Indexer.cc

    r4c03e63 re1c1829  
    493493                acceptNewScope( compLitExpr->get_result(), *this );
    494494                maybeAccept( compLitExpr->get_initializer(), *this );
     495        }
     496
     497        void Indexer::visit( UntypedValofExpr *valofExpr ) {
     498                acceptNewScope( valofExpr->get_result(), *this );
     499                maybeAccept( valofExpr->get_body(), *this );
    495500        }
    496501
  • src/SymTab/Indexer.h

    r4c03e63 re1c1829  
    6969                virtual void visit( ConstructorExpr * ctorExpr );
    7070                virtual void visit( CompoundLiteralExpr *compLitExpr );
     71                virtual void visit( UntypedValofExpr *valofExpr );
    7172                virtual void visit( RangeExpr *rangeExpr );
    7273                virtual void visit( UntypedTupleExpr *tupleExpr );
  • src/SymTab/Validate.cc

    r4c03e63 re1c1829  
    6666#include "ResolvExpr/typeops.h"
    6767
    68 #include "SynTree/Attribute.h"
    6968#include "SynTree/Expression.h"
    7069#include "SynTree/Mutator.h"
     
    115114
    116115        /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers.
    117         class EnumAndPointerDecay {
    118         public:
    119                 void previsit( EnumDecl *aggregateDecl );
    120                 void previsit( FunctionType *func );
     116        class EnumAndPointerDecayPass final : public Visitor {
     117                typedef Visitor Parent;
     118                virtual void visit( EnumDecl *aggregateDecl );
     119                virtual void visit( FunctionType *func );
    121120        };
    122121
     
    126125          public:
    127126                LinkReferenceToTypes( bool doDebug, const Indexer *indexer );
     127          private:
    128128                using Parent::visit;
    129129                void visit( EnumInstType *enumInst ) final;
     
    135135                void visit( UnionDecl *unionDecl ) final;
    136136                void visit( TypeInstType *typeInst ) final;
    137           private:
     137
    138138                const Indexer *indexer;
    139139
     
    146146        };
    147147
    148         /// Replaces array and function types in forall lists by appropriate pointer type and assigns each Object and Function declaration a unique ID.
    149         class ForallPointerDecay final : public Indexer {
     148        /// Replaces array and function types in forall lists by appropriate pointer type
     149        class Pass3 final : public Indexer {
    150150                typedef Indexer Parent;
    151151          public:
    152152                using Parent::visit;
    153                 ForallPointerDecay( const Indexer *indexer );
    154 
     153                Pass3( const Indexer *indexer );
     154          private:
    155155                virtual void visit( ObjectDecl *object ) override;
    156156                virtual void visit( FunctionDecl *func ) override;
     
    159159        };
    160160
    161         class ReturnChecker : public WithScopes {
     161        class ReturnChecker {
    162162          public:
    163163                /// Checks that return statements return nothing if their return type is void
     
    166166          private:
    167167                void previsit( FunctionDecl * functionDecl );
     168                void postvisit( FunctionDecl * functionDecl );
    168169                void previsit( ReturnStmt * returnStmt );
    169170
    170171                typedef std::list< DeclarationWithType * > ReturnVals;
    171172                ReturnVals returnVals;
     173                std::stack< ReturnVals > returnValsStack;
    172174        };
    173175
     
    245247
    246248        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    247                 PassVisitor<EnumAndPointerDecay> epc;
     249                EnumAndPointerDecayPass epc;
    248250                LinkReferenceToTypes lrt( doDebug, 0 );
    249                 ForallPointerDecay fpd( 0 );
     251                Pass3 pass3( 0 );
    250252                CompoundLiteral compoundliteral;
    251253                PassVisitor<ValidateGenericParameters> genericParams;
     
    259261                VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
    260262                Concurrency::applyKeywords( translationUnit );
    261                 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay
     263                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecayPass
    262264                Concurrency::implementMutexFuncs( translationUnit );
    263265                Concurrency::implementThreadStarter( translationUnit );
    264266                ReturnChecker::checkFunctionReturns( translationUnit );
    265267                compoundliteral.mutateDeclarationList( translationUnit );
    266                 acceptAll( translationUnit, fpd );
     268                acceptAll( translationUnit, pass3 );
    267269                ArrayLength::computeLength( translationUnit );
    268270        }
    269271
    270272        void validateType( Type *type, const Indexer *indexer ) {
    271                 PassVisitor<EnumAndPointerDecay> epc;
     273                EnumAndPointerDecayPass epc;
    272274                LinkReferenceToTypes lrt( false, indexer );
    273                 ForallPointerDecay fpd( indexer );
     275                Pass3 pass3( indexer );
    274276                type->accept( epc );
    275277                type->accept( lrt );
    276                 type->accept( fpd );
     278                type->accept( pass3 );
    277279        }
    278280
     
    353355        }
    354356
    355         void EnumAndPointerDecay::previsit( EnumDecl *enumDecl ) {
     357        void EnumAndPointerDecayPass::visit( EnumDecl *enumDecl ) {
    356358                // Set the type of each member of the enumeration to be EnumConstant
    357359                for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
     
    360362                        obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) );
    361363                } // for
     364                Parent::visit( enumDecl );
    362365        }
    363366
     
    366369                void fixFunctionList( DWTList & dwts, FunctionType * func ) {
    367370                        // the only case in which "void" is valid is where it is the only one in the list; then it should be removed
    368                         // entirely. other fix ups are handled by the FixFunction class
     371                        // entirely other fix ups are handled by the FixFunction class
    369372                        typedef typename DWTList::iterator DWTIterator;
    370373                        DWTIterator begin( dwts.begin() ), end( dwts.end() );
     
    385388                                for ( ; i != end; ++i ) {
    386389                                        FixFunction fixer;
    387                                         *i = (*i)->acceptMutator( fixer );
     390                                        *i = (*i )->acceptMutator( fixer );
    388391                                        if ( fixer.get_isVoid() ) {
    389392                                                throw SemanticError( "invalid type void in function type ", func );
     
    394397        }
    395398
    396         void EnumAndPointerDecay::previsit( FunctionType *func ) {
     399        void EnumAndPointerDecayPass::visit( FunctionType *func ) {
    397400                // Fix up parameters and return types
    398401                fixFunctionList( func->get_parameters(), func );
    399402                fixFunctionList( func->get_returnVals(), func );
     403                Visitor::visit( func );
    400404        }
    401405
     
    544548        }
    545549
    546         ForallPointerDecay::ForallPointerDecay( const Indexer *other_indexer ) :  Indexer( false ) {
     550        Pass3::Pass3( const Indexer *other_indexer ) :  Indexer( false ) {
    547551                if ( other_indexer ) {
    548552                        indexer = other_indexer;
     
    582586        }
    583587
    584         void ForallPointerDecay::visit( ObjectDecl *object ) {
     588        void Pass3::visit( ObjectDecl *object ) {
    585589                forallFixer( object->get_type() );
    586590                if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) {
     
    591595        }
    592596
    593         void ForallPointerDecay::visit( FunctionDecl *func ) {
     597        void Pass3::visit( FunctionDecl *func ) {
    594598                forallFixer( func->get_type() );
    595599                Parent::visit( func );
     
    603607
    604608        void ReturnChecker::previsit( FunctionDecl * functionDecl ) {
    605                 GuardValue( returnVals );
     609                returnValsStack.push( returnVals );
    606610                returnVals = functionDecl->get_functionType()->get_returnVals();
     611        }
     612        void ReturnChecker::postvisit( __attribute__((unused)) FunctionDecl * functionDecl ) {
     613                returnVals = returnValsStack.top();
     614                returnValsStack.pop();
    607615        }
    608616
     
    919927                                ret->set_name( toString( "_retval_", CodeGen::genName( functionDecl ) ) );
    920928                        }
    921                         ret->get_attributes().push_back( new Attribute( "unused" ) );
    922929                }
    923930        }
  • src/SynTree/Attribute.h

    r4c03e63 re1c1829  
    4040};
    4141
    42 const std::list< Attribute * > noAttributes;
    43 
    4442#endif
    4543
  • src/SynTree/BaseSyntaxNode.h

    r4c03e63 re1c1829  
    2424        CodeLocation location;
    2525
    26         virtual ~BaseSyntaxNode() {}
    27 
    28         virtual void accept( Visitor & v ) = 0;
     26        virtual void accept( Visitor & v ) = 0; // temporary -- needs to be here so that BaseSyntaxNode is polymorphic and can be dynamic_cast
    2927};
    3028
  • src/SynTree/Constant.cc

    r4c03e63 re1c1829  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Jun 22 10:11:00 2017
    13 // Update Count     : 28
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 30 15:18:38 2015
     13// Update Count     : 12
    1414//
    1515
     
    2121#include "Type.h"
    2222
    23 Constant::Constant( Type * type, std::string rep, unsigned long long val ) : type( type ), rep( rep ), val( val ) {}
    24 Constant::Constant( Type * type, std::string rep, double val ) : type( type ), rep( rep ), val( val ) {}
     23Constant::Constant( Type *type_, std::string value_ ) : type( type_ ), value( value_ ) {}
    2524
    26 Constant::Constant( const Constant &other ) : rep( other.rep ), val( other.val ) {
     25Constant::Constant( const Constant &other ) {
    2726        type = other.type->clone();
     27        value = other.value;
    2828}
    2929
    3030Constant::~Constant() { delete type; }
    3131
    32 Constant Constant::from_bool( bool b ) {
    33         return Constant( new BasicType( Type::Qualifiers(), BasicType::Bool ), b ? "1" : "0" , (unsigned long long int)b );
    34 }
    35 
    3632Constant Constant::from_int( int i ) {
    37         return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ), (unsigned long long int)i );
     33        return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) );
    3834}
    3935
    4036Constant Constant::from_ulong( unsigned long i ) {
    41         return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ), (unsigned long long int)i );
     37        return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) );
    4238}
    4339
    4440Constant Constant::from_double( double d ) {
    45         return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ), d );
     41        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) );
    4642}
    4743
     44Constant *Constant::clone() const { assert( false ); return 0; }
     45
    4846void Constant::print( std::ostream &os ) const {
    49         os << "(" << rep << " " << val.ival;
     47        os << "(" << value;
    5048        if ( type ) {
    5149                os << ": ";
  • src/SynTree/Constant.h

    r4c03e63 re1c1829  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Jun 22 10:13:00 2017
    13 // Update Count     : 15
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jun 30 13:33:17 2016
     13// Update Count     : 6
    1414//
    1515
     
    2323class Constant {
    2424  public:
    25         Constant( Type * type, std::string rep, unsigned long long val );
    26         Constant( Type * type, std::string rep, double val );
    27         Constant( const Constant & other );
     25        Constant( Type *type, std::string value );
     26        Constant( const Constant &other );
    2827        virtual ~Constant();
    2928
    30         Type * get_type() { return type; }
    31         void set_type( Type * newValue ) { type = newValue; }
    32         std::string & get_value() { return rep; }
    33         void set_value( std::string newValue ) { rep = newValue; }
     29        Type *get_type() { return type; }
     30        void set_type( Type *newValue ) { type = newValue; }
     31        std::string &get_value() { return value; }
     32        void set_value( std::string newValue ) { value = newValue; }
    3433
    35         /// generates a boolean constant of the given bool
    36         static Constant from_bool( bool b );
    3734        /// generates an integer constant of the given int
    3835        static Constant from_int( int i );
     
    4239        static Constant from_double( double d );
    4340
    44         virtual void accept( Visitor & v ) { v.visit( this ); }
    45         virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    46         virtual void print( std::ostream & os ) const;
     41        virtual Constant *clone() const;
     42        virtual void accept( Visitor &v ) { v.visit( this ); }
     43        virtual Constant *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     44        virtual void print( std::ostream &os ) const;
    4745  private:
    48         Type * type;
    49         std::string rep;
    50         union Val {
    51                 unsigned long long ival;
    52                 double dval;
    53                 Val( unsigned long long ival ) : ival( ival ) {}
    54                 Val( double dval ) : dval( dval ) {}
    55         } val;
     46        Type *type;
     47        std::string value;
    5648};
    5749
  • src/SynTree/Expression.cc

    r4c03e63 re1c1829  
    288288}
    289289
     290// CastExpr *CastExpr::clone() const { return 0; }
     291
    290292void CastExpr::print( std::ostream &os, int indent ) const {
    291293        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
     
    353355}
    354356
     357//// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    355358MemberExpr::MemberExpr( const MemberExpr &other ) :
    356359                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     
    358361
    359362MemberExpr::~MemberExpr() {
    360         // don't delete the member declaration, since it points somewhere else in the tree
     363        // delete member;
    361364        delete aggregate;
    362365}
     
    588591}
    589592
     593UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
     594
     595UntypedValofExpr::~UntypedValofExpr() { delete body; }
     596
     597void UntypedValofExpr::print( std::ostream &os, int indent ) const {
     598        os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
     599        if ( get_body() != 0 )
     600                get_body()->print( os, indent + 2 );
     601}
     602
    590603RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    591604RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
  • src/SynTree/Expression.h

    r4c03e63 re1c1829  
    226226};
    227227
    228 /// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer.
    229 /// Does not take ownership of member.
     228/// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
    230229class MemberExpr : public Expression {
    231230  public:
     
    248247};
    249248
    250 /// VariableExpr represents an expression that simply refers to the value of a named variable.
    251 /// Does not take ownership of var.
     249/// VariableExpr represents an expression that simply refers to the value of a named variable
    252250class VariableExpr : public Expression {
    253251  public:
     
    600598};
    601599
     600/// ValofExpr represents a GCC 'lambda expression'
     601class UntypedValofExpr : public Expression {
     602  public:
     603        UntypedValofExpr( Statement *_body, Expression *_aname = nullptr ) : Expression( _aname ), body ( _body ) {}
     604        UntypedValofExpr( const UntypedValofExpr & other );
     605        virtual ~UntypedValofExpr();
     606
     607        Expression * get_value();
     608        Statement * get_body() const { return body; }
     609
     610        virtual UntypedValofExpr * clone() const { return new UntypedValofExpr( * this ); }
     611        virtual void accept( Visitor & v ) { v.visit( this ); }
     612        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     613        virtual void print( std::ostream & os, int indent = 0 ) const;
     614  private:
     615        Statement * body;
     616};
     617
    602618/// RangeExpr represents a range e.g. '3 ... 5' or '1~10'
    603619class RangeExpr : public Expression {
  • src/SynTree/Mutator.cc

    r4c03e63 re1c1829  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jun 22 13:43:00 2017
    13 // Update Count     : 24
     12// Last Modified On : Thu Mar  8 16:36:00 2017
     13// Update Count     : 23
    1414//
    1515
     
    162162        tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
    163163        mutateAll( tryStmt->get_catchers(), *this );
    164         tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
    165164        return tryStmt;
    166165}
     
    168167Statement *Mutator::mutate( CatchStmt *catchStmt ) {
    169168        catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
    170         catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
    171169        catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
    172170        return catchStmt;
     
    382380}
    383381
     382Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
     383        valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) );
     384        valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
     385        return valofExpr;
     386}
     387
    384388Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
    385389        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
  • src/SynTree/Mutator.h

    r4c03e63 re1c1829  
    7878        virtual Expression* mutate( ConstructorExpr *ctorExpr );
    7979        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
     80        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    8081        virtual Expression* mutate( RangeExpr *rangeExpr );
    8182        virtual Expression* mutate( UntypedTupleExpr *tupleExpr );
  • src/SynTree/ObjectDecl.cc

    r4c03e63 re1c1829  
    5656
    5757        if ( init ) {
    58                 os << " with initializer " << std::endl;
    59                 init->print( os, indent+2 );
    60                 os << std::endl << std::string(indent+2, ' ');
     58                os << " with initializer ";
     59                init->print( os, indent );
     60                os << std::endl << std::string(indent, ' ');
    6161                os << "maybeConstructed? " << init->get_maybeConstructed();
    6262        } // if
  • src/SynTree/Statement.cc

    r4c03e63 re1c1829  
    313313}
    314314
    315 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &_handlers, FinallyStmt *_finallyBlock ) :
     315TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
    316316        Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock ) {
    317317}
     
    334334        // handlers
    335335        os << string( indent + 2, ' ' ) << "and handlers: " << endl;
    336         for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
     336        for ( std::list<Statement *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
    337337                (*i )->print( os, indent + 4 );
    338338
  • src/SynTree/Statement.h

    r4c03e63 re1c1829  
    315315class TryStmt : public Statement {
    316316  public:
    317         TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
     317        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
    318318        TryStmt( const TryStmt &other );
    319319        virtual ~TryStmt();
     
    321321        CompoundStmt *get_block() const { return block; }
    322322        void set_block( CompoundStmt *newValue ) { block = newValue; }
    323         std::list<CatchStmt *>& get_catchers() { return handlers; }
     323        std::list<Statement *>& get_catchers() { return handlers; }
    324324
    325325        FinallyStmt *get_finally() const { return finallyBlock; }
     
    333333  private:
    334334        CompoundStmt *block;
    335         std::list<CatchStmt *> handlers;
     335        std::list<Statement *> handlers;
    336336        FinallyStmt *finallyBlock;
    337337};
  • src/SynTree/Visitor.cc

    r4c03e63 re1c1829  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jun 22 13:41:00 2017
    13 // Update Count     : 26
     12// Last Modified On : Thu Jun  8 16:31:00 2017
     13// Update Count     : 25
    1414//
    1515
     
    137137        maybeAccept( tryStmt->get_block(), *this );
    138138        acceptAll( tryStmt->get_catchers(), *this );
    139         maybeAccept( tryStmt->get_finally(), *this );
    140139}
    141140
    142141void Visitor::visit( CatchStmt *catchStmt ) {
    143142        maybeAccept( catchStmt->get_decl(), *this );
    144         maybeAccept( catchStmt->get_cond(), *this );
    145143        maybeAccept( catchStmt->get_body(), *this );
    146144}
     
    301299        maybeAccept( compLitExpr->get_result(), *this );
    302300        maybeAccept( compLitExpr->get_initializer(), *this );
     301}
     302
     303void Visitor::visit( UntypedValofExpr *valofExpr ) {
     304        maybeAccept( valofExpr->get_result(), *this );
     305        maybeAccept( valofExpr->get_body(), *this );
    303306}
    304307
  • src/SynTree/Visitor.h

    r4c03e63 re1c1829  
    8181        virtual void visit( ConstructorExpr * ctorExpr );
    8282        virtual void visit( CompoundLiteralExpr *compLitExpr );
     83        virtual void visit( UntypedValofExpr *valofExpr );
    8384        virtual void visit( RangeExpr *rangeExpr );
    8485        virtual void visit( UntypedTupleExpr *tupleExpr );
     
    162163                        } // if
    163164                } catch( SemanticError &e ) {
    164                         e.set_location( (*i)->location );
     165                        e.set_location( (*i)->location );                       
    165166                        errors.append( e );
    166167                } // try
  • src/Tuples/TupleExpansion.cc

    r4c03e63 re1c1829  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 17:35:04 2017
    13 // Update Count     : 19
     12// Last Modified On : Thu Mar 16 08:05:17 2017
     13// Update Count     : 15
    1414//
    1515
     
    191191                                commaExpr->set_arg1( nullptr );
    192192                        }
    193                         ObjectDecl * finished = new ObjectDecl( toString( "_unq", id, "_finished_" ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ),
    194                                                                                                         new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ), noDesignators ) );
     193                        BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
     194                        ObjectDecl * finished = new ObjectDecl( toString( "_unq", id, "_finished_" ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ), new SingleInit( new ConstantExpr( Constant( boolType->clone(), "0" ) ), noDesignators ) );
    195195                        addDeclaration( finished );
    196196                        // (finished ? _unq_expr_N : (_unq_expr_N = <unqExpr->get_expr()>, finished = 1, _unq_expr_N))
    197197                        // This pattern ensures that each unique expression is evaluated once, regardless of evaluation order of the generated C code.
    198                         Expression * assignFinished = UntypedExpr::createAssign( new VariableExpr(finished), new ConstantExpr( Constant::from_int( 1 ) ) );
     198                        Expression * assignFinished = UntypedExpr::createAssign( new VariableExpr(finished), new ConstantExpr( Constant( boolType->clone(), "1" ) ) );
    199199                        ConditionalExpr * condExpr = new ConditionalExpr( new VariableExpr( finished ), var->clone(),
    200200                                new CommaExpr( new CommaExpr( assignUnq, assignFinished ), var->clone() ) );
  • src/tests/.expect/32/KRfunctions.txt

    r4c03e63 re1c1829  
    66extern int printf(const char *__restrict __format, ...);
    77int __f0__Fi_iPCii__1(int __a__i_1, const int *__b__PCi_1, int __c__i_1){
    8     __attribute__ ((unused)) int ___retval_f0__i_1;
     8    int ___retval_f0__i_1;
    99}
    1010int __f1__Fi_PiiPi__1(int *__a__Pi_1, __attribute__ ((unused)) int __b__i_1, int *__c__Pi_1){
    11     __attribute__ ((unused)) int ___retval_f1__i_1;
     11    int ___retval_f1__i_1;
    1212}
    1313int __f2__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    14     __attribute__ ((unused)) int ___retval_f2__i_1;
     14    int ___retval_f2__i_1;
    1515}
    1616struct S {
     
    4040}
    4141int __f3__Fi_2sS2sSPi__1(struct S __a__2sS_1, struct S __b__2sS_1, int *__c__Pi_1){
    42     __attribute__ ((unused)) int ___retval_f3__i_1;
     42    int ___retval_f3__i_1;
    4343    struct S __s__2sS_2;
    4444}
    4545int __f4__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    46     __attribute__ ((unused)) int ___retval_f4__i_1;
     46    int ___retval_f4__i_1;
    4747}
    4848int __f5__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    49     __attribute__ ((unused)) int ___retval_f5__i_1;
     49    int ___retval_f5__i_1;
    5050}
    5151int (*__f6__FPFi_i__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __anonymous_object0){
    52     __attribute__ ((unused)) int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
     52    int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
    5353}
    5454int (*__f7__FPFi_ii__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __a__i_1, int __b__i_1){
    55     __attribute__ ((unused)) int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
     55    int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
    5656}
    5757int *__f8__FPi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    58     __attribute__ ((unused)) int *___retval_f8__Pi_1;
     58    int *___retval_f8__Pi_1;
    5959}
    6060int *const __f9__FCPi_PiiPi__1(int *__a__Pi_1, int __b__i_1, int *__c__Pi_1){
    61     __attribute__ ((unused)) int *const ___retval_f9__CPi_1;
     61    int *const ___retval_f9__CPi_1;
    6262}
    6363int *(*__f10__FPFPi_ii__iPiPid__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1, double __y__d_1))(int __x__i_1, int __y__i_1){
    64     __attribute__ ((unused)) int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
     64    int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
    6565    int *__x__FPi_ii__2(int __anonymous_object2, int __anonymous_object3);
    6666    ((void)(___retval_f10__PFPi_ii__1=__x__FPi_ii__2) /* ?{} */);
     
    6868}
    6969int (*__f11__FPA0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[]{
    70     __attribute__ ((unused)) int (*___retval_f11__PA0i_1)[];
     70    int (*___retval_f11__PA0i_1)[];
    7171}
    7272int (*__f12__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((unsigned int )10)]{
    73     __attribute__ ((unused)) int (*___retval_f12__PA0A0i_1)[][((unsigned int )10)];
     73    int (*___retval_f12__PA0A0i_1)[][((unsigned int )10)];
    7474}
    7575int (*__f13__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((unsigned int )10)]{
    76     __attribute__ ((unused)) int (*___retval_f13__PA0A0i_1)[][((unsigned int )10)];
     76    int (*___retval_f13__PA0A0i_1)[][((unsigned int )10)];
    7777}
    7878int (*__f14__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((unsigned int )10)]{
    79     __attribute__ ((unused)) int (*___retval_f14__PA0A0i_1)[][((unsigned int )10)];
     79    int (*___retval_f14__PA0A0i_1)[][((unsigned int )10)];
    8080}
    8181const int __fred__FCi___1(){
    82     __attribute__ ((unused)) const int ___retval_fred__Ci_1;
     82    const int ___retval_fred__Ci_1;
    8383    int *(*__x__PFPi_ii__2)(int __anonymous_object4, int __anonymous_object5);
    8484    int __a__i_2;
     
    8888    ((void)((*((int *(**)(int __x__i_1, int __y__i_1))(&_tmp_cp_ret0)))) /* ^?{} */);
    8989    const int __f1__FCi_iPiPi__2(int __a__i_2, int *__b__Pi_2, int *__c__Pi_2){
    90         __attribute__ ((unused)) const int ___retval_f1__Ci_2;
     90        const int ___retval_f1__Ci_2;
    9191    }
    9292    const int __f2__FCi_iii__2(int __a__i_2, int __b__i_2, int __c__i_2){
    93         __attribute__ ((unused)) const int ___retval_f2__Ci_2;
     93        const int ___retval_f2__Ci_2;
    9494    }
    9595}
  • src/tests/.expect/32/attributes.txt

    r4c03e63 re1c1829  
    66extern int printf(const char *__restrict __format, ...);
    77int __la__Fi___1(){
    8     __attribute__ ((unused)) int ___retval_la__i_1;
     8    int ___retval_la__i_1;
    99    L: __attribute__ ((unused)) ((void)1);
    1010}
     
    226226__attribute__ ((unused,used)) int __f1__Fi___1();
    227227__attribute__ ((unused)) int __f1__Fi___1(){
    228     __attribute__ ((unused)) int ___retval_f1__i_1;
     228    int ___retval_f1__i_1;
    229229}
    230230__attribute__ ((unused,unused,unused,used)) int **const __f2__FCPPi___1();
    231231__attribute__ ((unused,unused,unused)) int **const __f2__FCPPi___1(){
    232     __attribute__ ((unused)) int **const ___retval_f2__CPPi_1;
     232    int **const ___retval_f2__CPPi_1;
    233233}
    234234__attribute__ ((unused,used,unused)) int (*__f3__FPA0i_i__1(int __anonymous_object1))[];
    235235__attribute__ ((unused,unused)) int (*__f3__FPA0i_i__1(int __p__i_1))[]{
    236     __attribute__ ((unused)) int (*___retval_f3__PA0i_1)[];
     236    int (*___retval_f3__PA0i_1)[];
    237237}
    238238__attribute__ ((unused,used,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object2);
    239239__attribute__ ((unused,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object3){
    240     __attribute__ ((unused)) int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
     240    int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
    241241}
    242242int __vtr__Fi___1(){
    243     __attribute__ ((unused)) int ___retval_vtr__i_1;
     243    int ___retval_vtr__i_1;
    244244    __attribute__ ((unused,unused,used)) int __t1__i_2;
    245245    __attribute__ ((unused,unused,unused,unused,unused)) int **__t2__PPi_2;
     
    251251int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1);
    252252int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1){
    253     __attribute__ ((unused)) int ___retval_ipd1__i_1;
     253    int ___retval_ipd1__i_1;
    254254}
    255255int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    256256int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    257     __attribute__ ((unused)) int ___retval_ipd2__i_1;
     257    int ___retval_ipd2__i_1;
    258258}
    259259int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    260260int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    261     __attribute__ ((unused)) int ___retval_ipd3__i_1;
     261    int ___retval_ipd3__i_1;
    262262}
    263263int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)());
    264264int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)()){
    265     __attribute__ ((unused)) int ___retval_ipd4__i_1;
     265    int ___retval_ipd4__i_1;
    266266}
    267267int __tpr1__Fi_i__1(__attribute__ ((unused,unused,unused)) int __Foo__i_1);
     
    273273int __tpr7__Fi_PFi_PFi_i____1(__attribute__ ((unused,unused)) int (*__anonymous_object7)(__attribute__ ((unused)) int (*__anonymous_object8)(__attribute__ ((unused,unused)) int __anonymous_object9)));
    274274int __ad__Fi___1(){
    275     __attribute__ ((unused)) int ___retval_ad__i_1;
     275    int ___retval_ad__i_1;
    276276    __attribute__ ((used,unused)) int __ad1__i_2;
    277277    __attribute__ ((unused,unused,unused)) int *__ad2__Pi_2;
  • src/tests/.expect/32/declarationSpecifier.txt

    r4c03e63 re1c1829  
    670670static inline volatile const short __f48__FCVs___1();
    671671int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    672     __attribute__ ((unused)) int ___retval_main__i_1;
     672    int ___retval_main__i_1;
    673673    ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    674674    return ((int )___retval_main__i_1);
     
    685685static inline int invoke_main(int argc, char **argv, char **envp);
    686686int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    687     __attribute__ ((unused)) int ___retval_main__i_1;
     687    int ___retval_main__i_1;
    688688    int _tmp_cp_ret0;
    689689    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/32/extension.txt

    r4c03e63 re1c1829  
    8585__extension__ int j;
    8686__extension__ int __fred__Fi_i__1(int __p__i_1){
    87     __attribute__ ((unused)) int ___retval_fred__i_1;
     87    int ___retval_fred__i_1;
    8888    __extension__ struct S {
    8989        __extension__ int __a__i_2;
     
    105105    ((void)((*((int *)(&_tmp_cp_ret0)))) /* ^?{} */);
    106106    __extension__ int __mary__Fi_i__2(int __p__i_2){
    107         __attribute__ ((unused)) int ___retval_mary__i_2;
     107        int ___retval_mary__i_2;
    108108    }
    109109    ((void)__extension__ sizeof(3));
  • src/tests/.expect/32/gccExtensions.txt

    r4c03e63 re1c1829  
    77extern int __x__i_1 asm ( "xx" );
    88int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    9     __attribute__ ((unused)) int ___retval_main__i_1;
     9    int ___retval_main__i_1;
    1010    asm ( "nop" :  :  :  );
    1111    asm ( "nop" :  :  :  );
     
    2626    const int __i3__Ci_2;
    2727    inline int __f1__Fi___2(){
    28         __attribute__ ((unused)) int ___retval_f1__i_2;
     28        int ___retval_f1__i_2;
    2929    }
    3030    inline int __f2__Fi___2(){
    31         __attribute__ ((unused)) int ___retval_f2__i_2;
     31        int ___retval_f2__i_2;
    3232    }
    3333    int __s1__i_2;
     
    182182static inline int invoke_main(int argc, char **argv, char **envp);
    183183int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    184     __attribute__ ((unused)) int ___retval_main__i_1;
     184    int ___retval_main__i_1;
    185185    int _tmp_cp_ret0;
    186186    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/64/KRfunctions.txt

    r4c03e63 re1c1829  
    66extern int printf(const char *__restrict __format, ...);
    77int __f0__Fi_iPCii__1(int __a__i_1, const int *__b__PCi_1, int __c__i_1){
    8     __attribute__ ((unused)) int ___retval_f0__i_1;
     8    int ___retval_f0__i_1;
    99}
    1010int __f1__Fi_PiiPi__1(int *__a__Pi_1, __attribute__ ((unused)) int __b__i_1, int *__c__Pi_1){
    11     __attribute__ ((unused)) int ___retval_f1__i_1;
     11    int ___retval_f1__i_1;
    1212}
    1313int __f2__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    14     __attribute__ ((unused)) int ___retval_f2__i_1;
     14    int ___retval_f2__i_1;
    1515}
    1616struct S {
     
    4040}
    4141int __f3__Fi_2sS2sSPi__1(struct S __a__2sS_1, struct S __b__2sS_1, int *__c__Pi_1){
    42     __attribute__ ((unused)) int ___retval_f3__i_1;
     42    int ___retval_f3__i_1;
    4343    struct S __s__2sS_2;
    4444}
    4545int __f4__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    46     __attribute__ ((unused)) int ___retval_f4__i_1;
     46    int ___retval_f4__i_1;
    4747}
    4848int __f5__Fi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    49     __attribute__ ((unused)) int ___retval_f5__i_1;
     49    int ___retval_f5__i_1;
    5050}
    5151int (*__f6__FPFi_i__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __anonymous_object0){
    52     __attribute__ ((unused)) int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
     52    int (*___retval_f6__PFi_i__1)(int __anonymous_object1);
    5353}
    5454int (*__f7__FPFi_ii__iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))(int __a__i_1, int __b__i_1){
    55     __attribute__ ((unused)) int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
     55    int (*___retval_f7__PFi_ii__1)(int __a__i_1, int __b__i_1);
    5656}
    5757int *__f8__FPi_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1){
    58     __attribute__ ((unused)) int *___retval_f8__Pi_1;
     58    int *___retval_f8__Pi_1;
    5959}
    6060int *const __f9__FCPi_PiiPi__1(int *__a__Pi_1, int __b__i_1, int *__c__Pi_1){
    61     __attribute__ ((unused)) int *const ___retval_f9__CPi_1;
     61    int *const ___retval_f9__CPi_1;
    6262}
    6363int *(*__f10__FPFPi_ii__iPiPid__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1, double __y__d_1))(int __x__i_1, int __y__i_1){
    64     __attribute__ ((unused)) int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
     64    int *(*___retval_f10__PFPi_ii__1)(int __x__i_1, int __y__i_1);
    6565    int *__x__FPi_ii__2(int __anonymous_object2, int __anonymous_object3);
    6666    ((void)(___retval_f10__PFPi_ii__1=__x__FPi_ii__2) /* ?{} */);
     
    6868}
    6969int (*__f11__FPA0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[]{
    70     __attribute__ ((unused)) int (*___retval_f11__PA0i_1)[];
     70    int (*___retval_f11__PA0i_1)[];
    7171}
    7272int (*__f12__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((long unsigned int )10)]{
    73     __attribute__ ((unused)) int (*___retval_f12__PA0A0i_1)[][((long unsigned int )10)];
     73    int (*___retval_f12__PA0A0i_1)[][((long unsigned int )10)];
    7474}
    7575int (*__f13__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((long unsigned int )10)]{
    76     __attribute__ ((unused)) int (*___retval_f13__PA0A0i_1)[][((long unsigned int )10)];
     76    int (*___retval_f13__PA0A0i_1)[][((long unsigned int )10)];
    7777}
    7878int (*__f14__FPA0A0i_iPiPi__1(int __a__i_1, int *__b__Pi_1, int *__c__Pi_1))[][((long unsigned int )10)]{
    79     __attribute__ ((unused)) int (*___retval_f14__PA0A0i_1)[][((long unsigned int )10)];
     79    int (*___retval_f14__PA0A0i_1)[][((long unsigned int )10)];
    8080}
    8181const int __fred__FCi___1(){
    82     __attribute__ ((unused)) const int ___retval_fred__Ci_1;
     82    const int ___retval_fred__Ci_1;
    8383    int *(*__x__PFPi_ii__2)(int __anonymous_object4, int __anonymous_object5);
    8484    int __a__i_2;
     
    8888    ((void)((*((int *(**)(int __x__i_1, int __y__i_1))(&_tmp_cp_ret0)))) /* ^?{} */);
    8989    const int __f1__FCi_iPiPi__2(int __a__i_2, int *__b__Pi_2, int *__c__Pi_2){
    90         __attribute__ ((unused)) const int ___retval_f1__Ci_2;
     90        const int ___retval_f1__Ci_2;
    9191    }
    9292    const int __f2__FCi_iii__2(int __a__i_2, int __b__i_2, int __c__i_2){
    93         __attribute__ ((unused)) const int ___retval_f2__Ci_2;
     93        const int ___retval_f2__Ci_2;
    9494    }
    9595}
  • src/tests/.expect/64/attributes.txt

    r4c03e63 re1c1829  
    66extern int printf(const char *__restrict __format, ...);
    77int __la__Fi___1(){
    8     __attribute__ ((unused)) int ___retval_la__i_1;
     8    int ___retval_la__i_1;
    99    L: __attribute__ ((unused)) ((void)1);
    1010}
     
    226226__attribute__ ((unused,used)) int __f1__Fi___1();
    227227__attribute__ ((unused)) int __f1__Fi___1(){
    228     __attribute__ ((unused)) int ___retval_f1__i_1;
     228    int ___retval_f1__i_1;
    229229}
    230230__attribute__ ((unused,unused,unused,used)) int **const __f2__FCPPi___1();
    231231__attribute__ ((unused,unused,unused)) int **const __f2__FCPPi___1(){
    232     __attribute__ ((unused)) int **const ___retval_f2__CPPi_1;
     232    int **const ___retval_f2__CPPi_1;
    233233}
    234234__attribute__ ((unused,used,unused)) int (*__f3__FPA0i_i__1(int __anonymous_object1))[];
    235235__attribute__ ((unused,unused)) int (*__f3__FPA0i_i__1(int __p__i_1))[]{
    236     __attribute__ ((unused)) int (*___retval_f3__PA0i_1)[];
     236    int (*___retval_f3__PA0i_1)[];
    237237}
    238238__attribute__ ((unused,used,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object2);
    239239__attribute__ ((unused,unused)) int (*__f4__FPFi_i____1())(int __anonymous_object3){
    240     __attribute__ ((unused)) int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
     240    int (*___retval_f4__PFi_i__1)(int __anonymous_object4);
    241241}
    242242int __vtr__Fi___1(){
    243     __attribute__ ((unused)) int ___retval_vtr__i_1;
     243    int ___retval_vtr__i_1;
    244244    __attribute__ ((unused,unused,used)) int __t1__i_2;
    245245    __attribute__ ((unused,unused,unused,unused,unused)) int **__t2__PPi_2;
     
    251251int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1);
    252252int __ipd1__Fi_ii__1(__attribute__ ((unused,unused,unused)) int __p__i_1, __attribute__ ((unused,unused,unused)) int __q__i_1){
    253     __attribute__ ((unused)) int ___retval_ipd1__i_1;
     253    int ___retval_ipd1__i_1;
    254254}
    255255int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    256256int __ipd2__Fi_PiPi__1(__attribute__ ((unused,unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    257     __attribute__ ((unused)) int ___retval_ipd2__i_1;
     257    int ___retval_ipd2__i_1;
    258258}
    259259int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1);
    260260int __ipd3__Fi_PiPi__1(__attribute__ ((unused,unused,unused)) int *__p__Pi_1, __attribute__ ((unused,unused,unused)) int *__q__Pi_1){
    261     __attribute__ ((unused)) int ___retval_ipd3__i_1;
     261    int ___retval_ipd3__i_1;
    262262}
    263263int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)());
    264264int __ipd4__Fi_PFi__PFi____1(__attribute__ ((unused,unused,unused)) int (*__p__PFi___1)(), __attribute__ ((unused,unused,unused)) int (*__q__PFi___1)()){
    265     __attribute__ ((unused)) int ___retval_ipd4__i_1;
     265    int ___retval_ipd4__i_1;
    266266}
    267267int __tpr1__Fi_i__1(__attribute__ ((unused,unused,unused)) int __Foo__i_1);
     
    273273int __tpr7__Fi_PFi_PFi_i____1(__attribute__ ((unused,unused)) int (*__anonymous_object7)(__attribute__ ((unused)) int (*__anonymous_object8)(__attribute__ ((unused,unused)) int __anonymous_object9)));
    274274int __ad__Fi___1(){
    275     __attribute__ ((unused)) int ___retval_ad__i_1;
     275    int ___retval_ad__i_1;
    276276    __attribute__ ((used,unused)) int __ad1__i_2;
    277277    __attribute__ ((unused,unused,unused)) int *__ad2__Pi_2;
  • src/tests/.expect/64/declarationSpecifier.txt

    r4c03e63 re1c1829  
    670670static inline volatile const short __f48__FCVs___1();
    671671int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    672     __attribute__ ((unused)) int ___retval_main__i_1;
     672    int ___retval_main__i_1;
    673673    ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    674674    return ((int )___retval_main__i_1);
     
    685685static inline int invoke_main(int argc, char **argv, char **envp);
    686686int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    687     __attribute__ ((unused)) int ___retval_main__i_1;
     687    int ___retval_main__i_1;
    688688    int _tmp_cp_ret0;
    689689    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/64/extension.txt

    r4c03e63 re1c1829  
    8585__extension__ int j;
    8686__extension__ int __fred__Fi_i__1(int __p__i_1){
    87     __attribute__ ((unused)) int ___retval_fred__i_1;
     87    int ___retval_fred__i_1;
    8888    __extension__ struct S {
    8989        __extension__ int __a__i_2;
     
    105105    ((void)((*((int *)(&_tmp_cp_ret0)))) /* ^?{} */);
    106106    __extension__ int __mary__Fi_i__2(int __p__i_2){
    107         __attribute__ ((unused)) int ___retval_mary__i_2;
     107        int ___retval_mary__i_2;
    108108    }
    109109    ((void)__extension__ sizeof(3));
  • src/tests/.expect/64/gccExtensions.txt

    r4c03e63 re1c1829  
    77extern int __x__i_1 asm ( "xx" );
    88int __main__Fi_iPPCc__1(int __argc__i_1, const char **__argv__PPCc_1){
    9     __attribute__ ((unused)) int ___retval_main__i_1;
     9    int ___retval_main__i_1;
    1010    asm ( "nop" :  :  :  );
    1111    asm ( "nop" :  :  :  );
     
    2626    const int __i3__Ci_2;
    2727    inline int __f1__Fi___2(){
    28         __attribute__ ((unused)) int ___retval_f1__i_2;
     28        int ___retval_f1__i_2;
    2929    }
    3030    inline int __f2__Fi___2(){
    31         __attribute__ ((unused)) int ___retval_f2__i_2;
     31        int ___retval_f2__i_2;
    3232    }
    3333    int __s1__i_2;
     
    182182static inline int invoke_main(int argc, char **argv, char **envp);
    183183int main(int __argc__i_1, char **__argv__PPc_1, char **__envp__PPc_1){
    184     __attribute__ ((unused)) int ___retval_main__i_1;
     184    int ___retval_main__i_1;
    185185    int _tmp_cp_ret0;
    186186    ((void)(___retval_main__i_1=((_tmp_cp_ret0=invoke_main(__argc__i_1, __argv__PPc_1, __envp__PPc_1)) , _tmp_cp_ret0)) /* ?{} */);
  • src/tests/.expect/scopeErrors.txt

    r4c03e63 re1c1829  
    33  with parameters
    44    double
    5   returning
    6     _retval_butThisIsAnError:       Attribute with name: unused
    7 double
    8   with body
     5  returning
     6    _retval_butThisIsAnError: double
     7  with body
    98    CompoundStmt
Note: See TracChangeset for help on using the changeset viewer.