Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    ref9988b r37cdd97  
    2020
    2121#include "AST/Attribute.hpp"
    22 #include "AST/Copy.hpp"
    2322#include "AST/Decl.hpp"
    2423#include "AST/Expr.hpp"
     
    167166                        LinkageSpec::Spec( node->linkage.val ),
    168167                        bfwd,
    169                         type->clone(),
     168                        type,
    170169                        init,
    171170                        attr,
     
    588587                assert( tgtResnSlots.empty() );
    589588
    590                 if ( srcInferred.data.inferParams ) {
     589                if ( srcInferred.mode == ast::Expr::InferUnion::Params ) {
    591590                        const ast::InferredParams &srcParams = srcInferred.inferParams();
    592591                        for (auto & srcParam : srcParams) {
     
    594593                                        srcParam.second.decl,
    595594                                        get<Declaration>().accept1(srcParam.second.declptr),
    596                                         get<Type>().accept1(srcParam.second.actualType)->clone(),
    597                                         get<Type>().accept1(srcParam.second.formalType)->clone(),
    598                                         get<Expression>().accept1(srcParam.second.expr)->clone()
     595                                        get<Type>().accept1(srcParam.second.actualType),
     596                                        get<Type>().accept1(srcParam.second.formalType),
     597                                        get<Expression>().accept1(srcParam.second.expr)
    599598                                ));
    600599                                assert(res.second);
    601600                        }
    602                 }
    603                 if ( srcInferred.data.resnSlots ) {
     601                } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots  ) {
    604602                        const ast::ResnSlots &srcSlots = srcInferred.resnSlots();
    605603                        for (auto srcSlot : srcSlots) {
     
    622620
    623621                tgt->result = get<Type>().accept1(src->result);
    624                 // Unconditionally use a clone of the result type.
    625                 // We know this will leak some objects: much of the immediate conversion result.
    626                 // In some cases, using the conversion result directly gives unintended object sharing.
    627                 // A parameter (ObjectDecl, a child of a FunctionType) is shared by the weak-ref cache.
    628                 // But tgt->result must be fully owned privately by tgt.
    629                 // Applying these conservative copies here means
    630                 // - weak references point at the declaration's copy, not these expr.result copies (good)
    631                 // - we copy more objects than really needed (bad, tolerated)
    632                 if (tgt->result) {
    633                         tgt->result = tgt->result->clone();
    634                 }
    635622                return visitBaseExpr_skipResultType(src, tgt);
    636623        }
     
    992979
    993980        const ast::Expr * visit( const ast::StmtExpr * node ) override final {
    994                 auto stmts = node->stmts;
    995                 // disable sharing between multiple StmtExprs explicitly.
    996                 if (inCache(stmts)) {
    997                         stmts = ast::deepCopy(stmts.get());
    998                 }
    999981                auto rslt = new StmtExpr(
    1000                         get<CompoundStmt>().accept1(stmts)
     982                        get<CompoundStmt>().accept1(node->stmts)
    1001983                );
    1002984
     
    20041986
    20051987                assert( oldInferParams.empty() || oldResnSlots.empty() );
    2006                 // assert( newInferred.mode == ast::Expr::InferUnion::Empty );
     1988                assert( newInferred.mode == ast::Expr::InferUnion::Empty );
    20071989
    20081990                if ( !oldInferParams.empty() ) {
     
    21352117                                old->location,
    21362118                                GET_ACCEPT_1(member, DeclWithType),
    2137                                 GET_ACCEPT_1(aggregate, Expr),
    2138                                 ast::MemberExpr::NoOpConstructionChosen
     2119                                GET_ACCEPT_1(aggregate, Expr)
    21392120                        )
    21402121                );
Note: See TracChangeset for help on using the changeset viewer.