Ignore:
Timestamp:
Aug 8, 2017, 8:01:10 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
9a4e996
Parents:
4618319
Message:

Prevent reference types from being added in Box through createDeref

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Lvalue.cc

    r4618319 rb0440b7  
    9494        } // namespace
    9595
     96        static bool referencesEliminated = false;
     97        // used by UntypedExpr::createDeref to determine whether result type of dereference should be ReferenceType or value type.
     98        bool referencesPermissable() {
     99                return ! referencesEliminated;
     100        }
     101
    96102        void convertLvalue( std::list< Declaration* >& translationUnit ) {
    97103                std::cerr << "convertLvalue" << std::endl;
     
    106112                mutateAll( translationUnit, collapser );
    107113                mutateAll( translationUnit, elim );  // last because other passes need reference types to work
     114
     115                // from this point forward, no other pass should create reference types.
     116                referencesEliminated = true;
    108117        }
    109118
     
    134143                                // can be of differing lengths only when function is variadic
    135144                                assertf( ftype->get_parameters().size() == appExpr->get_args().size() || ftype->get_isVarArgs(), "ApplicationExpr args do not match formal parameter type." );
     145
     146                                if ( isIntrinsicReference( appExpr ) ) {
     147                                        // eliminate reference types from intrinsic applications - now they return lvalues
     148                                        appExpr->set_result( appExpr->get_result()->stripReferences() );
     149                                        appExpr->get_result()->set_lvalue( true );
     150                                }
     151
    136152                                unsigned int i = 0;
    137153                                const unsigned int end = ftype->get_parameters().size();
     
    252268                                }
    253269                                if ( ResolvExpr::typesCompatibleIgnoreQualifiers( castExpr->get_result(), castExpr->get_arg()->get_result()->stripReferences(), SymTab::Indexer() ) ) {
    254                                         // can remove cast if types are compatible
     270                                        // can remove cast if types are compatible, changing expression type to value type
     271                                        ret->set_result( castExpr->get_result()->clone() );
    255272                                        castExpr->set_arg( nullptr );
    256273                                        delete castExpr;
Note: See TracChangeset for help on using the changeset viewer.