Changeset 3ed994e


Ignore:
Timestamp:
May 29, 2018, 2:02:47 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, 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, with_gc
Children:
96812c0
Parents:
d807ca28
git-author:
Rob Schluntz <rschlunt@…> (05/29/18 12:29:01)
git-committer:
Rob Schluntz <rschlunt@…> (05/29/18 14:02:47)
Message:

Push deleted decls through the system

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rd807ca28 r3ed994e  
    171171        // *** Declarations
    172172        void CodeGenerator::postvisit( FunctionDecl * functionDecl ) {
     173                // deleted decls should never be used, so don't print them
     174                if ( functionDecl->isDeleted && genC ) return;
    173175                extension( functionDecl );
    174176                genAttributes( functionDecl->get_attributes() );
     
    184186                        functionDecl->get_statements()->accept( *visitor );
    185187                } // if
     188                if ( functionDecl->isDeleted ) {
     189                        output << " = void";
     190                }
    186191        }
    187192
    188193        void CodeGenerator::postvisit( ObjectDecl * objectDecl ) {
     194                // deleted decls should never be used, so don't print them
     195                if ( objectDecl->isDeleted && genC ) return;
    189196                if (objectDecl->get_name().empty() && genC ) {
    190197                        // only generate an anonymous name when generating C code, otherwise it clutters the output too much
     
    205212                        objectDecl->get_init()->accept( *visitor );
    206213                } // if
     214                if ( objectDecl->isDeleted ) {
     215                        output << " = void";
     216                }
    207217
    208218                if ( objectDecl->get_bitfieldWidth() ) {
  • src/Common/PassVisitor.h

    rd807ca28 r3ed994e  
    313313        void indexerAddUnionFwd ( UnionDecl                 * node  ) { indexer_impl_addUnionFwd ( pass, 0, node ); }
    314314        void indexerAddTrait    ( TraitDecl                 * node  ) { indexer_impl_addTrait    ( pass, 0, node ); }
    315         void indexerAddWith     ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith     ( pass, 0, exprs, withStmt ); }
     315        void indexerAddWith     ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith( pass, 0, exprs, withStmt ); }
    316316
    317317
  • src/Parser/DeclarationNode.cc

    rd807ca28 r3ed994e  
    10671067                        SemanticError( this, "invalid function specifier for " );
    10681068                } // if
    1069                 return buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension );
     1069                bool isDelete = initializer && initializer->get_isDelete();
     1070                Declaration * decl = buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, isDelete ? nullptr : maybeBuild< Initializer >(initializer), attributes )->set_extension( extension );
     1071                if ( isDelete ) {
     1072                        DeclarationWithType * dwt = strict_dynamic_cast<DeclarationWithType *>( decl );
     1073                        dwt->isDeleted = true;
     1074                }
     1075                return decl;
    10701076        } // if
    10711077
  • src/Parser/InitializerNode.cc

    rd807ca28 r3ed994e  
    2727
    2828InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode * des )
    29                 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {
     29                : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ), isDelete( false ) {
    3030        if ( aggrp )
    3131                kids = dynamic_cast< InitializerNode * >( get_next() );
     
    3636
    3737InitializerNode::InitializerNode( InitializerNode * init, bool aggrp, ExpressionNode * des )
    38                 : expr( nullptr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) {
     38                : expr( nullptr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ), isDelete( false ) {
    3939        if ( init )
    4040                set_last( init );
     
    4646                set_next( nullptr );
    4747} // InitializerNode::InitializerNode
     48
     49InitializerNode::InitializerNode( bool isDelete ) : expr( nullptr ), aggregate( false ), designator( nullptr ), kids( nullptr ), maybeConstructed( false ), isDelete( isDelete ) {}
    4850
    4951InitializerNode::~InitializerNode() {
     
    8486
    8587Initializer * InitializerNode::build() const {
     88        assertf( ! isDelete, "Should not build delete stmt InitializerNode" );
    8689        if ( aggregate ) {
    8790                // steal designators from children
  • src/Parser/ParseNode.h

    rd807ca28 r3ed994e  
    8787        InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode * des = nullptr );
    8888        InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr );
     89        InitializerNode( bool isDelete );
    8990        ~InitializerNode();
    9091        virtual InitializerNode * clone() const { assert( false ); return nullptr; }
     
    9798        InitializerNode * set_maybeConstructed( bool value ) { maybeConstructed = value; return this; }
    9899        bool get_maybeConstructed() const { return maybeConstructed; }
     100
     101        bool get_isDelete() const { return isDelete; }
    99102
    100103        InitializerNode * next_init() const { return kids; }
     
    110113        InitializerNode * kids;
    111114        bool maybeConstructed;
     115        bool isDelete;
    112116}; // InitializerNode
    113117
  • src/Parser/parser.yy

    rd807ca28 r3ed994e  
    21132113                { $$ = $2; }
    21142114        | '=' VOID
    2115                 { $$ = nullptr; }
     2115                { $$ = new InitializerNode( true ); }
    21162116        | ATassign initializer
    21172117                { $$ = $2->set_maybeConstructed( false ); }
  • src/SymTab/Indexer.cc

    rd807ca28 r3ed994e  
    471471        void Indexer::addId( DeclarationWithType * decl, Expression * baseExpr ) {
    472472                // default handling of conflicts is to raise an error
    473                 addId( decl, [decl](IdData &, const std::string & msg) { SemanticError( decl, msg ); return true; }, baseExpr );
     473                addId( decl, [decl](IdData &, const std::string & msg) { SemanticError( decl, msg ); return true; }, baseExpr, decl->isDeleted ? decl : nullptr );
    474474        }
    475475
  • src/SynTree/Declaration.cc

    rd807ca28 r3ed994e  
    104104}
    105105
     106
    106107// Local Variables: //
    107108// tab-width: 4 //
  • src/SynTree/Declaration.h

    rd807ca28 r3ed994e  
    8484        Expression *asmName;
    8585        std::list< Attribute * > attributes;
     86        bool isDeleted = false;
    8687
    8788        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
Note: See TracChangeset for help on using the changeset viewer.