Changeset 579263a for src/Common
- Timestamp:
- Jun 26, 2017, 4:48:35 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- bb1cd95
- Parents:
- e4d829b (diff), 2a7b3ca (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
re4d829b r579263a 12 12 #include "SynTree/Expression.h" 13 13 #include "SynTree/Constant.h" 14 #include "SynTree/TypeSubstitution.h" 14 15 15 16 #include "PassVisitor.proto.h" … … 18 19 // Templated visitor type 19 20 // To use declare a PassVisitor< YOUR VISITOR TYPE > 20 // The visitor type should specify the previsit/postvisit for types that are desired. 21 // The visitor type should specify the previsit/postvisit/premutate/postmutate for types that are desired. 22 // Note: previsit/postvisit/premutate/postmutate must be **public** members 23 // 24 // Several additional features are available through inheritance 25 // | WithTypeSubstitution - provides polymorphic TypeSubstitution * env for the current expression 26 // | WithStmtsToAdd - provides the ability to insert statements before or after the current statement by adding new statements into 27 // stmtsToAddBefore or stmtsToAddAfter respectively. 28 // | WithShortCircuiting - provides the ability to skip visiting child nodes; set visit_children to false in pre{visit,mutate} to skip visiting children 29 // | WithGuards - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable 30 // will automatically be restored to its previous value after the corresponding postvisit/postmutate teminates. 21 31 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 32 template< typename pass_type > 23 33 class PassVisitor final : public Visitor, public Mutator { 24 34 public: 25 PassVisitor() = default;26 35 27 36 template< typename... Args > 28 37 PassVisitor(Args &&... args) 29 38 : pass( std::forward<Args>( args )... ) 30 {} 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 } 31 46 32 47 virtual ~PassVisitor() = default; … … 54 69 virtual void visit( BranchStmt *branchStmt ) override final; 55 70 virtual void visit( ReturnStmt *returnStmt ) override final; 71 virtual void visit( ThrowStmt *throwStmt ) override final; 56 72 virtual void visit( TryStmt *tryStmt ) override final; 57 73 virtual void visit( CatchStmt *catchStmt ) override final; … … 85 101 virtual void visit( ConstructorExpr * ctorExpr ) override final; 86 102 virtual void visit( CompoundLiteralExpr *compLitExpr ) override final; 87 virtual void visit( UntypedValofExpr *valofExpr ) override final;88 103 virtual void visit( RangeExpr *rangeExpr ) override final; 89 104 virtual void visit( UntypedTupleExpr *tupleExpr ) override final; 90 105 virtual void visit( TupleExpr *tupleExpr ) override final; 91 106 virtual void visit( TupleIndexExpr *tupleExpr ) override final; 92 virtual void visit( MemberTupleExpr *tupleExpr ) override final;93 107 virtual void visit( TupleAssignExpr *assignExpr ) override final; 94 108 virtual void visit( StmtExpr * stmtExpr ) override final; … … 140 154 virtual Statement* mutate( BranchStmt *branchStmt ) override final; 141 155 virtual Statement* mutate( ReturnStmt *returnStmt ) override final; 156 virtual Statement* mutate( ThrowStmt *throwStmt ) override final; 142 157 virtual Statement* mutate( TryStmt *returnStmt ) override final; 143 158 virtual Statement* mutate( CatchStmt *catchStmt ) override final; … … 171 186 virtual Expression* mutate( ConstructorExpr *ctorExpr ) override final; 172 187 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ) override final; 173 virtual Expression* mutate( UntypedValofExpr *valofExpr ) override final;174 188 virtual Expression* mutate( RangeExpr *rangeExpr ) override final; 175 189 virtual Expression* mutate( UntypedTupleExpr *tupleExpr ) override final; 176 190 virtual Expression* mutate( TupleExpr *tupleExpr ) override final; 177 191 virtual Expression* mutate( TupleIndexExpr *tupleExpr ) override final; 178 virtual Expression* mutate( MemberTupleExpr *tupleExpr ) override final;179 192 virtual Expression* mutate( TupleAssignExpr *assignExpr ) override final; 180 193 virtual Expression* mutate( StmtExpr * stmtExpr ) override final; … … 207 220 208 221 private: 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 209 225 template<typename node_type> void call_previsit ( node_type * node ) { previsit_impl ( pass, node, 0 ); } 210 226 template<typename node_type> void call_postvisit( node_type * node ) { postvisit_impl( pass, node, 0 ); } … … 218 234 void set_env( TypeSubstitution * env ) { set_env_impl( pass, env, 0); } 219 235 220 void visitStatementList( std::list< Statement* > &statements ); 236 template< typename func_t > 237 void handleStatementList( std::list< Statement * > & statements, func_t func ); 238 void visitStatementList ( std::list< Statement* > &statements ); 221 239 void mutateStatementList( std::list< Statement* > &statements ); 222 240 223 Statement * visitStatement( Statement * stmt ); 241 template< typename func_t > 242 Statement * handleStatement( Statement * stmt, func_t func ); 243 Statement * visitStatement ( Statement * stmt ); 224 244 Statement * mutateStatement( Statement * stmt ); 225 245 226 void visitExpression( Expression * expr ); 246 template< typename func_t > 247 Expression * handleExpression( Expression * expr, func_t func ); 248 Expression * visitExpression ( Expression * expr ); 227 249 Expression * mutateExpression( Expression * expr ); 228 250 … … 231 253 std::list< Statement* > * get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); } 232 254 std::list< Statement* > * get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); } 233 bool visit_children() { bool* skip = skip_children_impl(pass, 0); return ! (skip && *skip); } 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 ); } 259 260 guard_value_impl init_guard() { 261 guard_value_impl guard; 262 auto at_cleanup = at_cleanup_impl(pass, 0); 263 if( at_cleanup ) { 264 *at_cleanup = [&guard]( cleanup_func_t && func, void* val ) { 265 guard.push( std::move( func ), val ); 266 }; 267 } 268 return guard; 269 } 270 }; 271 272 template<typename pass_type, typename T> 273 void GuardValue( pass_type * pass, T& val ) { 274 pass->at_cleanup( [ val ]( void * newVal ) { 275 * static_cast< T * >( newVal ) = val; 276 }, static_cast< void * >( & val ) ); 277 } 278 279 class WithTypeSubstitution { 280 protected: 281 WithTypeSubstitution() = default; 282 ~WithTypeSubstitution() = default; 283 284 public: 285 TypeSubstitution * env = nullptr; 286 }; 287 288 class WithStmtsToAdd { 289 protected: 290 WithStmtsToAdd() = default; 291 ~WithStmtsToAdd() = default; 292 293 public: 294 std::list< Statement* > stmtsToAddBefore; 295 std::list< Statement* > stmtsToAddAfter; 296 }; 297 298 class WithDeclsToAdd { 299 protected: 300 WithDeclsToAdd() = default; 301 ~WithDeclsToAdd() = default; 302 303 public: 304 std::list< Declaration* > declsToAddBefore; 305 std::list< Declaration* > declsToAddAfter; 306 }; 307 308 class WithShortCircuiting { 309 protected: 310 WithShortCircuiting() = default; 311 ~WithShortCircuiting() = default; 312 313 public: 314 bool_ref visit_children; 315 }; 316 317 class WithGuards { 318 protected: 319 WithGuards() = default; 320 ~WithGuards() = default; 321 322 public: 323 at_cleanup_t at_cleanup; 324 325 template< typename T > 326 void GuardValue( T& val ) { 327 at_cleanup( [ val ]( void * newVal ) { 328 * static_cast< T * >( newVal ) = val; 329 }, static_cast< void * >( & val ) ); 330 } 331 332 template< typename T > 333 void GuardScope( T& val ) { 334 val.beginScope(); 335 at_cleanup( []( void * val ) { 336 static_cast< T * >( val )->endScope(); 337 }, static_cast< void * >( & val ) ); 338 } 339 340 template< typename Func > 341 void GuardAction( Func func ) { 342 at_cleanup( [func](__attribute__((unused)) void *) { func(); }, nullptr ); 343 } 344 }; 345 346 template<typename pass_type> 347 class WithVisitorRef { 348 protected: 349 WithVisitorRef() {} 350 ~WithVisitorRef() {} 351 352 public: 353 PassVisitor<pass_type> * const visitor = nullptr; 234 354 }; 235 355 -
src/Common/PassVisitor.impl.h
re4d829b r579263a 1 1 #pragma once 2 2 3 #define VISIT_START( node ) \ 4 call_previsit( node ); \ 5 if( visit_children() ) { \ 6 7 #define VISIT_END( node ) \ 8 } \ 9 return call_postvisit( node ); \ 10 11 #define MUTATE_START( node ) \ 12 call_premutate( node ); \ 13 if( visit_children() ) { \ 3 #define VISIT_START( node ) \ 4 __attribute__((unused)) \ 5 const auto & guard = init_guard(); \ 6 bool visit_children = true; \ 7 set_visit_children( visit_children ); \ 8 call_previsit( node ); \ 9 if( visit_children ) { \ 10 11 #define VISIT_END( node ) \ 12 } \ 13 call_postvisit( node ); \ 14 15 #define MUTATE_START( node ) \ 16 __attribute__((unused)) \ 17 const auto & guard = init_guard(); \ 18 bool visit_children = true; \ 19 set_visit_children( visit_children ); \ 20 call_premutate( node ); \ 21 if( visit_children ) { \ 14 22 15 23 #define MUTATE_END( type, node ) \ … … 18 26 19 27 20 #define VISIT_BODY( node ) \21 VISIT_START( node ); \22 Visitor::visit( node ); \23 VISIT_END( node ); \28 #define VISIT_BODY( node ) \ 29 VISIT_START( node ); \ 30 Visitor::visit( node ); \ 31 VISIT_END( node ); \ 24 32 25 33 … … 36 44 } 37 45 38 typedef std::list< Statement * > StmtList_t; 39 40 template< typename pass_type > 41 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { 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 ) { 42 105 SemanticError errors; 106 107 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 108 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() ); 109 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () ); 110 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 111 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); 43 112 44 113 StmtList_t* beforeStmts = get_beforeStmts(); 45 114 StmtList_t* afterStmts = get_afterStmts(); 115 DeclList_t* beforeDecls = get_beforeDecls(); 116 DeclList_t* afterDecls = get_afterDecls(); 46 117 47 118 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 119 120 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); } 48 121 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 122 49 123 try { 50 (*i)->accept( *this ); 124 func( *i ); 125 assert(( empty( beforeStmts ) && empty( afterStmts )) 126 || ( empty( beforeDecls ) && empty( afterDecls )) ); 127 51 128 } catch ( SemanticError &e ) { 52 129 errors.append( e ); 53 130 } 131 132 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); } 54 133 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 55 134 } 56 135 136 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); } 57 137 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 58 138 if ( !errors.isEmpty() ) { throw errors; } … … 60 140 61 141 template< typename pass_type > 142 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { 143 handleStatementList( statements, [this]( Statement * stmt) { 144 stmt->accept( *this ); 145 }); 146 } 147 148 template< typename pass_type > 62 149 void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { 63 SemanticError errors; 150 handleStatementList( statements, [this]( Statement *& stmt) { 151 stmt = stmt->acceptMutator( *this ); 152 }); 153 } 154 155 156 template< typename pass_type > 157 template< typename func_t > 158 Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) { 159 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 160 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () ); 161 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 162 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); 163 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() ); 164 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () ); 165 166 Statement *newStmt = func( stmt ); 64 167 65 168 StmtList_t* beforeStmts = get_beforeStmts(); 66 169 StmtList_t* afterStmts = get_afterStmts(); 67 68 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 69 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 70 try { 71 *i = (*i)->acceptMutator( *this ); 72 } catch ( SemanticError &e ) { 73 errors.append( e ); 74 } 75 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 76 } 77 78 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 79 if ( !errors.isEmpty() ) { throw errors; } 80 } 81 82 template< typename pass_type > 83 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 84 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 85 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 86 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 87 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 88 89 maybeAccept( stmt, *this ); 90 91 StmtList_t* beforeStmts = get_beforeStmts(); 92 StmtList_t* afterStmts = get_afterStmts(); 93 94 if( empty(beforeStmts) && empty(afterStmts) ) { return stmt; } 170 DeclList_t* beforeDecls = get_beforeDecls(); 171 DeclList_t* afterDecls = get_afterDecls(); 172 173 if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; } 174 assert(( empty( beforeStmts ) && empty( afterStmts )) 175 || ( empty( beforeDecls ) && empty( afterDecls )) ); 95 176 96 177 CompoundStmt *compound = new CompoundStmt( noLabels ); 178 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); } 97 179 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 98 compound->get_kids().push_back( stmt ); 180 compound->get_kids().push_back( newStmt ); 181 if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); } 99 182 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 100 183 return compound; … … 102 185 103 186 template< typename pass_type > 187 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 188 return handleStatement( stmt, [this]( Statement * stmt ) { 189 maybeAccept( stmt, *this ); 190 return stmt; 191 }); 192 } 193 194 template< typename pass_type > 104 195 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 105 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 106 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 107 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 108 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 109 110 Statement *newStmt = maybeMutate( stmt, *this ); 111 112 StmtList_t* beforeStmts = get_beforeStmts(); 113 StmtList_t* afterStmts = get_afterStmts(); 114 115 if( empty(beforeStmts) && empty(afterStmts) ) { return newStmt; } 116 117 CompoundStmt *compound = new CompoundStmt( noLabels ); 118 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 119 compound->get_kids().push_back( newStmt ); 120 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 121 return compound; 122 } 123 124 125 126 template< typename pass_type > 127 void PassVisitor< pass_type >::visitExpression( Expression * expr ) { 128 if( !expr ) return; 196 return handleStatement( stmt, [this]( Statement * stmt ) { 197 return maybeMutate( stmt, *this ); 198 }); 199 } 200 201 template< typename pass_type > 202 template< typename func_t > 203 Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) { 204 if( !expr ) return nullptr; 129 205 130 206 auto env_ptr = get_env_ptr(); … … 132 208 *env_ptr = expr->get_env(); 133 209 } 134 // xxx - should env be cloned (or moved) onto the result of the mutate? 135 expr->accept( *this ); 210 211 // should env be cloned (or moved) onto the result of the mutate? 212 return func( expr ); 213 } 214 215 template< typename pass_type > 216 Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) { 217 return handleExpression(expr, [this]( Expression * expr ) { 218 expr->accept( *this ); 219 return expr; 220 }); 136 221 } 137 222 138 223 template< typename pass_type > 139 224 Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { 140 if( !expr ) return nullptr; 141 142 auto env_ptr = get_env_ptr(); 143 if ( env_ptr && expr->get_env() ) { 144 *env_ptr = expr->get_env(); 145 } 146 // xxx - should env be cloned (or moved) onto the result of the mutate? 147 return expr->acceptMutator( *this ); 148 } 149 225 return handleExpression(expr, [this]( Expression * expr ) { 226 return expr->acceptMutator( *this ); 227 }); 228 } 150 229 151 230 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ … … 153 232 template< typename pass_type > 154 233 void PassVisitor< pass_type >::visit( ObjectDecl * node ) { 155 VISIT_BODY( node ); 234 VISIT_BODY( node ); 156 235 } 157 236 158 237 template< typename pass_type > 159 238 void PassVisitor< pass_type >::visit( FunctionDecl * node ) { 160 VISIT_BODY( node ); 239 VISIT_BODY( node ); 161 240 } 162 241 163 242 template< typename pass_type > 164 243 void PassVisitor< pass_type >::visit( StructDecl * node ) { 165 VISIT_BODY( node ); 244 VISIT_BODY( node ); 166 245 } 167 246 168 247 template< typename pass_type > 169 248 void PassVisitor< pass_type >::visit( UnionDecl * node ) { 170 VISIT_BODY( node ); 249 VISIT_BODY( node ); 171 250 } 172 251 173 252 template< typename pass_type > 174 253 void PassVisitor< pass_type >::visit( EnumDecl * node ) { 175 VISIT_BODY( node ); 254 VISIT_BODY( node ); 176 255 } 177 256 178 257 template< typename pass_type > 179 258 void PassVisitor< pass_type >::visit( TraitDecl * node ) { 180 VISIT_BODY( node ); 259 VISIT_BODY( node ); 181 260 } 182 261 183 262 template< typename pass_type > 184 263 void PassVisitor< pass_type >::visit( TypeDecl * node ) { 185 VISIT_BODY( node ); 264 VISIT_BODY( node ); 186 265 } 187 266 188 267 template< typename pass_type > 189 268 void PassVisitor< pass_type >::visit( TypedefDecl * node ) { 190 VISIT_BODY( node ); 269 VISIT_BODY( node ); 191 270 } 192 271 193 272 template< typename pass_type > 194 273 void PassVisitor< pass_type >::visit( AsmDecl * node ) { 195 VISIT_BODY( node ); 274 VISIT_BODY( node ); 196 275 } 197 276 … … 225 304 void PassVisitor< pass_type >::visit( ExprStmt * node ) { 226 305 VISIT_START( node ); 227 call_beginScope();228 306 229 307 visitExpression( node->get_expr() ); 230 308 231 call_endScope();232 309 VISIT_END( node ); 233 310 } … … 242 319 } 243 320 321 //-------------------------------------------------------------------------- 322 // AsmStmt 244 323 template< typename pass_type > 245 324 void PassVisitor< pass_type >::visit( AsmStmt * node ) { 246 VISIT_BODY( node ); 325 VISIT_BODY( node ); 326 } 327 328 template< typename pass_type > 329 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { 330 MUTATE_BODY( Statement, node ); 247 331 } 248 332 … … 251 335 template< typename pass_type > 252 336 void PassVisitor< pass_type >::visit( IfStmt * node ) { 253 VISIT_START( node ); 337 VISIT_START( node ); 254 338 255 339 visitExpression( node->get_condition() ); … … 262 346 template< typename pass_type > 263 347 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) { 264 MUTATE_START( node ); 348 MUTATE_START( node ); 265 349 266 350 node->set_condition( mutateExpression( node->get_condition() ) ); … … 275 359 template< typename pass_type > 276 360 void PassVisitor< pass_type >::visit( WhileStmt * node ) { 277 VISIT_START( node ); 361 VISIT_START( node ); 278 362 279 363 visitExpression( node->get_condition() ); … … 285 369 template< typename pass_type > 286 370 Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) { 287 MUTATE_START( node ); 371 MUTATE_START( node ); 288 372 289 373 node->set_condition( mutateExpression( node->get_condition() ) ); … … 294 378 295 379 //-------------------------------------------------------------------------- 296 // WhileStmt380 // ForStmt 297 381 template< typename pass_type > 298 382 void PassVisitor< pass_type >::visit( ForStmt * node ) { 299 VISIT_START( node ); 383 VISIT_START( node ); 300 384 301 385 acceptAll( node->get_initialization(), *this ); … … 309 393 template< typename pass_type > 310 394 Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) { 311 MUTATE_START( node ); 395 MUTATE_START( node ); 312 396 313 397 mutateAll( node->get_initialization(), *this ); … … 323 407 template< typename pass_type > 324 408 void PassVisitor< pass_type >::visit( SwitchStmt * node ) { 325 VISIT_START( node ); 409 VISIT_START( node ); 326 410 327 411 visitExpression( node->get_condition() ); … … 333 417 template< typename pass_type > 334 418 Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) { 335 MUTATE_START( node ); 336 419 MUTATE_START( node ); 420 337 421 node->set_condition( mutateExpression( node->get_condition() ) ); 338 422 mutateStatementList( node->get_statements() ); 339 423 340 424 MUTATE_END( Statement, node ); 341 425 } 342 426 343 427 //-------------------------------------------------------------------------- 344 // SwitchStmt428 // CaseStmt 345 429 template< typename pass_type > 346 430 void PassVisitor< pass_type >::visit( CaseStmt * node ) { 347 VISIT_START( node ); 348 431 VISIT_START( node ); 432 349 433 visitExpression( node->get_condition() ); 350 434 visitStatementList( node->get_statements() ); 351 435 352 436 VISIT_END( node ); 353 437 } … … 355 439 template< typename pass_type > 356 440 Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) { 357 MUTATE_START( node ); 358 441 MUTATE_START( node ); 442 359 443 node->set_condition( mutateExpression( node->get_condition() ) ); 360 444 mutateStatementList( node->get_statements() ); 361 445 362 446 MUTATE_END( Statement, node ); 363 447 } 364 448 449 //-------------------------------------------------------------------------- 450 // BranchStmt 365 451 template< typename pass_type > 366 452 void PassVisitor< pass_type >::visit( BranchStmt * node ) { 367 VISIT_BODY( node ); 453 VISIT_BODY( node ); 454 } 455 456 template< typename pass_type > 457 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { 458 MUTATE_BODY( Statement, node ); 368 459 } 369 460 … … 386 477 387 478 MUTATE_END( Statement, node ); 479 } 480 481 //-------------------------------------------------------------------------- 482 // ThrowStmt 483 484 template< typename pass_type > 485 void PassVisitor< pass_type >::visit( ThrowStmt * node ) { 486 VISIT_BODY( node ); 487 } 488 489 template< typename pass_type > 490 Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { 491 MUTATE_BODY( Statement, node ); 388 492 } 389 493 … … 396 500 maybeAccept( node->get_block(), *this ); 397 501 acceptAll( node->get_catchers(), *this ); 502 maybeAccept( node->get_finally(), *this ); 398 503 399 504 VISIT_END( node ); … … 406 511 node->set_block( maybeMutate( node->get_block(), *this ) ); 407 512 mutateAll( node->get_catchers(), *this ); 408 513 node->set_finally( maybeMutate( node->get_finally(), *this ) ); 514 409 515 MUTATE_END( Statement, node ); 410 516 } … … 416 522 VISIT_START( node ); 417 523 524 maybeAccept( node->get_decl(), *this ); 525 node->set_cond( visitExpression( node->get_cond() ) ); 418 526 node->set_body( visitStatement( node->get_body() ) ); 419 maybeAccept( node->get_decl(), *this );420 527 421 528 VISIT_END( node ); … … 425 532 Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) { 426 533 MUTATE_START( node ); 427 428 node->set_body( mutateStatement( node->get_body() ) ); 429 node->set_decl( maybeMutate( node->get_decl(), *this ) ); 430 534 535 node->set_decl( maybeMutate( node->get_decl(), *this ) ); 536 node->set_cond( mutateExpression( node->get_cond() ) ); 537 node->set_body( mutateStatement( node->get_body() ) ); 538 431 539 MUTATE_END( Statement, node ); 432 540 } … … 434 542 template< typename pass_type > 435 543 void PassVisitor< pass_type >::visit( FinallyStmt * node ) { 436 VISIT_BODY( node ); 544 VISIT_BODY( node ); 437 545 } 438 546 439 547 template< typename pass_type > 440 548 void PassVisitor< pass_type >::visit( NullStmt * node ) { 441 VISIT_BODY( node ); 549 VISIT_BODY( node ); 442 550 } 443 551 444 552 template< typename pass_type > 445 553 void PassVisitor< pass_type >::visit( DeclStmt * node ) { 446 VISIT_BODY( node ); 554 VISIT_BODY( node ); 447 555 } 448 556 449 557 template< typename pass_type > 450 558 void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) { 451 VISIT_BODY( node ); 559 VISIT_BODY( node ); 452 560 } 453 561 454 562 template< typename pass_type > 455 563 void PassVisitor< pass_type >::visit( ApplicationExpr * node ) { 456 VISIT_BODY( node ); 564 VISIT_BODY( node ); 457 565 } 458 566 … … 462 570 void PassVisitor< pass_type >::visit( UntypedExpr * node ) { 463 571 VISIT_START( node ); 572 573 // maybeAccept( node->get_env(), *this ); 574 maybeAccept( node->get_result(), *this ); 464 575 465 576 for ( auto expr : node->get_args() ) { … … 474 585 MUTATE_START( node ); 475 586 587 node->set_env( maybeMutate( node->get_env(), *this ) ); 588 node->set_result( maybeMutate( node->get_result(), *this ) ); 589 476 590 for ( auto& expr : node->get_args() ) { 477 591 expr = mutateExpression( expr ); … … 483 597 template< typename pass_type > 484 598 void PassVisitor< pass_type >::visit( NameExpr * node ) { 485 VISIT_BODY( node ); 599 VISIT_BODY( node ); 486 600 } 487 601 488 602 template< typename pass_type > 489 603 void PassVisitor< pass_type >::visit( CastExpr * node ) { 490 VISIT_BODY( node ); 604 VISIT_BODY( node ); 491 605 } 492 606 493 607 template< typename pass_type > 494 608 void PassVisitor< pass_type >::visit( AddressExpr * node ) { 495 VISIT_BODY( node ); 609 VISIT_BODY( node ); 496 610 } 497 611 498 612 template< typename pass_type > 499 613 void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) { 500 VISIT_BODY( node ); 614 VISIT_BODY( node ); 501 615 } 502 616 503 617 template< typename pass_type > 504 618 void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) { 505 VISIT_BODY( node ); 619 VISIT_BODY( node ); 506 620 } 507 621 508 622 template< typename pass_type > 509 623 void PassVisitor< pass_type >::visit( MemberExpr * node ) { 510 VISIT_BODY( node ); 624 VISIT_BODY( node ); 511 625 } 512 626 513 627 template< typename pass_type > 514 628 void PassVisitor< pass_type >::visit( VariableExpr * node ) { 515 VISIT_BODY( node ); 629 VISIT_BODY( node ); 516 630 } 517 631 518 632 template< typename pass_type > 519 633 void PassVisitor< pass_type >::visit( ConstantExpr * node ) { 520 VISIT_BODY( node ); 634 VISIT_BODY( node ); 521 635 } 522 636 523 637 template< typename pass_type > 524 638 void PassVisitor< pass_type >::visit( SizeofExpr * node ) { 525 VISIT_BODY( node ); 639 VISIT_BODY( node ); 526 640 } 527 641 528 642 template< typename pass_type > 529 643 void PassVisitor< pass_type >::visit( AlignofExpr * node ) { 530 VISIT_BODY( node ); 644 VISIT_BODY( node ); 531 645 } 532 646 533 647 template< typename pass_type > 534 648 void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) { 535 VISIT_BODY( node ); 649 VISIT_BODY( node ); 536 650 } 537 651 538 652 template< typename pass_type > 539 653 void PassVisitor< pass_type >::visit( OffsetofExpr * node ) { 540 VISIT_BODY( node ); 654 VISIT_BODY( node ); 541 655 } 542 656 543 657 template< typename pass_type > 544 658 void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) { 545 VISIT_BODY( node ); 659 VISIT_BODY( node ); 546 660 } 547 661 548 662 template< typename pass_type > 549 663 void PassVisitor< pass_type >::visit( AttrExpr * node ) { 550 VISIT_BODY( node ); 664 VISIT_BODY( node ); 551 665 } 552 666 553 667 template< typename pass_type > 554 668 void PassVisitor< pass_type >::visit( LogicalExpr * node ) { 555 VISIT_BODY( node ); 669 VISIT_BODY( node ); 556 670 } 557 671 558 672 template< typename pass_type > 559 673 void PassVisitor< pass_type >::visit( ConditionalExpr * node ) { 560 VISIT_BODY( node ); 674 VISIT_BODY( node ); 561 675 } 562 676 563 677 template< typename pass_type > 564 678 void PassVisitor< pass_type >::visit( CommaExpr * node ) { 565 VISIT_BODY( node ); 679 VISIT_BODY( node ); 566 680 } 567 681 568 682 template< typename pass_type > 569 683 void PassVisitor< pass_type >::visit( TypeExpr * node ) { 570 VISIT_BODY( node ); 684 VISIT_BODY( node ); 571 685 } 572 686 573 687 template< typename pass_type > 574 688 void PassVisitor< pass_type >::visit( AsmExpr * node ) { 575 VISIT_BODY( node ); 689 VISIT_BODY( node ); 576 690 } 577 691 578 692 template< typename pass_type > 579 693 void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) { 580 VISIT_BODY( node ); 694 VISIT_BODY( node ); 581 695 } 582 696 583 697 template< typename pass_type > 584 698 void PassVisitor< pass_type >::visit( ConstructorExpr * node ) { 585 VISIT_BODY( node ); 699 VISIT_BODY( node ); 586 700 } 587 701 588 702 template< typename pass_type > 589 703 void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) { 590 VISIT_BODY( node ); 591 } 592 593 template< typename pass_type > 594 void PassVisitor< pass_type >::visit( UntypedValofExpr * node ) { 595 VISIT_BODY( node ); 704 VISIT_BODY( node ); 596 705 } 597 706 598 707 template< typename pass_type > 599 708 void PassVisitor< pass_type >::visit( RangeExpr * node ) { 600 VISIT_BODY( node ); 709 VISIT_BODY( node ); 601 710 } 602 711 603 712 template< typename pass_type > 604 713 void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) { 605 VISIT_BODY( node ); 714 VISIT_BODY( node ); 606 715 } 607 716 608 717 template< typename pass_type > 609 718 void PassVisitor< pass_type >::visit( TupleExpr * node ) { 610 VISIT_BODY( node ); 719 VISIT_BODY( node ); 611 720 } 612 721 613 722 template< typename pass_type > 614 723 void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) { 615 VISIT_BODY( node ); 616 } 617 618 template< typename pass_type > 619 void PassVisitor< pass_type >::visit( MemberTupleExpr * node ) { 620 VISIT_BODY( node ); 724 VISIT_BODY( node ); 621 725 } 622 726 623 727 template< typename pass_type > 624 728 void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) { 625 VISIT_BODY( node ); 729 VISIT_BODY( node ); 626 730 } 627 731 … … 645 749 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { 646 750 MUTATE_START( node ); 647 751 648 752 // don't want statements from outer CompoundStmts to be added to this StmtExpr 649 753 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); … … 658 762 template< typename pass_type > 659 763 void PassVisitor< pass_type >::visit( UniqueExpr * node ) { 660 VISIT_BODY( node ); 764 VISIT_BODY( node ); 661 765 } 662 766 663 767 template< typename pass_type > 664 768 void PassVisitor< pass_type >::visit( VoidType * node ) { 665 VISIT_BODY( node ); 769 VISIT_BODY( node ); 666 770 } 667 771 668 772 template< typename pass_type > 669 773 void PassVisitor< pass_type >::visit( BasicType * node ) { 670 VISIT_BODY( node ); 774 VISIT_BODY( node ); 671 775 } 672 776 673 777 template< typename pass_type > 674 778 void PassVisitor< pass_type >::visit( PointerType * node ) { 675 VISIT_BODY( node ); 779 VISIT_BODY( node ); 676 780 } 677 781 678 782 template< typename pass_type > 679 783 void PassVisitor< pass_type >::visit( ArrayType * node ) { 680 VISIT_BODY( node ); 784 VISIT_BODY( node ); 681 785 } 682 786 683 787 template< typename pass_type > 684 788 void PassVisitor< pass_type >::visit( FunctionType * node ) { 685 VISIT_BODY( node ); 789 VISIT_BODY( node ); 686 790 } 687 791 688 792 template< typename pass_type > 689 793 void PassVisitor< pass_type >::visit( StructInstType * node ) { 690 VISIT_BODY( node ); 794 VISIT_BODY( node ); 691 795 } 692 796 693 797 template< typename pass_type > 694 798 void PassVisitor< pass_type >::visit( UnionInstType * node ) { 695 VISIT_BODY( node ); 799 VISIT_BODY( node ); 696 800 } 697 801 698 802 template< typename pass_type > 699 803 void PassVisitor< pass_type >::visit( EnumInstType * node ) { 700 VISIT_BODY( node ); 804 VISIT_BODY( node ); 701 805 } 702 806 703 807 template< typename pass_type > 704 808 void PassVisitor< pass_type >::visit( TraitInstType * node ) { 705 VISIT_BODY( node ); 809 VISIT_BODY( node ); 706 810 } 707 811 708 812 template< typename pass_type > 709 813 void PassVisitor< pass_type >::visit( TypeInstType * node ) { 710 VISIT_BODY( node ); 814 VISIT_BODY( node ); 711 815 } 712 816 713 817 template< typename pass_type > 714 818 void PassVisitor< pass_type >::visit( TupleType * node ) { 715 VISIT_BODY( node ); 819 VISIT_BODY( node ); 716 820 } 717 821 718 822 template< typename pass_type > 719 823 void PassVisitor< pass_type >::visit( TypeofType * node ) { 720 VISIT_BODY( node ); 824 VISIT_BODY( node ); 721 825 } 722 826 723 827 template< typename pass_type > 724 828 void PassVisitor< pass_type >::visit( AttrType * node ) { 725 VISIT_BODY( node ); 829 VISIT_BODY( node ); 726 830 } 727 831 728 832 template< typename pass_type > 729 833 void PassVisitor< pass_type >::visit( VarArgsType * node ) { 730 VISIT_BODY( node ); 834 VISIT_BODY( node ); 731 835 } 732 836 733 837 template< typename pass_type > 734 838 void PassVisitor< pass_type >::visit( ZeroType * node ) { 735 VISIT_BODY( node ); 839 VISIT_BODY( node ); 736 840 } 737 841 738 842 template< typename pass_type > 739 843 void PassVisitor< pass_type >::visit( OneType * node ) { 740 VISIT_BODY( node ); 844 VISIT_BODY( node ); 741 845 } 742 846 … … 763 867 template< typename pass_type > 764 868 void PassVisitor< pass_type >::visit( ListInit * node ) { 765 VISIT_BODY( node ); 869 VISIT_BODY( node ); 766 870 } 767 871 768 872 template< typename pass_type > 769 873 void PassVisitor< pass_type >::visit( ConstructorInit * node ) { 770 VISIT_BODY( node ); 874 VISIT_BODY( node ); 771 875 } 772 876 773 877 template< typename pass_type > 774 878 void PassVisitor< pass_type >::visit( Subrange * node ) { 775 VISIT_BODY( node ); 879 VISIT_BODY( node ); 776 880 } 777 881 778 882 template< typename pass_type > 779 883 void PassVisitor< pass_type >::visit( Constant * node ) { 780 VISIT_BODY( node ); 884 VISIT_BODY( node ); 781 885 } 782 886 … … 829 933 830 934 template< typename pass_type > 831 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {832 MUTATE_BODY( Statement, node );833 }834 835 template< typename pass_type >836 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {837 MUTATE_BODY( Statement, node );838 }839 840 template< typename pass_type >841 935 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { 842 936 MUTATE_BODY( Statement, node ); … … 974 1068 975 1069 template< typename pass_type > 976 Expression * PassVisitor< pass_type >::mutate( UntypedValofExpr * node ) {977 MUTATE_BODY( Expression, node );978 }979 980 template< typename pass_type >981 1070 Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) { 982 1071 MUTATE_BODY( Expression, node ); … … 995 1084 template< typename pass_type > 996 1085 Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) { 997 MUTATE_BODY( Expression, node );998 }999 1000 template< typename pass_type >1001 Expression * PassVisitor< pass_type >::mutate( MemberTupleExpr * node ) {1002 1086 MUTATE_BODY( Expression, node ); 1003 1087 } -
src/Common/PassVisitor.proto.h
re4d829b r579263a 1 1 #pragma once 2 3 template<typename pass_type> 4 class PassVisitor; 5 6 typedef std::function<void( void * )> cleanup_func_t; 7 8 class guard_value_impl { 9 public: 10 guard_value_impl() = default; 11 12 ~guard_value_impl() { 13 while( !cleanups.empty() ) { 14 auto& cleanup = cleanups.top(); 15 cleanup.func( cleanup.val ); 16 cleanups.pop(); 17 } 18 } 19 20 void push( cleanup_func_t && func, void* val ) { 21 cleanups.emplace( std::move(func), val ); 22 } 23 24 private: 25 struct cleanup_t { 26 cleanup_func_t func; 27 void * val; 28 29 cleanup_t( cleanup_func_t&& func, void * val ) : func(func), val(val) {} 30 }; 31 32 std::stack< cleanup_t > cleanups; 33 }; 34 35 typedef 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 }; 2 54 3 55 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4 56 // Deep magic (a.k.a template meta programming) to make the templated visitor work 5 57 // Basically the goal is to make 2 previsit_impl 6 // 1 - Use when a pass implements a valid previsit. This uses overloading which means the any overload of 58 // 1 - Use when a pass implements a valid previsit. This uses overloading which means the any overload of 7 59 // 'pass.previsit( node )' that compiles will be used for that node for that type 8 60 // This requires that this option only compile for passes that actually define an appropriate visit. … … 18 70 // Visit 19 71 template<typename pass_type, typename node_type> 20 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) {72 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) { 21 73 pass.previsit( node ); 22 74 } … … 27 79 28 80 template<typename pass_type, typename node_type> 29 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) {81 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) { 30 82 pass.postvisit( node ); 31 83 } … … 36 88 // Mutate 37 89 template<typename pass_type, typename node_type> 38 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) {90 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) { 39 91 return pass.premutate( node ); 40 92 } … … 45 97 46 98 template<typename return_type, typename pass_type, typename node_type> 47 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) {99 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) { 48 100 return pass.postmutate( node ); 49 101 } … … 54 106 // Begin/End scope 55 107 template<typename pass_type> 56 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) {108 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) { 57 109 pass.beginScope(); 58 110 } … … 63 115 64 116 template<typename pass_type> 65 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) {117 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) { 66 118 pass.endScope(); 67 119 } … … 73 125 #define FIELD_PTR( type, name ) \ 74 126 template<typename pass_type> \ 75 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; }\127 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; } \ 76 128 \ 77 129 template<typename pass_type> \ … … 81 133 FIELD_PTR( std::list< Statement* >, stmtsToAddBefore ) 82 134 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) 83 FIELD_PTR( bool, skip_children ) 135 FIELD_PTR( std::list< Declaration* >, declsToAddBefore ) 136 FIELD_PTR( std::list< Declaration* >, declsToAddAfter ) 137 FIELD_PTR( bool_ref, visit_children ) 138 FIELD_PTR( at_cleanup_t, at_cleanup ) 139 FIELD_PTR( PassVisitor<pass_type> * const, visitor )
Note:
See TracChangeset
for help on using the changeset viewer.