Changeset 68f9c43 for src/SymTab


Ignore:
Timestamp:
Mar 16, 2018, 5:15:02 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
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)
Message:

First pass at delete removal

Location:
src/SymTab
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r6171841 r68f9c43  
    214214        void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) {
    215215                FunctionDecl * decl = functionDecl->clone();
    216                 delete decl->statements;
    217216                decl->statements = nullptr;
    218217                declsToAdd.push_back( decl );
     
    333332                } catch ( SemanticErrorException err ) {
    334333                        // okay if decl does not resolve - that means the function should not be generated
    335                         delete dcl;
    336334                }
    337335        }
     
    373371                        // do not carry over field's attributes to parameter type
    374372                        Type * paramType = field->get_type()->clone();
    375                         deleteAll( paramType->attributes );
    376373                        paramType->attributes.clear();
    377374                        // add a parameter corresponding to this field
     
    383380                        resolve( ctor );
    384381                }
    385                 delete memCtorType;
    386382        }
    387383
     
    511507                        // do not carry over field's attributes to parameter type
    512508                        Type * paramType = field->get_type()->clone();
    513                         deleteAll( paramType->attributes );
    514509                        paramType->attributes.clear();
    515510                        // add a parameter corresponding to this field
     
    524519                        break;
    525520                }
    526                 delete memCtorType;
    527521        }
    528522
  • src/SymTab/Autogen.h

    r6171841 r68f9c43  
    9797                // return if adding reference fails - will happen on default constructor and destructor
    9898                if ( isReferenceCtorDtor && ! srcParam.addReference() ) {
    99                         delete fExpr;
    10099                        return listInit;
    101100                }
  • src/SymTab/FixFunction.cc

    r6171841 r68f9c43  
    2828
    2929        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 };
    3634        }
    3735
     
    4240        Type * FixFunction::postmutate(ArrayType *arrayType) {
    4341                // 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 };
    4943        }
    5044
  • src/SymTab/Validate.cc

    r6171841 r68f9c43  
    310310                } // if
    311311                // Always remove the hoisted aggregate from the inner structure.
    312                 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion, false ); } );
     312                GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion ); } );
    313313        }
    314314
     
    365365                        // one void is the only thing in the list; remove it.
    366366                        if ( containsVoid ) {
    367                                 delete dwts.front();
    368367                                dwts.clear();
    369368                        }
     
    492491                                }
    493492                        }
    494                         deleteAll( td->assertions );
    495493                        td->assertions.clear();
    496494                } // for
     
    608606                                        // expand trait instance into all of its members
    609607                                        expandAssertions( traitInst, back_inserter( type->assertions ) );
    610                                         delete traitInst;
    611608                                } else {
    612609                                        // pass other assertions through
     
    682679                        SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    683680                }
    684                 filter( translationUnit, isTypedef, true );
     681                filter( translationUnit, isTypedef );
    685682        }
    686683
     
    696693                                ret->attributes.splice( ret->attributes.end(), typeInst->attributes );
    697694                        } else {
    698                                 deleteAll( ret->attributes );
    699695                                ret->attributes.clear();
    700696                        }
     
    709705                                mutateAll( rtt->parameters, *visitor );  // recursively fix typedefs on parameters
    710706                        } // if
    711                         delete typeInst;
    712707                        return ret;
    713708                } else {
     
    795790                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->get_type() ) ) { // function type?
    796791                        // 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() };
    802795                } // if
    803796                return objDecl;
     
    823816                        } // if
    824817                        return false;
    825                 }, true);
     818                } );
    826819                return compoundStmt;
    827820        }
     
    831824        template<typename AggDecl>
    832825        AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) {
    833                 filter( aggDecl->members, isTypedef, true );
     826                filter( aggDecl->members, isTypedef );
    834827                return aggDecl;
    835828        }
     
    961954                static UniqueName indexName( "_compLit" );
    962955
    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() };
    967958                declsToAddBefore.push_back( tempvar );                                  // add modified temporary to current block
    968959                return new VariableExpr( tempvar );
     
    1000991                        // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false.
    1001992                        ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
    1002                         deleteAll( retVals );
    1003993                        retVals.clear();
    1004994                        retVals.push_back( newRet );
     
    10411031                        if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( inner->arg ) ) {
    10421032                                if ( labels.count( nameExpr->name ) ) {
    1043                                         Label name = nameExpr->name;
    1044                                         delete addrExpr;
    1045                                         return new LabelAddressExpr( name );
     1033                                        return new LabelAddressExpr{ nameExpr->name };
    10461034                                }
    10471035                        }
Note: See TracChangeset for help on using the changeset viewer.