Changeset f6e8c67 for src/ResolvExpr


Ignore:
Timestamp:
Mar 6, 2024, 6:06:43 AM (10 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
647d633
Parents:
bbf2cb1 (diff), af60383 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    rbbf2cb1 rf6e8c67  
    412412
    413413        void resolveWithExprs(std::vector<ast::ptr<ast::Expr>> & exprs, std::list<ast::ptr<ast::Stmt>> & stmtsToAdd);
     414        bool shouldGenCtorInit( const ast::ObjectDecl * ) const;
    414415
    415416        void beginScope() { managedTypes.beginScope(); }
     
    581582}
    582583
     584bool Resolver::shouldGenCtorInit( ast::ObjectDecl const * decl ) const {
     585        // If we shouldn't try to construct it, then don't.
     586        if ( !InitTweak::tryConstruct( decl ) ) return false;
     587        // Otherwise, if it is a managed type, we may construct it.
     588        if ( managedTypes.isManaged( decl ) ) return true;
     589        // Skip construction if it is trivial at compile-time.
     590        if ( InitTweak::isConstExpr( decl->init ) ) return false;
     591        // Skip construction for local declarations.
     592        return ( !isInFunction() || decl->storage.is_static );
     593}
     594
    583595const ast::ObjectDecl * Resolver::previsit( const ast::ObjectDecl * objectDecl ) {
    584596        // To handle initialization of routine pointers [e.g. int (*fp)(int) = foo()],
     
    615627                        // this object in visitor pass, thus disabling CtorInit codegen.
    616628                        // this happens on aggregate members and function parameters.
    617                         if ( InitTweak::tryConstruct( mutDecl ) && ( managedTypes.isManaged( mutDecl ) || ((! isInFunction() || mutDecl->storage.is_static ) && ! InitTweak::isConstExpr( mutDecl->init ) ) ) ) {
     629                        if ( shouldGenCtorInit( mutDecl ) ) {
    618630                                // constructed objects cannot be designated
    619631                                if ( InitTweak::isDesignated( mutDecl->init ) ) {
Note: See TracChangeset for help on using the changeset viewer.