Ignore:
Timestamp:
Oct 29, 2019, 4:01:24 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
773db65, 9421f3d8
Parents:
7951100 (diff), 8364209 (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/SynTree/ApplicationExpr.cc

    r7951100 rb067d9b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Apr 26 12:41:06 2016
    13 // Update Count     : 4
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Aug 12 14:28:00 2019
     13// Update Count     : 5
    1414//
    1515
     
    2525#include "Declaration.h"         // for Declaration
    2626#include "Expression.h"          // for ParamEntry, ApplicationExpr, Expression
     27#include "InitTweak/InitTweak.h" // for getFunction
    2728#include "ResolvExpr/typeops.h"  // for extractResultType
    2829#include "Type.h"                // for Type, PointerType, FunctionType
    2930
     31ParamEntry::ParamEntry( UniqueId decl, Declaration * declptr, Type * actualType, Type * formalType, Expression* expr )
     32                : decl( decl ), declptr( declptr ), actualType( actualType ), formalType( formalType ), expr( expr ) {
     33        }
     34
    3035ParamEntry::ParamEntry( const ParamEntry &other ) :
    31                 decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ), inferParams( new InferredParams( *other.inferParams ) ) {
    32 }
    33 
    34 ParamEntry &ParamEntry::operator=( const ParamEntry &other ) {
    35         if ( &other == this ) return *this;
    36         decl = other.decl;
    37         // xxx - this looks like a memory leak
    38         actualType = maybeClone( other.actualType );
    39         formalType = maybeClone( other.formalType );
    40         expr = maybeClone( other.expr );
    41         *inferParams = *other.inferParams;
    42         return *this;
     36                decl( other.decl ), declptr( maybeClone( other.declptr ) ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ) {
    4337}
    4438
    4539ParamEntry::~ParamEntry() {
     40        delete declptr;
    4641        delete actualType;
    4742        delete formalType;
     
    5045
    5146ParamEntry::ParamEntry( ParamEntry && other ) :
    52                 decl( other.decl ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr ), inferParams( std::move( other.inferParams ) ) {
    53         other.actualType = nullptr;
    54         other.formalType = nullptr;
    55         other.expr = nullptr;
     47                decl( other.decl ), declptr( other.declptr ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr ) {
     48        new (&other) ParamEntry();
    5649}
    5750
    5851ParamEntry & ParamEntry::operator=( ParamEntry && other ) {
    5952        if ( &other == this ) return *this;
    60         delete actualType;
    61         delete formalType;
    62         delete expr;
    63         decl = other.decl;
    64         actualType = other.actualType;
    65         formalType = other.formalType;
    66         expr = other.expr;
    67         other.actualType = nullptr;
    68         other.formalType = nullptr;
    69         other.expr = nullptr;
    70         inferParams = std::move( other.inferParams );
     53        this->~ParamEntry();
     54        new (this) ParamEntry(other.decl, other.declptr, other.actualType, other.formalType, other.expr);
     55        new (&other) ParamEntry();
     56
    7157        return *this;
    7258}
     
    9177}
    9278
     79bool ApplicationExpr::get_lvalue() const {
     80        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     81        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     82        if ( const DeclarationWithType * func = InitTweak::getFunction( this ) ) {
     83                return func->linkage == LinkageSpec::Intrinsic && lvalueFunctions.count(func->name);
     84        }
     85        return false;
     86}
     87
    9388void ApplicationExpr::print( std::ostream &os, Indenter indent ) const {
    9489        os << "Application of" << std::endl << indent+1;
Note: See TracChangeset for help on using the changeset viewer.