Changeset 535adab


Ignore:
Timestamp:
May 19, 2017, 11:56:51 AM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, 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:
44264c5, d298e03
Parents:
27caf8d (diff), 8905f56 (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 plg2:software/cfa/cfa-cc

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/GenType.cc

    r27caf8d r535adab  
    237237        void GenType::visit( TupleType * tupleType ) {
    238238                assertf( ! genC, "Tuple types should not reach code generation." );
    239                 Visitor::visit( tupleType );
    240239                unsigned int i = 0;
    241240                std::ostringstream os;
     
    245244                        os << genType( t, "", pretty, genC, lineMarks ) << (i == tupleType->size() ? "" : ", ");
    246245                }
    247                 os << "]";
     246                os << "] ";
    248247                typeString = os.str() + typeString;
    249248        }
  • src/GenPoly/InstantiateGeneric.cc

    r27caf8d r535adab  
    367367                                concDecl->set_body( inst->get_baseStruct()->has_body() );
    368368                                substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    369                                 DeclMutator::addDeclaration( concDecl );
    370                                 insert( inst, typeSubs, concDecl );
     369                                insert( inst, typeSubs, concDecl ); // must insert before recursion
    371370                                concDecl->acceptMutator( *this ); // recursively instantiate members
     371                                DeclMutator::addDeclaration( concDecl ); // must occur before declaration is added so that member instantiations appear first
    372372                        }
    373373                        StructInstType *newInst = new StructInstType( inst->get_qualifiers(), concDecl->get_name() );
     
    422422                                concDecl->set_body( inst->get_baseUnion()->has_body() );
    423423                                substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    424                                 DeclMutator::addDeclaration( concDecl );
    425                                 insert( inst, typeSubs, concDecl );
     424                                insert( inst, typeSubs, concDecl ); // must insert before recursion
    426425                                concDecl->acceptMutator( *this ); // recursively instantiate members
     426                                DeclMutator::addDeclaration( concDecl ); // must occur before declaration is added so that member instantiations appear first
    427427                        }
    428428                        UnionInstType *newInst = new UnionInstType( inst->get_qualifiers(), concDecl->get_name() );
  • src/InitTweak/FixInit.cc

    r27caf8d r535adab  
    619619
    620620                Expression * FixCopyCtors::mutate( StmtExpr * stmtExpr ) {
    621                         stmtExpr = safe_dynamic_cast< StmtExpr * >( Parent::mutate( stmtExpr ) );
     621                        // function call temporaries should be placed at statement-level, rather than nested inside of a new statement expression,
     622                        // since temporaries can be shared across sub-expressions, e.g.
     623                        //   [A, A] f();
     624                        //   g([A] x, [A] y);
     625                        //   f(g());
     626                        // f is executed once, so the return temporary is shared across the tuple constructors for x and y.
     627                        std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
     628                        for ( Statement *& stmt : stmts ) {
     629                                stmt = stmt->acceptMutator( *this );
     630                        } // for
     631                        // stmtExpr = safe_dynamic_cast< StmtExpr * >( Parent::mutate( stmtExpr ) );
    622632                        assert( stmtExpr->get_result() );
    623633                        Type * result = stmtExpr->get_result();
  • src/SynTree/TypeSubstitution.cc

    r27caf8d r535adab  
    166166                        boundVars.insert( (*tyvar )->get_name() );
    167167                } // for
    168         } // if
    169         // bind type variables from generic type instantiations
    170         std::list< TypeDecl* > *baseParameters = type->get_baseParameters();
    171         if ( baseParameters && ! type->get_parameters().empty() ) {
    172                 for ( std::list< TypeDecl* >::const_iterator tyvar = baseParameters->begin(); tyvar != baseParameters->end(); ++tyvar ) {
    173                         boundVars.insert( (*tyvar)->get_name() );
    174                 } // for
     168                // bind type variables from generic type instantiations
     169                std::list< TypeDecl* > *baseParameters = type->get_baseParameters();
     170                if ( baseParameters && ! type->get_parameters().empty() ) {
     171                        for ( std::list< TypeDecl* >::const_iterator tyvar = baseParameters->begin(); tyvar != baseParameters->end(); ++tyvar ) {
     172                                boundVars.insert( (*tyvar)->get_name() );
     173                        } // for
     174                } // if
    175175        } // if
    176176        Type *ret = Mutator::mutate( type );
  • src/main.cc

    r27caf8d r535adab  
    6464        bresolvep = false,
    6565        bboxp = false,
     66        bcodegenp = false,
    6667        ctorinitp = false,
    6768        declstatsp = false,
     
    306307                OPTPRINT( "box" )
    307308                GenPoly::box( translationUnit );
     309
     310                if ( bcodegenp ) {
     311                        dump( translationUnit );
     312                        return 0;
     313                }
    308314
    309315                if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
     
    377383
    378384        int c;
    379         while ( (c = getopt_long( argc, argv, "abBcdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
     385        while ( (c = getopt_long( argc, argv, "abBcCdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
    380386                switch ( c ) {
    381387                  case Ast:
     
    393399                  case 'c':                                                                             // print after constructors and destructors are replaced
    394400                        ctorinitp = true;
     401                        break;
     402                  case 'C':                                                                             // print before code generation
     403                        bcodegenp = true;
    395404                        break;
    396405                  case DeclStats:
Note: See TracChangeset for help on using the changeset viewer.