Ignore:
Timestamp:
Sep 21, 2017, 3:23:33 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
05807e9, 29bc63e
Parents:
e4d6335
git-author:
Rob Schluntz <rschlunt@…> (09/21/17 15:19:47)
git-committer:
Rob Schluntz <rschlunt@…> (09/21/17 15:23:33)
Message:

Convert HoistArrayDimension? to PassVisitor?, cleanup in InitTweak? and CodeGen?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    re4d6335 r22bc276  
    1 #include <stddef.h>                // for NULL
    21#include <algorithm>               // for find, all_of
    32#include <cassert>                 // for assertf, assert, strict_dynamic_cast
     
    184183                        callExpr->get_args().splice( callExpr->get_args().end(), args );
    185184
    186                         *out++ = new IfStmt( noLabels, cond, new ExprStmt( noLabels, callExpr ), NULL );
     185                        *out++ = new IfStmt( noLabels, cond, new ExprStmt( noLabels, callExpr ), nullptr );
    187186
    188187                        UntypedExpr * increment = new UntypedExpr( new NameExpr( "++?" ) );
     
    250249        // To accomplish this, generate switch statement, consuming all of expander's elements
    251250        Statement * InitImpl::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) {
    252                 if ( ! init ) return NULL;
     251                if ( ! init ) return nullptr;
    253252                CompoundStmt * block = new CompoundStmt( noLabels );
    254253                build( dst, indices.begin(), indices.end(), init, back_inserter( block->get_kids() ) );
    255254                if ( block->get_kids().empty() ) {
    256255                        delete block;
    257                         return NULL;
     256                        return nullptr;
    258257                } else {
    259                         init = NULL; // init was consumed in creating the list init
     258                        init = nullptr; // init was consumed in creating the list init
    260259                        return block;
    261260                }
    262261        }
    263262
    264         Statement * ExprImpl::buildListInit( __attribute((unused)) UntypedExpr * dst, __attribute((unused)) std::list< Expression * > & indices ) {
    265                 return NULL;
     263        Statement * ExprImpl::buildListInit( UntypedExpr *, std::list< Expression * > & ) {
     264                return nullptr;
    266265        }
    267266
     
    270269        }
    271270
    272         bool tryConstruct( ObjectDecl * objDecl ) {
     271        bool tryConstruct( DeclarationWithType * dwt ) {
     272                ObjectDecl * objDecl = dynamic_cast< ObjectDecl * >( dwt );
     273                if ( ! objDecl ) return false;
    273274                return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
    274                         (objDecl->get_init() == NULL ||
    275                                 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ))
    276                         && ! objDecl->get_storageClasses().is_extern;
     275                        (objDecl->get_init() == nullptr ||
     276                                ( objDecl->get_init() != nullptr && objDecl->get_init()->get_maybeConstructed() ))
     277                        && ! objDecl->get_storageClasses().is_extern
     278                        && ! dynamic_cast< ReferenceType * >( objDecl->type );
    277279        }
    278280
     
    314316                collectCtorDtorCalls( stmt, matches );
    315317                assert( matches.size() <= 1 );
    316                 return matches.size() == 1 ? matches.front() : NULL;
     318                return matches.size() == 1 ? matches.front() : nullptr;
    317319        }
    318320
     
    359361        ApplicationExpr * isIntrinsicCallExpr( Expression * expr ) {
    360362                ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr );
    361                 if ( ! appExpr ) return NULL;
     363                if ( ! appExpr ) return nullptr;
    362364                DeclarationWithType * function = getCalledFunction( appExpr->get_function() );
    363365                assertf( function, "getCalledFunction returned nullptr: %s", toString( appExpr->get_function() ).c_str() );
    364366                // check for Intrinsic only - don't want to remove all overridable ctor/dtors because autogenerated ctor/dtor
    365367                // will call all member dtors, and some members may have a user defined dtor.
    366                 return function->get_linkage() == LinkageSpec::Intrinsic ? appExpr : NULL;
     368                return function->get_linkage() == LinkageSpec::Intrinsic ? appExpr : nullptr;
    367369        }
    368370
     
    482484                        return refType->get_base();
    483485                } else {
    484                         return NULL;
     486                        return nullptr;
    485487                }
    486488        }
     
    488490        Type * isPointerType( Type * type ) {
    489491                if ( getPointerBase( type ) ) return type;
    490                 else return NULL;
     492                else return nullptr;
    491493        }
    492494
Note: See TracChangeset for help on using the changeset viewer.