Changeset 37024fd for src/InitTweak/FixGlobalInit.cc
- Timestamp:
- May 6, 2016, 3:01:28 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 03e5d14
- Parents:
- 9a92216
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixGlobalInit.cc
r9a92216 r37024fd 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 1 3:51:00201612 // Last Modified On : Fri May 06 14:59:26 2016 13 13 // Update Count : 2 14 14 // … … 30 30 class GlobalFixer : public Visitor { 31 31 public: 32 GlobalFixer( );32 GlobalFixer( const std::string & name ); 33 33 34 34 virtual void visit( ObjectDecl *objDecl ); … … 41 41 42 42 UniqueName tempNamer; 43 CompoundStmt * block;43 FunctionDecl * initFunction; 44 44 }; 45 45 … … 88 88 89 89 void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name ) { 90 GlobalFixer fixer ;90 GlobalFixer fixer( name ); 91 91 acceptAll( translationUnit, fixer ); 92 // attribute only appears on the forward declaration, so need to make two function decls: 93 // one with the body, one with the attribute. 94 FunctionDecl * initFunction = new FunctionDecl( initName( name ), DeclarationNode::NoStorageClass, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), 0, false, false ); 95 FunctionDecl * forward = initFunction->clone(); 96 forward->set_attribute( FunctionDecl::Constructor ); 97 initFunction->set_statements( fixer.block ); 98 translationUnit.push_back( forward ); 99 translationUnit.push_back( initFunction ); 92 translationUnit.push_back( fixer.initFunction ); 100 93 } 101 94 … … 109 102 } 110 103 111 GlobalFixer::GlobalFixer() : tempNamer( "_global_init" ), block( new CompoundStmt( noLabels ) ) { 104 GlobalFixer::GlobalFixer( const std::string & name ) : tempNamer( "_global_init" ) { 105 initFunction = new FunctionDecl( initName( name ), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Constructor ); 112 106 } 113 107 114 108 void GlobalFixer::visit( ObjectDecl *objDecl ) { 115 std::list< Statement * > & statements = block->get_kids();109 std::list< Statement * > & statements = initFunction->get_statements()->get_kids(); 116 110 117 111 if ( objDecl->get_init() == NULL ) return;
Note: See TracChangeset
for help on using the changeset viewer.