Changeset 68f9c43 for src/SymTab
- Timestamp:
- Mar 16, 2018, 5:15:02 PM (7 years ago)
- Branches:
- new-env, with_gc
- Children:
- 8d7bef2
- Parents:
- 6171841
- git-author:
- Aaron Moss <a3moss@…> (03/16/18 17:04:24)
- git-committer:
- Aaron Moss <a3moss@…> (03/16/18 17:15:02)
- Location:
- src/SymTab
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r6171841 r68f9c43 214 214 void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) { 215 215 FunctionDecl * decl = functionDecl->clone(); 216 delete decl->statements;217 216 decl->statements = nullptr; 218 217 declsToAdd.push_back( decl ); … … 333 332 } catch ( SemanticErrorException err ) { 334 333 // okay if decl does not resolve - that means the function should not be generated 335 delete dcl;336 334 } 337 335 } … … 373 371 // do not carry over field's attributes to parameter type 374 372 Type * paramType = field->get_type()->clone(); 375 deleteAll( paramType->attributes );376 373 paramType->attributes.clear(); 377 374 // add a parameter corresponding to this field … … 383 380 resolve( ctor ); 384 381 } 385 delete memCtorType;386 382 } 387 383 … … 511 507 // do not carry over field's attributes to parameter type 512 508 Type * paramType = field->get_type()->clone(); 513 deleteAll( paramType->attributes );514 509 paramType->attributes.clear(); 515 510 // add a parameter corresponding to this field … … 524 519 break; 525 520 } 526 delete memCtorType;527 521 } 528 522 -
src/SymTab/Autogen.h
r6171841 r68f9c43 97 97 // return if adding reference fails - will happen on default constructor and destructor 98 98 if ( isReferenceCtorDtor && ! srcParam.addReference() ) { 99 delete fExpr;100 99 return listInit; 101 100 } -
src/SymTab/FixFunction.cc
r6171841 r68f9c43 28 28 29 29 DeclarationWithType * FixFunction::postmutate(FunctionDecl *functionDecl) { 30 // can't delete function type because it may contain assertions, so transfer ownership to new object 31 ObjectDecl *pointer = new ObjectDecl( functionDecl->name, functionDecl->get_storageClasses(), functionDecl->linkage, nullptr, new PointerType( Type::Qualifiers(), functionDecl->type ), nullptr, functionDecl->attributes ); 32 functionDecl->attributes.clear(); 33 functionDecl->type = nullptr; 34 delete functionDecl; 35 return pointer; 30 return new ObjectDecl{ 31 functionDecl->name, functionDecl->get_storageClasses(), functionDecl->linkage, nullptr, 32 new PointerType{ Type::Qualifiers(), functionDecl->type }, 33 nullptr, functionDecl->attributes }; 36 34 } 37 35 … … 42 40 Type * FixFunction::postmutate(ArrayType *arrayType) { 43 41 // need to recursively mutate the base type in order for multi-dimensional arrays to work. 44 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic ); 45 arrayType->base = nullptr; 46 arrayType->dimension = nullptr; 47 delete arrayType; 48 return pointerType; 42 return new PointerType{ arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic }; 49 43 } 50 44 -
src/SymTab/Validate.cc
r6171841 r68f9c43 310 310 } // if 311 311 // Always remove the hoisted aggregate from the inner structure. 312 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion , false); } );312 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion ); } ); 313 313 } 314 314 … … 365 365 // one void is the only thing in the list; remove it. 366 366 if ( containsVoid ) { 367 delete dwts.front();368 367 dwts.clear(); 369 368 } … … 492 491 } 493 492 } 494 deleteAll( td->assertions );495 493 td->assertions.clear(); 496 494 } // for … … 608 606 // expand trait instance into all of its members 609 607 expandAssertions( traitInst, back_inserter( type->assertions ) ); 610 delete traitInst;611 608 } else { 612 609 // pass other assertions through … … 682 679 SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); 683 680 } 684 filter( translationUnit, isTypedef , true);681 filter( translationUnit, isTypedef ); 685 682 } 686 683 … … 696 693 ret->attributes.splice( ret->attributes.end(), typeInst->attributes ); 697 694 } else { 698 deleteAll( ret->attributes );699 695 ret->attributes.clear(); 700 696 } … … 709 705 mutateAll( rtt->parameters, *visitor ); // recursively fix typedefs on parameters 710 706 } // if 711 delete typeInst;712 707 return ret; 713 708 } else { … … 795 790 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->get_type() ) ) { // function type? 796 791 // replace the current object declaration with a function declaration 797 FunctionDecl * newDecl = new FunctionDecl( objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() ); 798 objDecl->get_attributes().clear(); 799 objDecl->set_type( nullptr ); 800 delete objDecl; 801 return newDecl; 792 return new FunctionDecl{ 793 objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), 794 funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() }; 802 795 } // if 803 796 return objDecl; … … 823 816 } // if 824 817 return false; 825 } , true);818 } ); 826 819 return compoundStmt; 827 820 } … … 831 824 template<typename AggDecl> 832 825 AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) { 833 filter( aggDecl->members, isTypedef , true);826 filter( aggDecl->members, isTypedef ); 834 827 return aggDecl; 835 828 } … … 961 954 static UniqueName indexName( "_compLit" ); 962 955 963 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() ); 964 compLitExpr->set_result( nullptr ); 965 compLitExpr->set_initializer( nullptr ); 966 delete compLitExpr; 956 ObjectDecl * tempvar = new ObjectDecl{ 957 indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() }; 967 958 declsToAddBefore.push_back( tempvar ); // add modified temporary to current block 968 959 return new VariableExpr( tempvar ); … … 1000 991 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 1001 992 ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 1002 deleteAll( retVals );1003 993 retVals.clear(); 1004 994 retVals.push_back( newRet ); … … 1041 1031 if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( inner->arg ) ) { 1042 1032 if ( labels.count( nameExpr->name ) ) { 1043 Label name = nameExpr->name; 1044 delete addrExpr; 1045 return new LabelAddressExpr( name ); 1033 return new LabelAddressExpr{ nameExpr->name }; 1046 1034 } 1047 1035 }
Note: See TracChangeset
for help on using the changeset viewer.