Changeset 302ef2a


Ignore:
Timestamp:
Dec 22, 2020, 3:16:47 PM (4 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2daea42
Parents:
797a193
Message:

smart pointer memory safety

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Node.hpp

    r797a193 r302ef2a  
    229229        const node_t & operator* () const { _check(); return *node; }
    230230        explicit operator bool() const { _check(); return node; }
    231         operator const node_t * () const { _check(); return node; }
     231        operator const node_t * () const & { _check(); return node; }
     232        operator const node_t * () && = delete;
    232233
    233234        const node_t * release() {
  • src/ResolvExpr/Resolver.cc

    r797a193 r302ef2a  
    13111311        }
    13121312
    1313         ast::ptr< ast::Expr > resolveStmtExpr(
     1313        const ast::Expr * resolveStmtExpr(
    13141314                const ast::StmtExpr * stmtExpr, const ast::SymbolTable & symtab
    13151315        ) {
    13161316                assert( stmtExpr );
    13171317                ast::Pass< Resolver_new > resolver{ symtab };
    1318                 ast::ptr< ast::Expr > ret = stmtExpr;
    1319                 ret = ret->accept( resolver );
    1320                 strict_dynamic_cast< ast::StmtExpr * >( ret.get_and_mutate() )->computeResult();
     1318                auto ret = mutate(stmtExpr->accept(resolver));
     1319                strict_dynamic_cast< ast::StmtExpr * >( ret )->computeResult();
    13211320                return ret;
    13221321        }
  • src/ResolvExpr/Resolver.h

    r797a193 r302ef2a  
    7272        ast::ptr< ast::Init > resolveCtorInit(
    7373                const ast::ConstructorInit * ctorInit, const ast::SymbolTable & symtab );
    74         /// Resolves a statement expression
    75         ast::ptr< ast::Expr > resolveStmtExpr(
     74        /// Resolves a statement expression 
     75        const ast::Expr * resolveStmtExpr(
    7676                const ast::StmtExpr * stmtExpr, const ast::SymbolTable & symtab );
    7777} // namespace ResolvExpr
  • src/ResolvExpr/Unify.cc

    r797a193 r302ef2a  
    811811                /// Creates a tuple type based on a list of DeclWithType
    812812                template< typename Iter >
    813                 static ast::ptr< ast::Type > tupleFromTypes( Iter crnt, Iter end ) {
     813                static const ast::Type * tupleFromTypes( Iter crnt, Iter end ) {
    814814                        std::vector< ast::ptr< ast::Type > > types;
    815815                        while ( crnt != end ) {
     
    821821                        }
    822822
    823                         return { new ast::TupleType{ std::move(types) } };
     823                        return new ast::TupleType{ std::move(types) };
    824824                }
    825825
     
    10341034        private:
    10351035                /// Creates a tuple type based on a list of Type
    1036                 static ast::ptr< ast::Type > tupleFromTypes(
     1036                static const ast::Type * tupleFromTypes(
    10371037                        const std::vector< ast::ptr< ast::Type > > & tys
    10381038                ) {
Note: See TracChangeset for help on using the changeset viewer.