Changeset 33b7d49


Ignore:
Timestamp:
Mar 15, 2022, 10:14:05 AM (2 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
48a91e2
Parents:
d824715
Message:

Added another check to checkInvariants for code locations. I also went through and made sure you can put it every after every new AST pass not followed by a forceFillCodeLocations.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Util.cpp

    rd824715 r33b7d49  
    1010// Created On       : Wed Jan 19  9:46:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Feb 18  9:42:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Fri Mar 11 18:07:00 2022
     13// Update Count     : 1
    1414//
    1515
    1616#include "Util.hpp"
    1717
    18 #include "Decl.hpp"
    1918#include "Node.hpp"
     19#include "ParseNode.hpp"
    2020#include "Pass.hpp"
    2121#include "TranslationUnit.hpp"
    22 #include "Common/ScopedMap.h"
    2322
    2423#include <vector>
     
    4645};
    4746
     47/// Check that every note that can has a set CodeLocation.
     48struct SetCodeLocationsCore {
     49        void previsit( const ParseNode * node ) {
     50                assert( node->location.isSet() );
     51        }
     52};
     53
    4854struct InvariantCore {
    4955        // To save on the number of visits: this is a kind of composed core.
    5056        // None of the passes should make changes so ordering doesn't matter.
    5157        NoStrongCyclesCore no_strong_cycles;
     58        SetCodeLocationsCore set_code_locations;
    5259
    5360        void previsit( const Node * node ) {
    5461                no_strong_cycles.previsit( node );
     62        }
     63
     64        void previsit( const ParseNode * node ) {
     65                no_strong_cycles.previsit( node );
     66                set_code_locations.previsit( node );
    5567        }
    5668
  • src/Common/CodeLocationTools.cpp

    rd824715 r33b7d49  
    99// Author           : Andrew Beach
    1010// Created On       : Fri Dec  4 15:42:00 2020
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  1 09:14:39 2022
    13 // Update Count     : 3
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Mar 14 15:14:00 2022
     13// Update Count     : 4
    1414//
    1515
     
    239239};
    240240
     241class LocalFillCore : public ast::WithGuards {
     242        CodeLocation const * parent;
     243public:
     244        LocalFillCore( CodeLocation const & location ) : parent( &location ) {
     245                assert( location.isSet() );
     246        }
     247
     248        template<typename node_t>
     249        auto previsit( node_t const * node )
     250                        -> typename std::enable_if<has_code_location<node_t>::value, node_t const *>::type {
     251                if ( node->location.isSet() ) {
     252                        GuardValue( parent ) = &node->location;
     253                        return node;
     254                } else {
     255                        node_t * mut = ast::mutate( node );
     256                        mut->location = *parent;
     257                        return mut;
     258                }
     259        }
     260};
     261
    241262} // namespace
    242263
     
    278299        ast::Pass<FillCore>::run( unit );
    279300}
     301
     302ast::Node const * localFillCodeLocations(
     303                CodeLocation const & location , ast::Node const * node ) {
     304        ast::Pass<LocalFillCore> visitor( location );
     305        return node->accept( visitor );
     306}
  • src/Common/CodeLocationTools.hpp

    rd824715 r33b7d49  
    1010// Created On       : Fri Dec  4 15:35:00 2020
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Dec  9  9:53:00 2020
    13 // Update Count     : 1
     12// Last Modified On : Mon Mar 14 15:14:00 2022
     13// Update Count     : 2
    1414//
    1515
    1616#pragma once
    1717
     18class CodeLocation;
    1819namespace ast {
     20        class Node;
    1921        class TranslationUnit;
    2022}
     
    2830// Assign a nearby code-location to any unset code locations in the forest.
    2931void forceFillCodeLocations( ast::TranslationUnit & unit );
     32
     33// Fill in code-locations with a parent code location,
     34// using the provided CodeLocation as the base.
     35ast::Node const *
     36        localFillCodeLocations( CodeLocation const &, ast::Node const * );
  • src/ControlStruct/ExceptTranslateNew.cpp

    rd824715 r33b7d49  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Nov  8 11:53:00 2021
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 31 18:49:58 2022
    13 // Update Count     : 1
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Mar 11 17:51:00 2022
     13// Update Count     : 2
    1414//
    1515
     
    2727
    2828        typedef std::list<ast::CatchStmt*> CatchList;
    29 
    30         void split( CatchList& allHandlers, CatchList& terHandlers,
    31                                 CatchList& resHandlers ) {
    32                 while ( !allHandlers.empty() ) {
    33                         ast::CatchStmt * stmt = allHandlers.front();
    34                         allHandlers.pop_front();
    35                         if (stmt->kind == ast::ExceptionKind::Terminate) {
    36                                 terHandlers.push_back(stmt);
    37                         } else {
    38                                 resHandlers.push_back(stmt);
    39                         }
    40                 }
    41         }
    4229
    4330        void appendDeclStmt( ast::CompoundStmt * block, ast::DeclWithType * item ) {
     
    171158        ast::Stmt * create_resume_rethrow( const ast::ThrowStmt * throwStmt );
    172159
    173         // Types used in translation, make sure to use clone.
     160        // Types used in translation, first group are internal.
     161        ast::ObjectDecl * make_index_object( CodeLocation const & ) const;
     162        ast::ObjectDecl * make_exception_object( CodeLocation const & ) const;
     163        ast::ObjectDecl * make_bool_object( CodeLocation const & ) const;
     164        ast::ObjectDecl * make_voidptr_object( CodeLocation const & ) const;
     165        ast::ObjectDecl * make_unused_index_object( CodeLocation const & ) const;
    174166        // void (*function)();
    175         ast::FunctionDecl * try_func_t;
     167        ast::FunctionDecl * make_try_function( CodeLocation const & ) const;
    176168        // void (*function)(int, exception);
    177         ast::FunctionDecl * catch_func_t;
     169        ast::FunctionDecl * make_catch_function( CodeLocation const & ) const;
    178170        // int (*function)(exception);
    179         ast::FunctionDecl * match_func_t;
     171        ast::FunctionDecl * make_match_function( CodeLocation const & ) const;
    180172        // bool (*function)(exception);
    181         ast::FunctionDecl * handle_func_t;
     173        ast::FunctionDecl * make_handle_function( CodeLocation const & ) const;
    182174        // void (*function)(__attribute__((unused)) void *);
    183         ast::FunctionDecl * finally_func_t;
    184 
    185         ast::StructInstType * create_except_type() {
    186                 assert( except_decl );
    187                 return new ast::StructInstType( except_decl );
    188         }
    189         void init_func_types();
     175        ast::FunctionDecl * make_finally_function( CodeLocation const & ) const;
    190176
    191177public:
     
    199185};
    200186
    201 void TryMutatorCore::init_func_types() {
     187ast::ObjectDecl * TryMutatorCore::make_index_object(
     188                CodeLocation const & location ) const {
     189        return new ast::ObjectDecl(
     190                location,
     191                "__handler_index",
     192                new ast::BasicType(ast::BasicType::SignedInt),
     193                nullptr, //init
     194                ast::Storage::Classes{},
     195                ast::Linkage::Cforall
     196                );
     197}
     198
     199ast::ObjectDecl * TryMutatorCore::make_exception_object(
     200                CodeLocation const & location ) const {
    202201        assert( except_decl );
    203 
    204         ast::ObjectDecl index_obj(
    205                 {},
    206                 "__handler_index",
    207                 new ast::BasicType(ast::BasicType::SignedInt)
    208                 );
    209         ast::ObjectDecl exception_obj(
    210                 {},
     202        return new ast::ObjectDecl(
     203                location,
    211204                "__exception_inst",
    212205                new ast::PointerType(
    213206                        new ast::StructInstType( except_decl )
    214207                        ),
    215                 NULL
    216                 );
    217         ast::ObjectDecl bool_obj(
    218                 {},
     208                nullptr, //init
     209                ast::Storage::Classes{},
     210                ast::Linkage::Cforall
     211                );
     212}
     213
     214ast::ObjectDecl * TryMutatorCore::make_bool_object(
     215                CodeLocation const & location ) const {
     216        return new ast::ObjectDecl(
     217                location,
    219218                "__ret_bool",
    220219                new ast::BasicType( ast::BasicType::Bool ),
     
    225224                std::vector<ast::ptr<ast::Attribute>>{ new ast::Attribute( "unused" ) }
    226225                );
    227         ast::ObjectDecl voidptr_obj(
    228                 {},
     226}
     227
     228ast::ObjectDecl * TryMutatorCore::make_voidptr_object(
     229                CodeLocation const & location ) const {
     230        return new ast::ObjectDecl(
     231                location,
    229232                "__hook",
    230233                new ast::PointerType(
     
    237240                std::vector<ast::ptr<ast::Attribute>>{ new ast::Attribute( "unused" ) }
    238241                );
    239 
    240         ast::ObjectDecl unused_index_obj(
    241                 {},
     242}
     243
     244ast::ObjectDecl * TryMutatorCore::make_unused_index_object(
     245                CodeLocation const & location ) const {
     246        return new ast::ObjectDecl(
     247                location,
    242248                "__handler_index",
    243249                new ast::BasicType(ast::BasicType::SignedInt),
     
    248254                std::vector<ast::ptr<ast::Attribute>>{ new ast::Attribute( "unused" ) }
    249255        );
    250         //unused_index_obj->attributes.push_back( new Attribute( "unused" ) );
    251 
    252         try_func_t = new ast::FunctionDecl(
    253                 {},
     256}
     257
     258ast::FunctionDecl * TryMutatorCore::make_try_function(
     259                CodeLocation const & location ) const {
     260        return new ast::FunctionDecl(
     261                location,
    254262                "try",
    255263                {}, //forall
     
    260268                ast::Linkage::Cforall
    261269        );
    262 
    263         catch_func_t = new ast::FunctionDecl(
    264                 {},
     270}
     271
     272ast::FunctionDecl * TryMutatorCore::make_catch_function(
     273                CodeLocation const & location ) const {
     274        return new ast::FunctionDecl(
     275                location,
    265276                "catch",
    266277                {}, //forall
    267                 {ast::deepCopy(&index_obj), ast::deepCopy(&exception_obj)},//param
     278                { make_index_object( location ), make_exception_object( location ) },
    268279                {}, //return void
    269280                nullptr,
     
    271282                ast::Linkage::Cforall
    272283        );
    273 
    274         match_func_t = new ast::FunctionDecl(
    275                 {},
     284}
     285
     286ast::FunctionDecl * TryMutatorCore::make_match_function(
     287                CodeLocation const & location ) const {
     288        return new ast::FunctionDecl(
     289                location,
    276290                "match",
    277291                {}, //forall
    278                 {ast::deepCopy(&exception_obj)},
    279                 {ast::deepCopy(&unused_index_obj)},
     292                { make_exception_object( location ) },
     293                { make_unused_index_object( location ) },
    280294                nullptr,
    281295                ast::Storage::Classes{},
    282296                ast::Linkage::Cforall
    283297        );
    284 
    285         handle_func_t = new ast::FunctionDecl(
    286                 {},
     298}
     299
     300ast::FunctionDecl * TryMutatorCore::make_handle_function(
     301                CodeLocation const & location ) const {
     302        return new ast::FunctionDecl(
     303                location,
    287304                "handle",
    288305                {}, //forall
    289                 {ast::deepCopy(&exception_obj)},
    290                 {ast::deepCopy(&bool_obj)},
     306                { make_exception_object( location ) },
     307                { make_bool_object( location ) },
    291308                nullptr,
    292309                ast::Storage::Classes{},
    293310                ast::Linkage::Cforall
    294311        );
    295 
    296         finally_func_t = new ast::FunctionDecl(
    297                 {},
     312}
     313
     314ast::FunctionDecl * TryMutatorCore::make_finally_function(
     315                CodeLocation const & location ) const {
     316        return new ast::FunctionDecl(
     317                location,
    298318                "finally",
    299319                {}, //forall
    300                 {ast::deepCopy(&voidptr_obj)},
     320                { make_voidptr_object( location ) },
    301321                {}, //return void
    302322                nullptr,
     
    304324                ast::Linkage::Cforall
    305325        );
    306 
    307         //catch_func_t.get_parameters().push_back( index_obj.clone() );
    308         //catch_func_t.get_parameters().push_back( exception_obj.clone() );
    309         //match_func_t.get_returnVals().push_back( unused_index_obj );
    310         //match_func_t.get_parameters().push_back( exception_obj.clone() );
    311         //handle_func_t.get_returnVals().push_back( bool_obj.clone() );
    312         //handle_func_t.get_parameters().push_back( exception_obj.clone() );
    313         //finally_func_t.get_parameters().push_back( voidptr_obj.clone() );
    314326}
    315327
    316328// TryStmt Mutation Helpers
    317 
    318 /*
    319 ast::CompoundStmt * TryMutatorCore::take_try_block( ast::TryStmt *tryStmt ) {
    320         ast::CompoundStmt * block = tryStmt->body;
    321         tryStmt->body = nullptr;
    322         return block;
    323 }
    324 */
    325329
    326330ast::FunctionDecl * TryMutatorCore::create_try_wrapper(
    327331                const ast::CompoundStmt *body ) {
    328332
    329         ast::FunctionDecl * ret = ast::deepCopy(try_func_t);
     333        ast::FunctionDecl * ret = make_try_function( body->location );
    330334        ret->stmts = body;
    331335        return ret;
     
    339343        const CodeLocation loc = handlers.front()->location;
    340344
    341         ast::FunctionDecl * func_t = ast::deepCopy(catch_func_t);
     345        ast::FunctionDecl * func_t = make_catch_function( loc );
    342346        const ast::DeclWithType * index_obj = func_t->params.front();
    343347        const ast::DeclWithType * except_obj = func_t->params.back();
     
    386390                // handler->body = nullptr;
    387391
    388                 handler_wrappers.push_back( new ast::CaseStmt(loc, 
     392                handler_wrappers.push_back( new ast::CaseStmt(loc,
    389393                        ast::ConstantExpr::from_int(loc, index) ,
    390394                        { block, new ast::ReturnStmt( loc, nullptr ) }
     
    393397        // TODO: Some sort of meaningful error on default perhaps?
    394398
    395         /*
    396         std::list<Statement*> stmt_handlers;
    397         while ( !handler_wrappers.empty() ) {
    398                 stmt_handlers.push_back( handler_wrappers.front() );
    399                 handler_wrappers.pop_front();
    400         }
    401         */
    402 
    403         ast::SwitchStmt * handler_lookup = new ast::SwitchStmt(loc,
     399        ast::SwitchStmt * handler_lookup = new ast::SwitchStmt( loc,
    404400                new ast::VariableExpr( loc, index_obj ),
    405401                std::move(handler_wrappers)
    406402                );
    407         ast::CompoundStmt * body = new ast::CompoundStmt(loc,
    408                 {handler_lookup});
     403        ast::CompoundStmt * body = new ast::CompoundStmt( loc, {handler_lookup} );
    409404
    410405        func_t->stmts = body;
     
    433428
    434429        // Check for type match.
    435         ast::VirtualCastExpr * vcex = new ast::VirtualCastExpr(loc, 
     430        ast::VirtualCastExpr * vcex = new ast::VirtualCastExpr(loc,
    436431                new ast::VariableExpr(loc, except_obj ),
    437432                local_except->get_type()
     
    445440        }
    446441        // Construct the match condition.
    447         block->push_back( new ast::IfStmt(loc, 
     442        block->push_back( new ast::IfStmt(loc,
    448443                cond, modded_handler->body, nullptr ) );
    449444
    450         // xxx - how does this work in new ast
    451         //modded_handler->set_decl( nullptr );
    452         //modded_handler->set_cond( nullptr );
    453         //modded_handler->set_body( nullptr );
    454         //delete modded_handler;
    455445        return block;
    456446}
     
    467457        ast::CompoundStmt * body = new ast::CompoundStmt(loc);
    468458
    469         ast::FunctionDecl * func_t = ast::deepCopy(match_func_t);
     459        ast::FunctionDecl * func_t = make_match_function( loc );
    470460        const ast::DeclWithType * except_obj = func_t->params.back();
    471461
     
    490480        }
    491481
    492         body->push_back( new ast::ReturnStmt(loc, 
     482        body->push_back( new ast::ReturnStmt(loc,
    493483                ast::ConstantExpr::from_int( loc, 0 ) ));
    494484
     
    525515        ast::CompoundStmt * body = new ast::CompoundStmt(loc);
    526516
    527         ast::FunctionDecl * func_t = ast::deepCopy(handle_func_t);
     517        ast::FunctionDecl * func_t = make_handle_function( loc );
    528518        const ast::DeclWithType * except_obj = func_t->params.back();
    529519
     
    535525                ast::CompoundStmt * handling_code;
    536526                if (handler->body.as<ast::CompoundStmt>()) {
    537                         handling_code =
    538                         strict_dynamic_cast<ast::CompoundStmt*>( handler->body.get_and_mutate() );
     527                        handling_code = strict_dynamic_cast<ast::CompoundStmt*>(
     528                                handler->body.get_and_mutate() );
    539529                } else {
    540530                        handling_code = new ast::CompoundStmt(loc);
     
    600590        const ast::CompoundStmt * body = finally->body;
    601591
    602         ast::FunctionDecl * func_t = ast::deepCopy(finally_func_t);
     592        ast::FunctionDecl * func_t = make_finally_function( tryStmt->location );
    603593        func_t->stmts = body;
    604594
    605         // finally->set_block( nullptr );
    606         // delete finally;
    607595        tryStmt->finally = nullptr;
    608 
    609596
    610597        return func_t;
     
    617604
    618605        const CodeLocation loc = finally_wrapper->location;
    619         // Make Cleanup Attribute.
    620         /*
    621         std::list< ast::Attribute * > attributes;
    622         {
    623                 std::list<  > attr_params;
    624                 attr_params.push_back( nameOf( finally_wrapper ) );
    625                 attributes.push_back( new Attribute( "cleanup", attr_params ) );
    626         }
    627         */
    628 
    629606        return new ast::ObjectDecl(
    630607                loc,
     
    644621        // return false;
    645622        const CodeLocation loc = throwStmt->location;
    646         ast::Stmt * result = new ast::ReturnStmt(loc, 
     623        ast::Stmt * result = new ast::ReturnStmt(loc,
    647624                ast::ConstantExpr::from_bool( loc, false )
    648625                );
    649626        result->labels = throwStmt->labels;
    650         // delete throwStmt; done by postvisit
    651627        return result;
    652628}
     
    660636                assert( nullptr == except_decl );
    661637                except_decl = structDecl;
    662                 init_func_types();
    663638        } else if ( structDecl->name == "__cfaehm_try_resume_node" ) {
    664639                assert( nullptr == node_decl );
     
    706681                }
    707682        }
    708         // split( mutStmt->handlers,
    709         //              termination_handlers, resumption_handlers );
    710683
    711684        if ( resumption_handlers.size() ) {
  • src/InitTweak/FixGlobalInit.cc

    rd824715 r33b7d49  
    113113                accept_all(translationUnit, fixer);
    114114
     115                // Say these magic declarations come at the end of the file.
     116                CodeLocation const & location = translationUnit.decls.back()->location;
     117
    115118                if ( !fixer.core.initStmts.empty() ) {
    116119                        std::vector<ast::ptr<ast::Expr>> ctorParams;
    117                         if (inLibrary) ctorParams.emplace_back(ast::ConstantExpr::from_int({}, 200));
    118                         auto initFunction = new ast::FunctionDecl({}, "__global_init__", {}, {}, {}, new ast::CompoundStmt({}, std::move(fixer.core.initStmts)),
    119                                 ast::Storage::Static, ast::Linkage::C, {new ast::Attribute("constructor", std::move(ctorParams))});
     120                        if (inLibrary) ctorParams.emplace_back(ast::ConstantExpr::from_int(location, 200));
     121                        auto initFunction = new ast::FunctionDecl(location,
     122                                "__global_init__", {}, {}, {},
     123                                new ast::CompoundStmt(location, std::move(fixer.core.initStmts)),
     124                                ast::Storage::Static, ast::Linkage::C,
     125                                {new ast::Attribute("constructor", std::move(ctorParams))});
    120126
    121127                        translationUnit.decls.emplace_back( initFunction );
     
    124130                if ( !fixer.core.destroyStmts.empty() ) {
    125131                        std::vector<ast::ptr<ast::Expr>> dtorParams;
    126                         if (inLibrary) dtorParams.emplace_back(ast::ConstantExpr::from_int({}, 200));
    127                         auto destroyFunction = new ast::FunctionDecl({}, "__global_destroy__", {}, {}, {}, new ast::CompoundStmt({}, std::move(fixer.core.destroyStmts)),
    128                                 ast::Storage::Static, ast::Linkage::C, {new ast::Attribute("destructor", std::move(dtorParams))});
     132                        if (inLibrary) dtorParams.emplace_back(ast::ConstantExpr::from_int(location, 200));
     133                        auto destroyFunction = new ast::FunctionDecl( location,
     134                                "__global_destroy__", {}, {}, {},
     135                                new ast::CompoundStmt(location, std::move(fixer.core.destroyStmts)),
     136                                ast::Storage::Static, ast::Linkage::C,
     137                                {new ast::Attribute("destructor", std::move(dtorParams))});
    129138
    130139                        translationUnit.decls.emplace_back(destroyFunction);
  • src/InitTweak/FixInitNew.cpp

    rd824715 r33b7d49  
    1616#include "CodeGen/GenType.h"           // for genPrettyType
    1717#include "CodeGen/OperatorTable.h"
     18#include "Common/CodeLocationTools.hpp"
    1819#include "Common/PassVisitor.h"        // for PassVisitor, WithStmtsToAdd
    1920#include "Common/SemanticError.h"      // for SemanticError
     
    553554                ast::ptr<ast::Expr> guard = mutArg;
    554555
    555                 ast::ptr<ast::ObjectDecl> tmp = new ast::ObjectDecl({}, "__tmp", mutResult, nullptr );
     556                ast::ptr<ast::ObjectDecl> tmp = new ast::ObjectDecl(loc, "__tmp", mutResult, nullptr );
    556557
    557558                // create and resolve copy constructor
     
    799800        // to prevent warnings ('_unq0' may be used uninitialized in this function),
    800801        // insert an appropriate zero initializer for UniqueExpr temporaries.
    801         ast::Init * makeInit( const ast::Type * t ) {
     802        ast::Init * makeInit( const ast::Type * t, CodeLocation const & loc ) {
    802803                if ( auto inst = dynamic_cast< const ast::StructInstType * >( t ) ) {
    803804                        // initizer for empty struct must be empty
    804                         if ( inst->base->members.empty() ) return new ast::ListInit({}, {});
     805                        if ( inst->base->members.empty() ) {
     806                                return new ast::ListInit( loc, {} );
     807                        }
    805808                } else if ( auto inst = dynamic_cast< const ast::UnionInstType * >( t ) ) {
    806809                        // initizer for empty union must be empty
    807                         if ( inst->base->members.empty() ) return new ast::ListInit({}, {});
    808                 }
    809 
    810                 return new ast::ListInit( {}, { new ast::SingleInit( {}, ast::ConstantExpr::from_int({}, 0) ) } );
     810                        if ( inst->base->members.empty() ) {
     811                                return new ast::ListInit( loc, {} );
     812                        }
     813                }
     814
     815                return new ast::ListInit( loc, {
     816                        new ast::SingleInit( loc, ast::ConstantExpr::from_int( loc, 0 ) )
     817                } );
    811818        }
    812819
     
    832839                        } else {
    833840                                // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression
    834                                 mutExpr->object = new ast::ObjectDecl( mutExpr->location, toString("_unq", mutExpr->id), mutExpr->result, makeInit( mutExpr->result ) );
     841                                mutExpr->object = new ast::ObjectDecl( mutExpr->location, toString("_unq", mutExpr->id), mutExpr->result, makeInit( mutExpr->result, mutExpr->location ) );
    835842                                mutExpr->var = new ast::VariableExpr( mutExpr->location, mutExpr->object );
    836843                        }
     
    12291236
    12301237                                                        auto destructor = new ast::ObjectDecl(loc, memberDtorNamer.newName(), new ast::StructInstType( ast::dtorStruct ), new ast::ListInit(loc, { new ast::SingleInit(loc, thisExpr ), new ast::SingleInit(loc, new ast::CastExpr( dtorExpr, dtorType ) ) } ) );
    1231                                                         destructor->attributes.push_back( new ast::Attribute( "cleanup", { new ast::VariableExpr({}, ast::dtorStructDestroy ) } ) );
     1238                                                        destructor->attributes.push_back( new ast::Attribute( "cleanup", { new ast::VariableExpr( loc, ast::dtorStructDestroy ) } ) );
    12321239                                                        mutStmts->push_front( new ast::DeclStmt(loc, destructor ) );
    12331240                                                        mutStmts->kids.splice( mutStmts->kids.begin(), stmtsToAdd );
     
    13231330
    13241331        const ast::Expr * GenStructMemberCalls::postvisit( const ast::UntypedExpr * untypedExpr ) {
    1325                 // Expression * newExpr = untypedExpr;
    13261332                // xxx - functions returning ast::ptr seems wrong...
    13271333                auto res = ResolvExpr::findVoidExpression( untypedExpr, symtab );
    1328                 return res.release();
    1329                 // return newExpr;
     1334                // Fix CodeLocation (at least until resolver is fixed).
     1335                auto fix = localFillCodeLocations( untypedExpr->location, res.release() );
     1336                return strict_dynamic_cast<const ast::Expr *>( fix );
    13301337        }
    13311338
  • src/main.cc

    rd824715 r33b7d49  
    3232
    3333#include "AST/Convert.hpp"
    34 #include "AST/Print.hpp"
    3534#include "CompilationState.h"
    3635#include "../config.h"                      // for CFA_LIBDIR
  • tests/collections/.expect/vector-err-pass-perm-it-byval.txt

    rd824715 r33b7d49  
    1 error: Unique best alternative includes deleted identifier in Generated Cast of:
     1collections/vector-demo.cfa:95:1 error: Unique best alternative includes deleted identifier in Generated Cast of:
    22  Application of
    33    Deleted Expression
Note: See TracChangeset for help on using the changeset viewer.