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