Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
b7c89aa
Parents:
f9feab8 (diff), 305581d (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' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.proto.h

    rf9feab8 r90152a4  
    4747
    4848        operator bool() { return m_ref ? *m_ref : true; }
    49         bool operator=( bool val ) { return *m_ref = val; }
     49        bool operator=( bool val ) { assert(m_ref); return *m_ref = val; }
    5050
    5151private:
     
    5353        friend class ChildrenGuard;
    5454
    55         bool * set( bool & val ) {
     55        bool * set( bool * val ) {
    5656                bool * prev = m_ref;
    57                 m_ref = &val;
     57                m_ref = val;
    5858                return prev;
    5959        }
     
    6767        ChildrenGuard( bool_ref * ref )
    6868                : m_val ( true )
    69                 , m_prev( ref ? ref->set( m_val ) : nullptr )
     69                , m_prev( ref ? ref->set( &m_val ) : nullptr )
    7070                , m_ref ( ref )
    7171        {}
     
    7373        ~ChildrenGuard() {
    7474                if( m_ref ) {
    75                         m_ref->set( *m_prev );
     75                        m_ref->set( m_prev );
    7676                }
    7777        }
     
    193193
    194194
    195 #define INDEXER_FUNC( func, type )                                                                                             \
     195#define INDEXER_FUNC1( func, type )                                                                                             \
    196196template<typename pass_type>                                                                                                   \
    197197static inline auto indexer_impl_##func ( pass_type & pass, int, type arg ) -> decltype( pass.indexer.func( arg ), void() ) {   \
     
    202202static inline void indexer_impl_##func ( pass_type &, long, type ) { }                                                          \
    203203
    204 INDEXER_FUNC( addId     , DeclarationWithType * );
    205 INDEXER_FUNC( addType   , NamedTypeDecl *       );
    206 INDEXER_FUNC( addStruct , StructDecl *          );
    207 INDEXER_FUNC( addEnum   , EnumDecl *            );
    208 INDEXER_FUNC( addUnion  , UnionDecl *           );
    209 INDEXER_FUNC( addTrait  , TraitDecl *           );
    210 INDEXER_FUNC( addWith   , WithStmt *            );
     204#define INDEXER_FUNC2( func, type1, type2 )                                                                                             \
     205template<typename pass_type>                                                                                                   \
     206static inline auto indexer_impl_##func ( pass_type & pass, int, type1 arg1, type2 arg2 ) -> decltype( pass.indexer.func( arg1, arg2 ), void() ) {   \
     207        pass.indexer.func( arg1, arg2 );                                                                                                \
     208}                                                                                                                              \
     209                                                                                                                               \
     210template<typename pass_type>                                                                                                   \
     211static inline void indexer_impl_##func ( pass_type &, long, type1, type2 ) { }
     212
     213
     214INDEXER_FUNC1( addId     , DeclarationWithType *       );
     215INDEXER_FUNC1( addType   , NamedTypeDecl *             );
     216INDEXER_FUNC1( addStruct , StructDecl *                );
     217INDEXER_FUNC1( addEnum   , EnumDecl *                  );
     218INDEXER_FUNC1( addUnion  , UnionDecl *                 );
     219INDEXER_FUNC1( addTrait  , TraitDecl *                 );
     220INDEXER_FUNC2( addWith   , std::list< Expression * > &, BaseSyntaxNode * );
    211221
    212222
Note: See TracChangeset for help on using the changeset viewer.