Changeset af1e8f56 for src/AST


Ignore:
Timestamp:
May 23, 2019, 4:22:58 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
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:
a16e246, f1ec88a
Parents:
20a5977 (diff), effe5b0 (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

Location:
src/AST
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r20a5977 raf1e8f56  
    7272// --- EnumDecl
    7373
    74 bool EnumDecl::valueOf( Decl* enumerator, long long& value ) const {
     74bool EnumDecl::valueOf( const Decl * enumerator, long long& value ) const {
    7575        if ( enumValues.empty() ) {
    7676                long long crntVal = 0;
    77                 for ( const Decl* member : members ) {
     77                for ( const Decl * member : members ) {
    7878                        const ObjectDecl* field = strict_dynamic_cast< const ObjectDecl* >( member );
    7979                        if ( field->init ) {
  • src/AST/Decl.hpp

    r20a5977 raf1e8f56  
    287287
    288288        /// gets the integer value for this enumerator, returning true iff value found
    289         bool valueOf( Decl* enumerator, long long& value ) const;
     289        bool valueOf( const Decl * enumerator, long long& value ) const;
    290290
    291291        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/AST/Pass.proto.hpp

    r20a5977 raf1e8f56  
    109109        };
    110110
     111        /// "Short hand" to check if this is a valid previsit function
     112        /// Mostly used to make the static_assert look (and print) prettier
    111113        template<typename pass_t, typename node_t>
    112114        struct is_valid_previsit {
     
    117119        };
    118120
     121        /// Used by previsit implementation
     122        /// We need to reassign the result to 'node', unless the function
     123        /// returns void, then we just leave 'node' unchanged
    119124        template<bool is_void>
    120125        struct __assign;
     
    134139                        node = pass.previsit( node );
    135140                        assertf(node, "Previsit must not return NULL");
     141                }
     142        };
     143
     144        /// Used by postvisit implementation
     145        /// We need to return the result unless the function
     146        /// returns void, then we just return the original node
     147        template<bool is_void>
     148        struct __return;
     149
     150        template<>
     151        struct __return<true> {
     152                template<typename pass_t, typename node_t>
     153                static inline const node_t * result( pass_t & pass, const node_t * & node ) {
     154                        pass.postvisit( node );
     155                        return node;
     156                }
     157        };
     158
     159        template<>
     160        struct __return<false> {
     161                template<typename pass_t, typename node_t>
     162                static inline auto result( pass_t & pass, const node_t * & node ) {
     163                        return pass.postvisit( node );
    136164                }
    137165        };
     
    174202                decltype( pass.postvisit( node ), node->accept( *(Visitor*)nullptr ) )
    175203        {
    176                 return pass.postvisit( node );
     204                return __return<
     205                        std::is_void<
     206                                decltype( pass.postvisit( node ) )
     207                        >::value
     208                >::result( pass, node );
    177209        }
    178210
Note: See TracChangeset for help on using the changeset viewer.