Changeset 45161b4d for src/SymTab


Ignore:
Timestamp:
Apr 13, 2016, 5:08:56 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
b11fac4
Parents:
3849857
Message:

generate implicit typedef right after sue name appears, further fixes storage allocation routines and comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r3849857 r45161b4d  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Apr  7 16:45:30 2016
    13 // Update Count     : 243
     12// Last Modified On : Wed Apr 13 16:39:30 2016
     13// Update Count     : 251
    1414//
    1515
     
    190190                AggDecl *handleAggregate( AggDecl * aggDecl );
    191191
     192                template<typename AggDecl>
     193                void addImplicitTypedef( AggDecl * aggDecl );
     194               
    192195                typedef std::map< std::string, std::pair< TypedefDecl *, int > > TypedefMap;
    193196                TypedefMap typedefNames;
     
    10141017        }
    10151018
    1016         // there may be typedefs nested within aggregates
    1017         // in order for everything to work properly, these
    1018         // should be removed as well
     1019        // there may be typedefs nested within aggregates in order for everything to work properly, these should be removed
     1020        // as well
    10191021        template<typename AggDecl>
    10201022        AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) {
     
    10301032                return aggDecl;
    10311033        }
    1032 
     1034       
     1035        template<typename AggDecl>
     1036        void EliminateTypedef::addImplicitTypedef( AggDecl * aggDecl ) {
     1037                if ( typedefNames.count( aggDecl->get_name() ) == 0 ) {
     1038                        Type *type;
     1039                        if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( aggDecl ) ) {
     1040                                type = new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() );
     1041                        } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( aggDecl ) ) {
     1042                                type = new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() );
     1043                        } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( aggDecl )  ) {
     1044                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
     1045                        } // if
     1046                        TypedefDecl * tyDecl = new TypedefDecl( aggDecl->get_name(), DeclarationNode::NoStorageClass, type );
     1047                        typedefNames[ aggDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
     1048                } // if
     1049        }
    10331050        Declaration *EliminateTypedef::mutate( StructDecl * structDecl ) {
     1051                addImplicitTypedef( structDecl );
    10341052                Mutator::mutate( structDecl );
    10351053                return handleAggregate( structDecl );
     
    10371055
    10381056        Declaration *EliminateTypedef::mutate( UnionDecl * unionDecl ) {
     1057                addImplicitTypedef( unionDecl );
    10391058                Mutator::mutate( unionDecl );
    10401059                return handleAggregate( unionDecl );
     
    10421061
    10431062        Declaration *EliminateTypedef::mutate( EnumDecl * enumDecl ) {
     1063                addImplicitTypedef( enumDecl );
    10441064                Mutator::mutate( enumDecl );
    10451065                return handleAggregate( enumDecl );
    10461066        }
    10471067
    1048                 Declaration *EliminateTypedef::mutate( TraitDecl * contextDecl ) {
     1068        Declaration *EliminateTypedef::mutate( TraitDecl * contextDecl ) {
    10491069                Mutator::mutate( contextDecl );
    10501070                return handleAggregate( contextDecl );
Note: See TracChangeset for help on using the changeset viewer.