Ignore:
Timestamp:
Aug 14, 2020, 11:40:04 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
5715d43, fa5e0112
Parents:
309d814 (diff), badd22f (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:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r309d814 r4c925cd  
    982982                ast::Pass<DeleteFinder_new> finder;
    983983                expr->accept( finder );
    984                 return finder.pass.delExpr;
     984                return finder.core.delExpr;
    985985        }
    986986
     
    10721072                /// Strips extraneous casts out of an expression
    10731073                struct StripCasts_new final {
    1074                         const ast::Expr * postmutate( const ast::CastExpr * castExpr ) {
     1074                        const ast::Expr * postvisit( const ast::CastExpr * castExpr ) {
    10751075                                if (
    1076                                         castExpr->isGenerated
     1076                                        castExpr->isGenerated == ast::GeneratedCast
    10771077                                        && typesCompatible( castExpr->arg->result, castExpr->result )
    10781078                                ) {
     
    11281128
    11291129                // set up and resolve expression cast to void
    1130                 ast::CastExpr * untyped = new ast::CastExpr{ expr };
     1130                ast::ptr< ast::CastExpr > untyped = new ast::CastExpr{ expr };
    11311131                CandidateRef choice = findUnfinishedKindExpression(
    11321132                        untyped, symtab, "", anyCandidate, ResolvMode::withAdjustment() );
     
    12361236
    12371237        public:
     1238                static size_t traceId;
    12381239                Resolver_new() = default;
    12391240                Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; }
     
    12661267                const ast::ConstructorInit * previsit( const ast::ConstructorInit * );
    12671268        };
    1268 
    1269         void resolve( std::list< ast::ptr<ast::Decl> >& translationUnit ) {
    1270                 ast::Pass< Resolver_new > resolver;
    1271                 accept_all( translationUnit, resolver );
     1269        // size_t Resolver_new::traceId = Stats::Heap::new_stacktrace_id("Resolver");
     1270
     1271        void resolve( std::list< ast::ptr< ast::Decl > >& translationUnit ) {
     1272                ast::Pass< Resolver_new >::run( translationUnit );
    12721273        }
    12731274
     
    12991300                // default value expressions have an environment which shouldn't be there and trips up
    13001301                // later passes.
    1301                 ast::ptr< ast::FunctionDecl > ret = functionDecl;
    1302                 for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) {
    1303                         const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i];
    1304 
    1305                         if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) {
     1302                assert( functionDecl->unique() );
     1303                ast::FunctionType * mutType = mutate( functionDecl->type.get() );
     1304
     1305                for ( unsigned i = 0 ; i < mutType->params.size() ; ++i ) {
     1306                        if ( const ast::ObjectDecl * obj = mutType->params[i].as< ast::ObjectDecl >() ) {
    13061307                                if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) {
    13071308                                        if ( init->value->env == nullptr ) continue;
    13081309                                        // clone initializer minus the initializer environment
    1309                                         ast::chain_mutate( ret )
    1310                                                 ( &ast::FunctionDecl::type )
    1311                                                         ( &ast::FunctionType::params )[i]
    1312                                                                 ( &ast::ObjectDecl::init )
    1313                                                                         ( &ast::SingleInit::value )->env = nullptr;
    1314 
    1315                                         assert( functionDecl != ret.get() || functionDecl->unique() );
    1316                                         assert( ! ret->type->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env );
     1310                                        auto mutParam = mutate( mutType->params[i].strict_as< ast::ObjectDecl >() );
     1311                                        auto mutInit = mutate( mutParam->init.strict_as< ast::SingleInit >() );
     1312                                        auto mutValue = mutate( mutInit->value.get() );
     1313
     1314                                        mutValue->env = nullptr;
     1315                                        mutInit->value = mutValue;
     1316                                        mutParam->init = mutInit;
     1317                                        mutType->params[i] = mutParam;
     1318
     1319                                        assert( ! mutType->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env);
    13171320                                }
    13181321                        }
    13191322                }
    1320                 return ret.get();
     1323                mutate_field(functionDecl, &ast::FunctionDecl::type, mutType);
     1324                return functionDecl;
    13211325        }
    13221326
     
    13411345                // in case we decide to allow nested enums
    13421346                GuardValue( inEnumDecl );
    1343                 inEnumDecl = false;
     1347                inEnumDecl = true;
    13441348        }
    13451349
Note: See TracChangeset for help on using the changeset viewer.