Changeset e0115286 for src/AST/Decl.hpp


Ignore:
Timestamp:
May 10, 2019, 3:00:41 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2a5e8a6
Parents:
1f93c2c
Message:

Fix a cyclic dependency with ptr and nodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r1f93c2c re0115286  
    122122        std::vector<ptr<DeclWithType>> assertions;
    123123
    124         NamedTypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, 
     124        NamedTypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
    125125                Type* b, Linkage::Spec spec = Linkage::Cforall )
    126126        : Decl( loc, name, storage, spec ), base( b ), parameters(), assertions() {}
     
    149149                Data( TypeDecl* d ) : kind( d->kind ), isComplete( d->sized ) {}
    150150                Data( Kind k, bool c ) : kind( k ), isComplete( c ) {}
    151                 Data( const Data& d1, const Data& d2 ) 
     151                Data( const Data& d1, const Data& d2 )
    152152                : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
    153153
     
    158158        };
    159159
    160         TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b, 
     160        TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b,
    161161                Kind k, bool s, Type* i = nullptr )
    162162        : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == Ttype || s ), init( i ) {}
     
    174174class TypedefDecl final : public NamedTypeDecl {
    175175public:
    176         TypedefDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, 
     176        TypedefDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
    177177                Type* b, Linkage::Spec spec = Linkage::Cforall )
    178178        : NamedTypeDecl( loc, name, storage, b, spec ) {}
     
    275275};
    276276
     277
     278//=================================================================================================
     279/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     280/// remove only if there is a better solution
     281/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     282/// forward declarations
     283inline void increment( const class Decl * node, Node::ref_type ref ) { node->increment(ref); }
     284inline void decrement( const class Decl * node, Node::ref_type ref ) { node->decrement(ref); }
     285inline void increment( const class DeclWithType * node, Node::ref_type ref ) { node->increment(ref); }
     286inline void decrement( const class DeclWithType * node, Node::ref_type ref ) { node->decrement(ref); }
     287inline void increment( const class ObjectDecl * node, Node::ref_type ref ) { node->increment(ref); }
     288inline void decrement( const class ObjectDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     289inline void increment( const class FunctionDecl * node, Node::ref_type ref ) { node->increment(ref); }
     290inline void decrement( const class FunctionDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     291inline void increment( const class AggregateDecl * node, Node::ref_type ref ) { node->increment(ref); }
     292inline void decrement( const class AggregateDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     293inline void increment( const class StructDecl * node, Node::ref_type ref ) { node->increment(ref); }
     294inline void decrement( const class StructDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     295inline void increment( const class UnionDecl * node, Node::ref_type ref ) { node->increment(ref); }
     296inline void decrement( const class UnionDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     297inline void increment( const class EnumDecl * node, Node::ref_type ref ) { node->increment(ref); }
     298inline void decrement( const class EnumDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     299inline void increment( const class TraitDecl * node, Node::ref_type ref ) { node->increment(ref); }
     300inline void decrement( const class TraitDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     301inline void increment( const class NamedTypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     302inline void decrement( const class NamedTypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     303inline void increment( const class TypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     304inline void decrement( const class TypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     305inline void increment( const class FtypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     306inline void decrement( const class FtypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     307inline void increment( const class DtypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     308inline void decrement( const class DtypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     309inline void increment( const class TypedefDecl * node, Node::ref_type ref ) { node->increment(ref); }
     310inline void decrement( const class TypedefDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     311inline void increment( const class AsmDecl * node, Node::ref_type ref ) { node->increment(ref); }
     312inline void decrement( const class AsmDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     313inline void increment( const class StaticAssertDecl * node, Node::ref_type ref ) { node->increment(ref); }
     314inline void decrement( const class StaticAssertDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     315
    277316}
    278317
Note: See TracChangeset for help on using the changeset viewer.