Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    r1ba88a0 r79970ed  
    77#include "SynTree/Attribute.h"
    88#include "GenPoly/GenPoly.h"
    9 #include "ResolvExpr/typeops.h"
    109
    1110namespace InitTweak {
     
    8079        public:
    8180                ExprImpl( Expression * expr ) : arg( expr ) {}
    82 
    83                 ~ExprImpl() { delete arg; }
    8481
    8582                virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
     
    125122
    126123        void InitExpander::clearArrayIndices() {
    127                 deleteAll( indices );
    128124                indices.clear();
    129125        }
     
    232228                return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
    233229                        (objDecl->get_init() == NULL ||
    234                                 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ))
     230                                ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) &&
     231                        ! isDesignated( objDecl->get_init() )
    235232                        && objDecl->get_storageClass() != DeclarationNode::Extern;
    236233        }
     
    390387                virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; }
    391388                virtual void visit( UntypedExpr *untypedExpr ) { 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                 }
     389                virtual void visit( NameExpr *nameExpr ) { isConstExpr = false; }
     390                virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }
    402391                virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
    403392                virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
    404393                virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; }
    405394                virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; }
     395                virtual void visit( ConstantExpr *constantExpr ) { /* bottom out */ }
    406396                // these might be okay?
    407397                // virtual void visit( SizeofExpr *sizeofExpr );
     
    446436        bool isDestructor( const std::string & str ) { return str == "^?{}"; }
    447437        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         }
    467438}
Note: See TracChangeset for help on using the changeset viewer.