Changes in src/SymTab/Validate.cc [b2da0574:42107b4]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rb2da0574 r42107b4 48 48 #include "CodeGen/CodeGenerator.h" // for genName 49 49 #include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign 50 #include "Common/GC.h" // for new_static_root, register_static_root 50 51 #include "Common/PassVisitor.h" // for PassVisitor, WithDeclsToAdd 51 52 #include "Common/ScopedMap.h" // for ScopedMap … … 199 200 void addImplicitTypedef( AggDecl * aggDecl ); 200 201 201 typedef std::unique_ptr<TypedefDecl> TypedefDeclPtr; 202 typedef ScopedMap< std::string, std::pair< TypedefDeclPtr, int > > TypedefMap; 202 typedef ScopedMap< std::string, std::pair< TypedefDecl*, int > > TypedefMap; 203 203 typedef std::map< std::string, TypeDecl * > TypeDeclMap; 204 204 TypedefMap typedefNames; … … 312 312 } // if 313 313 // Always remove the hoisted aggregate from the inner structure. 314 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist , false); } );314 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist ); } ); 315 315 } 316 316 … … 373 373 // one void is the only thing in the list; remove it. 374 374 if ( containsVoid ) { 375 delete dwts.front();376 375 dwts.clear(); 377 376 } … … 500 499 } 501 500 } 502 deleteAll( td->assertions );503 501 td->assertions.clear(); 504 502 } // for … … 616 614 // expand trait instance into all of its members 617 615 expandAssertions( traitInst, back_inserter( type->assertions ) ); 618 delete traitInst;619 616 } else { 620 617 // pass other assertions through … … 688 685 // grab and remember declaration of size_t 689 686 SizeType = eliminator.pass.typedefNames["size_t"].first->get_base()->clone(); 687 GC::get().register_static_root( SizeType ); 690 688 } else { 691 689 // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong 692 690 // eventually should have a warning for this case. 693 SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); 694 } 695 filter( translationUnit, isTypedef, true ); 691 SizeType = 692 new_static_root<BasicType>( Type::Qualifiers(), BasicType::LongUnsignedInt ); 693 } 694 filter( translationUnit, isTypedef ); 696 695 } 697 696 … … 707 706 ret->attributes.splice( ret->attributes.end(), typeInst->attributes ); 708 707 } else { 709 deleteAll( ret->attributes );710 708 ret->attributes.clear(); 711 709 } … … 720 718 mutateAll( rtt->parameters, *visitor ); // recursively fix typedefs on parameters 721 719 } // if 722 delete typeInst;723 720 return ret; 724 721 } else { … … 762 759 } 763 760 } else { 764 typedefNames[ tyDecl->get_name() ] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel );761 typedefNames[ tyDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel ); 765 762 } // if 766 763 … … 806 803 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->get_type() ) ) { // function type? 807 804 // replace the current object declaration with a function declaration 808 FunctionDecl * newDecl = new FunctionDecl( objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() ); 809 objDecl->get_attributes().clear(); 810 objDecl->set_type( nullptr ); 811 delete objDecl; 812 return newDecl; 805 return new FunctionDecl{ 806 objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), 807 funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() }; 813 808 } // if 814 809 return objDecl; … … 834 829 } // if 835 830 return false; 836 } , true);831 } ); 837 832 return compoundStmt; 838 833 } … … 842 837 template<typename AggDecl> 843 838 AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) { 844 filter( aggDecl->members, isTypedef , true);839 filter( aggDecl->members, isTypedef ); 845 840 return aggDecl; 846 841 } … … 857 852 type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ); 858 853 } // if 859 TypedefDecl Ptr tyDecl( new TypedefDecl( aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() ) );860 typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );854 TypedefDecl* tyDecl = new TypedefDecl{ aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() }; 855 typedefNames[ aggDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel ); 861 856 } // if 862 857 } … … 972 967 static UniqueName indexName( "_compLit" ); 973 968 974 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() ); 975 compLitExpr->set_result( nullptr ); 976 compLitExpr->set_initializer( nullptr ); 977 delete compLitExpr; 969 ObjectDecl * tempvar = new ObjectDecl{ 970 indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() }; 978 971 declsToAddBefore.push_back( tempvar ); // add modified temporary to current block 979 972 return new VariableExpr( tempvar ); … … 1011 1004 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 1012 1005 ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 1013 deleteAll( retVals );1014 1006 retVals.clear(); 1015 1007 retVals.push_back( newRet ); … … 1052 1044 if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( inner->arg ) ) { 1053 1045 if ( labels.count( nameExpr->name ) ) { 1054 Label name = nameExpr->name; 1055 delete addrExpr; 1056 return new LabelAddressExpr( name ); 1046 return new LabelAddressExpr{ nameExpr->name }; 1057 1047 } 1058 1048 }
Note:
See TracChangeset
for help on using the changeset viewer.