Changeset fdd0509


Ignore:
Timestamp:
Dec 22, 2017, 4:15:24 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
ddb80bd
Parents:
c1bf35f
Message:

Hoist non-constexpr array dimensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    rc1bf35f rfdd0509  
    3030#include "InitTweak.h"             // for isConstExpr, InitExpander, checkIn...
    3131#include "Parser/LinkageSpec.h"    // for isOverridable, C
     32#include "ResolvExpr/Resolver.h"
    3233#include "SymTab/Autogen.h"        // for genImplicitCall, SizeType
    3334#include "SymTab/Mangler.h"        // for Mangler
     
    8990        };
    9091
    91         struct HoistArrayDimension final : public WithDeclsToAdd, public WithShortCircuiting, public WithGuards {
     92        struct HoistArrayDimension final : public WithDeclsToAdd, public WithShortCircuiting, public WithGuards, public WithIndexer {
    9293                /// hoist dimension from array types in object declaration so that it uses a single
    9394                /// const variable of type size_t, so that side effecting array dimensions are only
     
    104105                void premutate( FunctionType * ) { visit_children = false; }
    105106
     107                // need this so that enumerators are added to the indexer, due to premutate(AggregateDecl *)
     108                void premutate( EnumDecl * ) {}
     109
    106110                void hoist( Type * type );
    107111
     
    180184                        if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist?
    181185
     186                        // need to resolve array dimensions in order to accurately determine if constexpr
     187                        ResolvExpr::findSingleExpression( arrayType->dimension, SymTab::SizeType->clone(), indexer );
    182188                        // don't need to hoist dimension if it's a constexpr - only need to if there's potential for side effects.
    183189                        if ( isConstExpr( arrayType->get_dimension() ) ) return;
     
    196202        void HoistArrayDimension::premutate( FunctionDecl * ) {
    197203                GuardValue( inFunction );
     204                inFunction = true;
    198205        }
    199206
Note: See TracChangeset for help on using the changeset viewer.