Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/FixFunction.cc

    r954ef5b rc3acf0aa  
    2626        FixFunction::FixFunction() : isVoid( false ) {}
    2727
    28 
    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;
     28        DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
     29                ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type() ), 0, functionDecl->get_attributes() );
     30                functionDecl->get_attributes().clear();
     31                // can't delete function type because it may contain assertions, but can't transfer ownership without a clone since set_type checks for nullptr
     32                functionDecl->set_type( functionDecl->get_type()->clone() );
    3433                delete functionDecl;
    3534                return pointer;
    3635        }
    3736
    38         Type * FixFunction::postmutate(ArrayType *arrayType) {
     37        Type * FixFunction::mutate(VoidType *voidType) {
     38                isVoid = true;
     39                return voidType;
     40        }
     41
     42        Type * FixFunction::mutate(BasicType *basicType) {
     43                return basicType;
     44        }
     45
     46        Type * FixFunction::mutate(PointerType *pointerType) {
     47                return pointerType;
     48        }
     49
     50        Type * FixFunction::mutate(ArrayType *arrayType) {
    3951                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
    40                 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic );
    41                 arrayType->base = nullptr;
    42                 arrayType->dimension = nullptr;
     52                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->get_base()->clone()->acceptMutator( *this ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() );
    4353                delete arrayType;
    4454                return pointerType;
    4555        }
    4656
    47         void FixFunction::premutate(VoidType *) {
    48                 isVoid = true;
     57        Type * FixFunction::mutate(StructInstType *aggregateUseType) {
     58                return aggregateUseType;
    4959        }
    5060
    51         void FixFunction::premutate(FunctionDecl *) { visit_children = false; }
    52         void FixFunction::premutate(ArrayType *) { visit_children = false; }
    53         void FixFunction::premutate(BasicType *) { visit_children = false; }
    54         void FixFunction::premutate(PointerType *) { visit_children = false; }
    55         void FixFunction::premutate(StructInstType *) { visit_children = false; }
    56         void FixFunction::premutate(UnionInstType *) { visit_children = false; }
    57         void FixFunction::premutate(EnumInstType *) { visit_children = false; }
    58         void FixFunction::premutate(TraitInstType *) { visit_children = false; }
    59         void FixFunction::premutate(TypeInstType *) { visit_children = false; }
    60         void FixFunction::premutate(TupleType *) { visit_children = false; }
    61         void FixFunction::premutate(VarArgsType *) { visit_children = false; }
    62         void FixFunction::premutate(ZeroType *) { visit_children = false; }
    63         void FixFunction::premutate(OneType *) { visit_children = false; }
     61        Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
     62                return aggregateUseType;
     63        }
     64
     65        Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
     66                return aggregateUseType;
     67        }
     68
     69        Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
     70                return aggregateUseType;
     71        }
     72
     73        Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
     74                return aggregateUseType;
     75        }
     76
     77        Type * FixFunction::mutate(TupleType *tupleType) {
     78                return tupleType;
     79        }
     80
     81        Type * FixFunction::mutate(VarArgsType *varArgsType) {
     82                return varArgsType;
     83        }
     84
     85        Type * FixFunction::mutate(ZeroType *zeroType) {
     86                return zeroType;
     87        }
     88
     89        Type * FixFunction::mutate(OneType *oneType) {
     90                return oneType;
     91        }
    6492} // namespace SymTab
    6593
Note: See TracChangeset for help on using the changeset viewer.