Ignore:
Timestamp:
Aug 30, 2016, 4:25:55 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
90e2334, fa463f1
Parents:
a2a8d2a6 (diff), ced2e989 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    ra2a8d2a6 r32a2a99  
    4949#include "SynTree/Statement.h"
    5050#include "SynTree/TypeSubstitution.h"
     51#include "GenPoly/ScopedMap.h"
    5152#include "Indexer.h"
    5253#include "FixFunction.h"
     
    162163                void addImplicitTypedef( AggDecl * aggDecl );
    163164
    164                 typedef std::map< std::string, std::pair< TypedefDecl *, int > > TypedefMap;
     165                typedef std::unique_ptr<TypedefDecl> TypedefDeclPtr;
     166                typedef GenPoly::ScopedMap< std::string, std::pair< TypedefDeclPtr, int > > TypedefMap;
    165167                typedef std::map< std::string, TypeDecl * > TypeDeclMap;
    166168                TypedefMap typedefNames;
     
    531533                        TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() );
    532534                        assert( base != typedeclNames.end() );
    533                         typeInst->set_baseType( base->second->clone() );
     535                        typeInst->set_baseType( base->second );
    534536                } // if
    535537                return typeInst;
     
    549551                        }
    550552                } else {
    551                         typedefNames[ tyDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
     553                        typedefNames[ tyDecl->get_name() ] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel );
    552554                } // if
    553555
     
    567569                        return new EnumDecl( enumDecl->get_name() );
    568570                } else {
    569                         return ret;
     571                        return ret->clone();
    570572                } // if
    571573        }
     
    582584
    583585        DeclarationWithType *EliminateTypedef::mutate( FunctionDecl * funcDecl ) {
    584                 TypedefMap oldNames = typedefNames;
     586                typedefNames.beginScope();
    585587                DeclarationWithType *ret = Mutator::mutate( funcDecl );
    586                 typedefNames = oldNames;
     588                typedefNames.endScope();
    587589                return ret;
    588590        }
    589591
    590592        DeclarationWithType *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
    591                 TypedefMap oldNames = typedefNames;
     593                typedefNames.beginScope();
    592594                DeclarationWithType *ret = Mutator::mutate( objDecl );
    593                 typedefNames = oldNames;
     595                typedefNames.endScope();
    594596                // is the type a function?
    595597                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) {
     
    603605
    604606        Expression *EliminateTypedef::mutate( CastExpr * castExpr ) {
    605                 TypedefMap oldNames = typedefNames;
     607                typedefNames.beginScope();
    606608                Expression *ret = Mutator::mutate( castExpr );
    607                 typedefNames = oldNames;
     609                typedefNames.endScope();
    608610                return ret;
    609611        }
    610612
    611613        CompoundStmt *EliminateTypedef::mutate( CompoundStmt * compoundStmt ) {
    612                 TypedefMap oldNames = typedefNames;
     614                typedefNames.beginScope();
    613615                scopeLevel += 1;
    614616                CompoundStmt *ret = Mutator::mutate( compoundStmt );
     
    625627                        i = next;
    626628                } // while
    627                 typedefNames = oldNames;
     629                typedefNames.endScope();
    628630                return ret;
    629631        }
     
    656658                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
    657659                        } // if
    658                         TypedefDecl * tyDecl = new TypedefDecl( aggDecl->get_name(), DeclarationNode::NoStorageClass, type );
    659                         typedefNames[ aggDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
     660                        TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode::NoStorageClass, type ) );
     661                        typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );
    660662                } // if
    661663        }
Note: See TracChangeset for help on using the changeset viewer.