Changeset 300d75b


Ignore:
Timestamp:
Jan 3, 2018, 10:10:20 AM (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:
4e22d7d
Parents:
b3048d4
Message:

Tighten the case where array dimension is hoisted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    rb3048d4 r300d75b  
    4141#include "SynTree/Type.h"          // for Type, ArrayType, Type::Qualifiers
    4242#include "SynTree/Visitor.h"       // for acceptAll, maybeAccept
     43#include "Tuples/Tuples.h"         // for maybeImpure
    4344
    4445namespace InitTweak {
     
    186187                        // need to resolve array dimensions in order to accurately determine if constexpr
    187188                        ResolvExpr::findSingleExpression( arrayType->dimension, SymTab::SizeType->clone(), indexer );
    188                         // don't need to hoist dimension if it's a constexpr - only need to if there's potential for side effects.
    189                         if ( isConstExpr( arrayType->get_dimension() ) ) return;
     189                        // don't need to hoist dimension if it's definitely pure - only need to if there's potential for side effects.
     190                        if ( ! Tuples::maybeImpure( arrayType->dimension ) ) return;
    190191
    191192                        ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );
Note: See TracChangeset for help on using the changeset viewer.