Ignore:
Timestamp:
Sep 4, 2016, 10:34:35 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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:
f04a8b81
Parents:
28307be (diff), b16898e (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    r28307be r3403534  
    77#include "SynTree/Attribute.h"
    88#include "GenPoly/GenPoly.h"
     9#include "ResolvExpr/typeops.h"
    910
    1011namespace InitTweak {
     
    7980        public:
    8081                ExprImpl( Expression * expr ) : arg( expr ) {}
     82
     83                ~ExprImpl() { delete arg; }
    8184
    8285                virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
     
    122125
    123126        void InitExpander::clearArrayIndices() {
     127                deleteAll( indices );
    124128                indices.clear();
    125129        }
     
    228232                return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
    229233                        (objDecl->get_init() == NULL ||
    230                                 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) &&
    231                         ! isDesignated( objDecl->get_init() )
     234                                ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ))
    232235                        && objDecl->get_storageClass() != DeclarationNode::Extern;
    233236        }
     
    387390                virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; }
    388391                virtual void visit( UntypedExpr *untypedExpr ) { isConstExpr = false; }
    389                 virtual void visit( NameExpr *nameExpr ) { isConstExpr = false; }
    390                 virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }
     392                virtual void visit( NameExpr *nameExpr ) {
     393                        // xxx - temporary hack, because 0 and 1 really should be constexprs, even though they technically aren't in Cforall today
     394                        if ( nameExpr->get_name() != "0" && nameExpr->get_name() != "1" ) isConstExpr = false;
     395                }
     396                // virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }
     397                virtual void visit( AddressExpr *addressExpr ) {
     398                        // address of a variable or member expression is constexpr
     399                        Expression * arg = addressExpr->get_arg();
     400                        if ( ! dynamic_cast< NameExpr * >( arg) && ! dynamic_cast< VariableExpr * >( arg ) && ! dynamic_cast< MemberExpr * >( arg ) && ! dynamic_cast< UntypedMemberExpr * >( arg ) ) isConstExpr = false;
     401                }
    391402                virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
    392403                virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
    393404                virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; }
    394405                virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; }
    395                 virtual void visit( ConstantExpr *constantExpr ) { /* bottom out */ }
    396406                // these might be okay?
    397407                // virtual void visit( SizeofExpr *sizeofExpr );
     
    436446        bool isDestructor( const std::string & str ) { return str == "^?{}"; }
    437447        bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); }
     448
     449        FunctionDecl * isCopyConstructor( Declaration * decl ) {
     450                FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl );
     451                if ( ! function ) return 0;
     452                if ( ! isConstructor( function->get_name() ) ) return 0;
     453                FunctionType * ftype = function->get_functionType();
     454                if ( ftype->get_parameters().size() != 2 ) return 0;
     455
     456                Type * t1 = ftype->get_parameters().front()->get_type();
     457                Type * t2 = ftype->get_parameters().back()->get_type();
     458                PointerType * ptrType = dynamic_cast< PointerType * > ( t1 );
     459                assert( ptrType );
     460
     461                if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
     462                        return function;
     463                } else {
     464                        return 0;
     465                }
     466        }
    438467}
Note: See TracChangeset for help on using the changeset viewer.