Changeset ddae809 for src/InitTweak
- Timestamp:
- Nov 2, 2017, 3:34:40 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:
- f9941ff
- Parents:
- 000178a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r000178a rddae809 501 501 } 502 502 503 // to prevent warnings (‘_unq0’ may be used uninitialized in this function), 504 // insert an appropriate zero initializer for UniqueExpr temporaries. 505 Initializer * makeInit( Type * t ) { 506 if ( StructInstType * inst = dynamic_cast< StructInstType * >( t ) ) { 507 // initizer for empty struct must be empty 508 if ( inst->baseStruct->members.empty() ) return new ListInit({}); 509 } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( t ) ) { 510 // initizer for empty union must be empty 511 if ( inst->baseUnion->members.empty() ) return new ListInit({}); 512 } 513 514 return new ListInit( { new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ) ) } ); 515 } 516 503 517 void ResolveCopyCtors::postvisit( UniqueExpr * unqExpr ) { 504 518 if ( vars.count( unqExpr->get_id() ) ) { … … 515 529 } else { 516 530 // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression 517 unqExpr->set_object( ObjectDecl::newObject( toString("_unq", unqExpr->get_id()), unqExpr->get_result()->clone(), nullptr) );531 unqExpr->set_object( ObjectDecl::newObject( toString("_unq", unqExpr->get_id()), unqExpr->get_result()->clone(), makeInit( unqExpr->get_result() ) ) ); 518 532 unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) ); 519 533 }
Note: See TracChangeset
for help on using the changeset viewer.