Changeset 5625427 for src/ResolvExpr


Ignore:
Timestamp:
Nov 13, 2023, 3:41:02 PM (7 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
8d182b1
Parents:
6ea85b22
Message:

Remove the warning directive from SpecCost?, you can't actually use the standard maybe_accept here, it does not allow the user to insert code between visiting elements in a container.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/SpecCost.cc

    r6ea85b22 r5625427  
    1616#include <cassert>
    1717#include <limits>
    18 #include <list>
    1918#include <type_traits>
    2019
     
    2524
    2625namespace {
     26
     27const ast::Type * expr_result( const ast::ptr< ast::Expr > & expr ) {
     28        return expr->result.get();
     29}
     30
     31const ast::Type * type_deref( const ast::ptr< ast::Type > & type ) {
     32        return type.get();
     33}
     34
    2735        /// The specialization counter inner class.
    2836        class SpecCounter : public ast::WithShortCircuiting, public ast::WithVisitorRef<SpecCounter> {
     
    3846                        typename std::add_pointer<ast::Type const *(typename T::value_type const &)>::type;
    3947
    40                 #warning Should use a standard maybe_accept
    41                 void maybe_accept( ast::Type const * type ) {
    42                         if ( type ) {
    43                                 auto node = type->accept( *visitor );
    44                                 assert( node == nullptr || node == type );
    45                         }
    46                 }
    47 
    4848                // Update the minimum to the new lowest non-none value.
    4949                template<typename T>
     
    5151                        for ( const auto & node : list ) {
    5252                                count = -1;
    53                                 maybe_accept( mapper( node ) );
     53
     54                                if ( ast::Type const * type = mapper( node ) ) {
     55                                        ast::Type const * newType = type->accept( *visitor );
     56                                        assert( newType == nullptr || newType == type );
     57                                }
     58
    5459                                if ( count != -1 && count < minimum ) minimum = count;
    5560                        }
     
    6267                        updateMinimumPresent( minCount, list, mapper );
    6368                        return toNoneOrInc( minCount );
    64                 }
    65 
    66                 // The three mappers:
    67                 static const ast::Type * decl_type( const ast::ptr< ast::DeclWithType > & decl ) {
    68                         return decl->get_type();
    69                 }
    70                 static const ast::Type * expr_result( const ast::ptr< ast::Expr > & expr ) {
    71                         return expr->result;
    72                 }
    73                 static const ast::Type * type_deref( const ast::ptr< ast::Type > & type ) {
    74                         return type.get();
    7569                }
    7670
     
    122116
    123117int specCost( const ast::Type * type ) {
    124         if ( nullptr == type ) {
    125                 return 0;
    126         }
    127         return ast::Pass<SpecCounter>::read( type );
     118        return ( nullptr == type ) ? 0 : ast::Pass<SpecCounter>::read( type );
    128119}
    129120
Note: See TracChangeset for help on using the changeset viewer.