Ignore:
Timestamp:
May 22, 2019, 5:23:02 PM (3 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
722c4831
Parents:
76ed81f (diff), ef5ef56 (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 plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.proto.hpp

    r76ed81f r893e106  
    107107                bool     * m_prev;
    108108                bool_ref * m_ref;
     109        };
     110
     111        template<typename pass_t, typename node_t>
     112        struct is_valid_previsit {
     113                using ret_t = decltype( ((pass_t*)nullptr)->previsit( (const node_t *)nullptr ) );
     114
     115                static constexpr bool value = std::is_void< ret_t >::value ||
     116                        std::is_base_of<const node_t, typename std::remove_pointer<ret_t>::type >::value;
    109117        };
    110118
     
    127135        static inline auto previsit( pass_t & pass, const node_t * & node, int ) -> decltype( pass.previsit( node ), void() ) {
    128136                static_assert(
    129                         std::is_base_of<const node_t, typename std::remove_pointer<decltype( pass.previsit( node ) )>::type >::value,
    130                         "Previsit may not change the type of the node. Use postvisit instead."
     137                        is_valid_previsit<pass_t, node_t>::value,
     138                        "Previsit may not change the type of the node. It must return its paremeter or void."
    131139                );
    132                 node = pass.previsit( node );
    133                 assert(node);
     140                if(std::is_void< decltype( pass.previsit(node) ) >::value) {
     141                        pass.previsit( node );
     142                } else {
     143                        node = pass.previsit( node );
     144                        assert(node);
     145                }
    134146        }
    135147
     
    139151        // PostVisit : never mutates the passed pointer but may return a different node
    140152        template<typename pass_t, typename node_t>
    141         static inline auto postvisit( pass_t & pass, const node_t * node, int ) -> decltype( pass.postvisit( node ), (const node_t *)nullptr ) {
     153        static inline auto postvisit( pass_t & pass, const node_t * node, int ) ->
     154                decltype( pass.postvisit( node ), node->accept( *(Visitor*)nullptr ) )
     155        {
    142156                return pass.postvisit( node );
    143157        }
Note: See TracChangeset for help on using the changeset viewer.