Changeset 1cb934d for src/InitTweak
- Timestamp:
- Nov 30, 2017, 5:11:59 PM (7 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:
- 1fbeebd
- Parents:
- fd236ed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixGlobalInit.cc
rfd236ed r1cb934d 20 20 #include <algorithm> // for replace_if 21 21 22 #include "Common/PassVisitor.h" 22 23 #include "Common/SemanticError.h" // for SemanticError 23 24 #include "Common/UniqueName.h" // for UniqueName … … 35 36 36 37 namespace InitTweak { 37 class GlobalFixer : public Visitor{38 class GlobalFixer : public WithShortCircuiting { 38 39 public: 39 40 GlobalFixer( const std::string & name, bool inLibrary ); 40 41 41 v irtual voidvisit( ObjectDecl *objDecl );42 v irtual voidvisit( FunctionDecl *functionDecl );43 v irtual voidvisit( StructDecl *aggregateDecl );44 v irtual voidvisit( UnionDecl *aggregateDecl );45 v irtual voidvisit( EnumDecl *aggregateDecl );46 v irtual voidvisit( TraitDecl *aggregateDecl );47 v irtual voidvisit( TypeDecl *typeDecl );42 void previsit( ObjectDecl *objDecl ); 43 void previsit( FunctionDecl *functionDecl ); 44 void previsit( StructDecl *aggregateDecl ); 45 void previsit( UnionDecl *aggregateDecl ); 46 void previsit( EnumDecl *aggregateDecl ); 47 void previsit( TraitDecl *aggregateDecl ); 48 void previsit( TypeDecl *typeDecl ); 48 49 49 50 UniqueName tempNamer; … … 53 54 54 55 void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ) { 55 GlobalFixer fixer( name, inLibrary ); 56 acceptAll( translationUnit, fixer ); 56 PassVisitor<GlobalFixer> visitor( name, inLibrary ); 57 acceptAll( translationUnit, visitor ); 58 GlobalFixer & fixer = visitor.pass; 57 59 // don't need to include function if it's empty 58 60 if ( fixer.initFunction->get_statements()->get_kids().empty() ) { … … 98 100 } 99 101 100 void GlobalFixer:: visit( ObjectDecl *objDecl ) {102 void GlobalFixer::previsit( ObjectDecl *objDecl ) { 101 103 std::list< Statement * > & initStatements = initFunction->get_statements()->get_kids(); 102 104 std::list< Statement * > & destroyStatements = destroyFunction->get_statements()->get_kids(); … … 134 136 135 137 // only modify global variables 136 void GlobalFixer:: visit( __attribute__((unused)) FunctionDecl *functionDecl ) {}137 void GlobalFixer:: visit( __attribute__((unused)) StructDecl *aggregateDecl ) {}138 void GlobalFixer:: visit( __attribute__((unused)) UnionDecl *aggregateDecl ) {}139 void GlobalFixer:: visit( __attribute__((unused)) EnumDecl *aggregateDecl ) {}140 void GlobalFixer:: visit( __attribute__((unused)) TraitDecl *aggregateDecl ) {}141 void GlobalFixer:: visit( __attribute__((unused)) TypeDecl *typeDecl ) {}138 void GlobalFixer::previsit( FunctionDecl * ) { visit_children = false; } 139 void GlobalFixer::previsit( StructDecl * ) { visit_children = false; } 140 void GlobalFixer::previsit( UnionDecl * ) { visit_children = false; } 141 void GlobalFixer::previsit( EnumDecl * ) { visit_children = false; } 142 void GlobalFixer::previsit( TraitDecl * ) { visit_children = false; } 143 void GlobalFixer::previsit( TypeDecl * ) { visit_children = false; } 142 144 143 145 } // namespace InitTweak
Note: See TracChangeset
for help on using the changeset viewer.