Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rf685679 r675d816  
    1010// Created On       : Thu May 09 15::37::05 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu May 23 16:59:00 2019
    13 // Update Count     : 6
     12// Last Modified On : Fri May 17 16:01:00 2019
     13// Update Count     : 4
    1414//
    1515
    1616#include "Convert.hpp"
    1717
    18 #include <unordered_map>
     18#include "AST/Pass.hpp"
    1919
    2020#include "AST/Attribute.hpp"
     
    2323#include "AST/Init.hpp"
    2424#include "AST/Stmt.hpp"
    25 #include "AST/TypeSubstitution.hpp"
     25
    2626
    2727#include "SynTree/Attribute.h"
    2828#include "SynTree/Declaration.h"
    29 #include "SynTree/TypeSubstitution.h"
    3029
    3130//================================================================================================
     
    4443class ConverterNewToOld : public ast::Visitor {
    4544        BaseSyntaxNode * node = nullptr;
    46         using Cache = std::unordered_map< const ast::Node *, BaseSyntaxNode * >;
    47         Cache cache;
    4845
    4946        template<typename T>
     
    5148                ConverterNewToOld & visitor;
    5249
    53                 template<typename U, enum ast::Node::ref_type R>
    54                 T * accept1( const ast::ptr_base<U, R> & ptr ) {
    55                         if ( ! ptr ) return nullptr;
     50                template<typename U>
     51                T * accept1( const ast::ptr<U> & ptr ) {
    5652                        ptr->accept( visitor );
    5753                        T * ret = strict_dynamic_cast< T * >( visitor.node );
     
    9288        }
    9389
    94         /// get new qualifiers from old type
    95         Type::Qualifiers cv( const ast::Type * ty ) { return { ty->qualifiers.val }; }
    96 
    97         /// returns true and sets `node` if in cache
    98         bool inCache( const ast::Node * node ) {
    99                 auto it = cache.find( node );
    100                 if ( it == cache.end() ) return false;
    101                 this->node = it->second;
    102                 return true;
    103         }
    104 
    10590public:
    10691        Declaration * decl( const ast::Decl * declNode ) {
     
    10994
    11095private:
    111         void declPostamble( Declaration * decl, const ast::Decl * node ) {
    112                 decl->location = node->location;
    113                 // name comes from constructor
    114                 // linkage comes from constructor
    115                 decl->extension = node->extension;
    116                 decl->uniqueId = node->uniqueId;
    117                 // storageClasses comes from constructor
    118                 this->node = decl;
    119         }
    120 
    121         const ast::DeclWithType * declWithTypePostamble (
    122                         DeclarationWithType * decl, const ast::DeclWithType * node ) {
    123                 cache.emplace( node, decl );
    124                 decl->mangleName = node->mangleName;
    125                 decl->scopeLevel = node->scopeLevel;
    126                 decl->asmName = get<Expression>().accept1( node->asmName );
    127                 // attributes comes from constructor
    128                 decl->isDeleted = node->isDeleted;
    129                 // fs comes from constructor
    130                 declPostamble( decl, node );
    131                 return nullptr;
    132         }
    133 
    13496        const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final {
    135                 if ( inCache( node ) ) return nullptr;
    136                 auto decl = new ObjectDecl(
    137                         node->name,
    138                         Type::StorageClasses( node->storage.val ),
    139                         LinkageSpec::Spec( node->linkage.val ),
    140                         get<Expression>().accept1( node->bitfieldWidth ),
    141                         get<Type>().accept1( node->type ),
    142                         get<Initializer>().accept1( node->init ),
    143                         get<Attribute>().acceptL( node->attributes ),
    144                         Type::FuncSpecifiers( node->funcSpec.val )
    145                 );
    146                 return declWithTypePostamble( decl, node );
     97                (void)node;
     98                return nullptr;
    14799        }
    148100
    149101        const ast::DeclWithType * visit( const ast::FunctionDecl * node ) override final {
    150                 if ( inCache( node ) ) return nullptr;
    151                 auto decl = new FunctionDecl(
    152                         node->name,
    153                         Type::StorageClasses( node->storage.val ),
    154                         LinkageSpec::Spec( node->linkage.val ),
    155                         get<FunctionType>().accept1( node->type ),
    156                         get<CompoundStmt>().accept1( node->stmts ),
    157                         get<Attribute>().acceptL( node->attributes ),
    158                         Type::FuncSpecifiers( node->funcSpec.val )
    159                 );
    160                 decl->withExprs = get<Expression>().acceptL( node->withExprs );
    161                 return declWithTypePostamble( decl, node );
    162         }
    163 
    164         const ast::Decl * namedTypePostamble( NamedTypeDecl * decl, const ast::NamedTypeDecl * node ) {
    165                 // base comes from constructor
    166                 decl->parameters = get<TypeDecl>().acceptL( node->params );
    167                 decl->assertions = get<DeclarationWithType>().acceptL( node->assertions );
    168                 declPostamble( decl, node );
     102                (void)node;
     103                return nullptr;
     104        }
     105
     106        const ast::Decl * visit( const ast::StructDecl * node ) override final {
     107                (void)node;
     108                return nullptr;
     109        }
     110
     111        const ast::Decl * visit( const ast::UnionDecl * node ) override final {
     112                (void)node;
     113                return nullptr;
     114        }
     115
     116        const ast::Decl * visit( const ast::EnumDecl * node ) override final {
     117                (void)node;
     118                return nullptr;
     119        }
     120
     121        const ast::Decl * visit( const ast::TraitDecl * node ) override final {
     122                (void)node;
    169123                return nullptr;
    170124        }
    171125
    172126        const ast::Decl * visit( const ast::TypeDecl * node ) override final {
    173                 if ( inCache( node ) ) return nullptr;
    174                 auto decl = new TypeDecl(
    175                         node->name,
    176                         Type::StorageClasses( node->storage.val ),
    177                         get<Type>().accept1( node->base ),
    178                         (TypeDecl::Kind)(unsigned)node->kind,
    179                         node->sized,
    180                         get<Type>().accept1( node->init )
    181                 );
    182                 cache.emplace( node, decl );
    183                 return namedTypePostamble( decl, node );
     127                (void)node;
     128                return nullptr;
    184129        }
    185130
    186131        const ast::Decl * visit( const ast::TypedefDecl * node ) override final {
    187                 auto decl = new TypedefDecl(
    188                         node->name,
    189                         node->location,
    190                         Type::StorageClasses( node->storage.val ),
    191             get<Type>().accept1( node->base ),
    192                         LinkageSpec::Spec( node->linkage.val )
    193                 );
    194                 return namedTypePostamble( decl, node );
    195         }
    196 
    197         const ast::Decl * aggregatePostamble( AggregateDecl * decl, const ast::AggregateDecl * node ) {
    198                 cache.emplace( node, decl );
    199                 decl->members = get<Declaration>().acceptL( node->members );
    200                 decl->parameters = get<TypeDecl>().acceptL( node->params );
    201                 decl->body = node->body;
    202                 // attributes come from constructor
    203                 decl->parent = get<AggregateDecl>().accept1( node->parent );
    204                 declPostamble( decl, node );
    205                 return nullptr;
    206         }
    207 
    208         const ast::Decl * visit( const ast::StructDecl * node ) override final {
    209                 if ( inCache( node ) ) return nullptr;
    210                 auto decl = new StructDecl(
    211                         node->name,
    212                         node->kind,
    213                         get<Attribute>().acceptL( node->attributes ),
    214                         LinkageSpec::Spec( node->linkage.val )
    215                 );
    216                 return aggregatePostamble( decl, node );
    217         }
    218 
    219         const ast::Decl * visit( const ast::UnionDecl * node ) override final {
    220                 if ( inCache( node ) ) return nullptr;
    221                 auto decl = new UnionDecl(
    222                         node->name,
    223                         get<Attribute>().acceptL( node->attributes ),
    224                         LinkageSpec::Spec( node->linkage.val )
    225                 );
    226                 return aggregatePostamble( decl, node );
    227         }
    228 
    229         const ast::Decl * visit( const ast::EnumDecl * node ) override final {
    230                 if ( inCache( node ) ) return nullptr;
    231                 auto decl = new EnumDecl(
    232                         node->name,
    233                         get<Attribute>().acceptL( node->attributes ),
    234                         LinkageSpec::Spec( node->linkage.val )
    235                 );
    236                 return aggregatePostamble( decl, node );
    237         }
    238 
    239         const ast::Decl * visit( const ast::TraitDecl * node ) override final {
    240                 if ( inCache( node ) ) return nullptr;
    241                 auto decl = new TraitDecl(
    242                         node->name,
    243                         {},
    244                         LinkageSpec::Spec( node->linkage.val )
    245                 );
    246                 return aggregatePostamble( decl, node );
     132                (void)node;
     133                return nullptr;
    247134        }
    248135
    249136        const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final {
    250                 auto decl = new AsmDecl( get<AsmStmt>().accept1( node->stmt ) );
    251                 declPostamble( decl, node );
     137                (void)node;
    252138                return nullptr;
    253139        }
    254140
    255141        const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) override final {
    256                 auto decl = new StaticAssertDecl(
    257                         get<Expression>().accept1( node->cond ),
    258                         get<ConstantExpr>().accept1( node->msg )
    259                 );
    260                 declPostamble( decl, node );
    261                 return nullptr;
    262         }
    263 
    264         const ast::Stmt * stmtPostamble( Statement * stmt, const ast::Stmt * node ) {
    265                 cache.emplace( node, stmt );
    266                 stmt->location = node->location;
    267                 stmt->labels = makeLabelL( stmt, node->labels );
    268                 this->node = stmt;
     142                (void)node;
    269143                return nullptr;
    270144        }
    271145
    272146        const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final {
    273                 if ( inCache( node ) ) return nullptr;
    274147                auto stmt = new CompoundStmt( get<Statement>().acceptL( node->kids ) );
    275                 stmtPostamble( stmt, node );
     148                stmt->location = node->location;
     149                stmt->labels = makeLabelL( stmt, node->labels );
     150                this->node = stmt;
    276151                return nullptr;
    277152        }
    278153
    279154        const ast::Stmt * visit( const ast::ExprStmt * node ) override final {
    280                 if ( inCache( node ) ) return nullptr;
    281                 auto stmt = new ExprStmt( nullptr );
    282                 cache.emplace( node, stmt );
    283                 stmt->expr = get<Expression>().accept1( node->expr );
    284                 return stmtPostamble( stmt, node );
     155                auto stmt = new ExprStmt( get<Expression>().accept1( node->expr ) );
     156                stmt->location = node->location;
     157                stmt->labels = makeLabelL( stmt, node->labels );
     158                this->node = stmt;
     159                return nullptr;
    285160        }
    286161
    287162        const ast::Stmt * visit( const ast::AsmStmt * node ) override final {
    288                 if ( inCache( node ) ) return nullptr;
    289163                auto stmt = new AsmStmt(
    290164                        node->isVolatile,
     
    295169                        makeLabelL( nullptr, node->gotoLabels ) // What are these labelling?
    296170                );
    297                 return stmtPostamble( stmt, node );
     171                stmt->location = node->location;
     172                stmt->labels = makeLabelL( stmt, node->labels );
     173                this->node = stmt;
     174                return nullptr;
    298175        }
    299176
    300177        const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final {
    301                 if ( inCache( node ) ) return nullptr;
    302178                auto stmt = new DirectiveStmt( node->directive );
    303                 return stmtPostamble( stmt, node );
     179                stmt->location = node->location;
     180                stmt->labels = makeLabelL( stmt, node->labels );
     181                this->node = stmt;
     182                return nullptr;
    304183        }
    305184
    306185        const ast::Stmt * visit( const ast::IfStmt * node ) override final {
    307                 if ( inCache( node ) ) return nullptr;
    308186                auto stmt = new IfStmt(
    309187                        get<Expression>().accept1( node->cond ),
     
    312190                        get<Statement>().acceptL( node->inits )
    313191                );
    314                 return stmtPostamble( stmt, node );
     192                stmt->location = node->location;
     193                stmt->labels = makeLabelL( stmt, node->labels );
     194                this->node = stmt;
     195                return nullptr;
    315196        }
    316197
    317198        const ast::Stmt * visit( const ast::SwitchStmt * node ) override final {
    318                 if ( inCache( node ) ) return nullptr;
    319199                auto stmt = new SwitchStmt(
    320200                        get<Expression>().accept1( node->cond ),
    321201                        get<Statement>().acceptL( node->stmts )
    322202                );
    323                 return stmtPostamble( stmt, node );
     203                stmt->location = node->location;
     204                stmt->labels = makeLabelL( stmt, node->labels );
     205                this->node = stmt;
     206                return nullptr;
    324207        }
    325208
    326209        const ast::Stmt * visit( const ast::CaseStmt * node ) override final {
    327                 if ( inCache( node ) ) return nullptr;
    328210                auto stmt = new CaseStmt(
    329211                        get<Expression>().accept1( node->cond ),
     
    331213                        node->isDefault()
    332214                );
    333                 return stmtPostamble( stmt, node );
     215                stmt->location = node->location;
     216                stmt->labels = makeLabelL( stmt, node->labels );
     217                this->node = stmt;
     218                return nullptr;
    334219        }
    335220
    336221        const ast::Stmt * visit( const ast::WhileStmt * node ) override final {
    337                 if ( inCache( node ) ) return nullptr;
    338222                auto inits = get<Statement>().acceptL( node->inits );
    339223                auto stmt = new WhileStmt(
     
    343227                        node->isDoWhile
    344228                );
    345                 return stmtPostamble( stmt, node );
     229                stmt->location = node->location;
     230                stmt->labels = makeLabelL( stmt, node->labels );
     231                this->node = stmt;
     232                return nullptr;
    346233        }
    347234
    348235        const ast::Stmt * visit( const ast::ForStmt * node ) override final {
    349                 if ( inCache( node ) ) return nullptr;
    350236                auto stmt = new ForStmt(
    351237                        get<Statement>().acceptL( node->inits ),
     
    354240                        get<Statement>().accept1( node->body )
    355241                );
    356                 return stmtPostamble( stmt, node );
     242                stmt->location = node->location;
     243                stmt->labels = makeLabelL( stmt, node->labels );
     244                this->node = stmt;
     245                return nullptr;
    357246        }
    358247
    359248        const ast::Stmt * visit( const ast::BranchStmt * node ) override final {
    360                 if ( inCache( node ) ) return nullptr;
    361249                BranchStmt * stmt;
    362250                if (node->computedTarget) {
     
    384272                        stmt->target = makeLabel( stmt, node->target );
    385273                }
    386                 return stmtPostamble( stmt, node );
     274                stmt->location = node->location;
     275                stmt->labels = makeLabelL( stmt, node->labels );
     276                this->node = stmt;
     277                return nullptr;
    387278        }
    388279
    389280        const ast::Stmt * visit( const ast::ReturnStmt * node ) override final {
    390                 if ( inCache( node ) ) return nullptr;
    391281                auto stmt = new ReturnStmt( get<Expression>().accept1( node->expr ) );
    392                 return stmtPostamble( stmt, node );
     282                stmt->location = node->location;
     283                stmt->labels = makeLabelL( stmt, node->labels );
     284                this->node = stmt;
     285                return nullptr;
    393286        }
    394287
    395288        const ast::Stmt * visit( const ast::ThrowStmt * node ) override final {
    396                 if ( inCache( node ) ) return nullptr;
    397289                ThrowStmt::Kind kind;
    398290                switch (node->kind) {
     
    411303                        get<Expression>().accept1( node->target )
    412304                );
    413                 return stmtPostamble( stmt, node );
     305                stmt->location = node->location;
     306                stmt->labels = makeLabelL( stmt, node->labels );
     307                this->node = stmt;
     308                return nullptr;
    414309        }
    415310
    416311        const ast::Stmt * visit( const ast::TryStmt * node ) override final {
    417                 if ( inCache( node ) ) return nullptr;
    418312                auto handlers = get<CatchStmt>().acceptL( node->handlers );
    419313                auto stmt = new TryStmt(
     
    422316                        get<FinallyStmt>().accept1( node->finally )
    423317                );
    424                 return stmtPostamble( stmt, node );
     318                stmt->location = node->location;
     319                stmt->labels = makeLabelL( stmt, node->labels );
     320                this->node = stmt;
     321                return nullptr;
    425322        }
    426323
    427324        const ast::Stmt * visit( const ast::CatchStmt * node ) override final {
    428                 if ( inCache( node ) ) return nullptr;
    429325                CatchStmt::Kind kind;
    430326                switch (node->kind) {
     
    444340                        get<Statement>().accept1( node->body )
    445341                );
    446                 return stmtPostamble( stmt, node );
     342                stmt->location = node->location;
     343                stmt->labels = makeLabelL( stmt, node->labels );
     344                this->node = stmt;
     345                return nullptr;
    447346        }
    448347
    449348        const ast::Stmt * visit( const ast::FinallyStmt * node ) override final {
    450                 if ( inCache( node ) ) return nullptr;
    451349                auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) );
    452                 return stmtPostamble( stmt, node );
     350                stmt->location = node->location;
     351                stmt->labels = makeLabelL( stmt, node->labels );
     352                this->node = stmt;
     353                return nullptr;
    453354        }
    454355
    455356        const ast::Stmt * visit( const ast::WaitForStmt * node ) override final {
    456                 if ( inCache( node ) ) return nullptr;
    457357                auto stmt = new WaitForStmt;
    458358                stmt->clauses.reserve( node->clauses.size() );
    459359                for ( auto clause : node->clauses ) {
    460360                        stmt->clauses.push_back({{
    461                                         get<Expression>().accept1( clause.target.func ),
    462                                         get<Expression>().acceptL( clause.target.args ),
     361                                        get<Expression>().accept1( clause.target.function ),
     362                                        get<Expression>().acceptL( clause.target.arguments ),
    463363                                },
    464364                                get<Statement>().accept1( clause.stmt ),
     
    475375                        get<Expression>().accept1( node->orElse.cond ),
    476376                };
    477                 return stmtPostamble( stmt, node );
     377                stmt->location = node->location;
     378                stmt->labels = makeLabelL( stmt, node->labels );
     379                this->node = stmt;
     380                return nullptr;
    478381        }
    479382
    480383        const ast::Stmt * visit( const ast::WithStmt * node ) override final {
    481                 if ( inCache( node ) ) return nullptr;
    482384                auto stmt = new WithStmt(
    483385                        get<Expression>().acceptL( node->exprs ),
    484386                        get<Statement>().accept1( node->stmt )
    485387                );
    486                 return stmtPostamble( stmt, node );
     388                stmt->location = node->location;
     389                stmt->labels = makeLabelL( stmt, node->labels );
     390                this->node = stmt;
     391                return nullptr;
    487392        }
    488393
    489394        const ast::NullStmt * visit( const ast::NullStmt * node ) override final {
    490                 if ( inCache( node ) ) return nullptr;
    491395                auto stmt = new NullStmt();
    492                 stmtPostamble( stmt, node );
     396                stmt->location = node->location;
     397                stmt->labels = makeLabelL( stmt, node->labels );
     398                this->node = stmt;
    493399                return nullptr;
    494400        }
    495401
    496402        const ast::Stmt * visit( const ast::DeclStmt * node ) override final {
    497                 if ( inCache( node ) ) return nullptr;
    498403                auto stmt = new DeclStmt( get<Declaration>().accept1( node->decl ) );
    499                 return stmtPostamble( stmt, node );
     404                stmt->location = node->location;
     405                stmt->labels = makeLabelL( stmt, node->labels );
     406                this->node = stmt;
     407                return nullptr;
    500408        }
    501409
    502410        const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final {
    503                 if ( inCache( node ) ) return nullptr;
    504                 auto stmt = new ImplicitCtorDtorStmt{
    505                         get<Statement>().accept1( node->callStmt )
    506                 };
    507                 return stmtPostamble( stmt, node );
    508         }
    509 
    510         TypeSubstitution * convertTypeSubstitution(const ast::TypeSubstitution * src) {
    511 
    512                 if (!src) return nullptr;
    513 
    514                 TypeSubstitution *rslt = new TypeSubstitution();
    515 
    516                 for (decltype(src->begin()) src_i = src->begin(); src_i != src->end(); src_i++) {
    517                         rslt->add( src_i->first,
    518                                    get<Type>().accept1(src_i->second) );
    519                 }
    520 
    521                 for (decltype(src->beginVar()) src_i = src->beginVar(); src_i != src->endVar(); src_i++) {
    522                         rslt->addVar( src_i->first,
    523                                       get<Expression>().accept1(src_i->second) );
    524                 }
    525 
    526                 return rslt;
    527         }
    528 
    529         void convertInferUnion(std::map<UniqueId,ParamEntry> &tgtInferParams,
    530                                                    std::vector<UniqueId>         &tgtResnSlots,
    531                                                    const ast::Expr::InferUnion   &srcInferred ) {
    532 
    533                 assert( tgtInferParams.empty() );
    534                 assert( tgtResnSlots.empty() );
    535 
    536                 if ( srcInferred.mode == ast::Expr::InferUnion::Params ) {
    537                         const ast::InferredParams &srcParams = srcInferred.inferParamsConst();
    538                         for (auto srcParam : srcParams) {
    539                                 tgtInferParams[srcParam.first] = ParamEntry(
    540                                         srcParam.second.decl,
    541                                         get<Type>().accept1(srcParam.second.actualType),
    542                                         get<Type>().accept1(srcParam.second.formalType),
    543                                         get<Expression>().accept1(srcParam.second.expr)
    544                                 );
    545                         }
    546                 } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots  ) {
    547                         const ast::ResnSlots &srcSlots = srcInferred.resnSlotsConst();
    548                         for (auto srcSlot : srcSlots) {
    549                                 tgtResnSlots.push_back(srcSlot);
    550                         }
    551                 }
    552         }
    553 
    554         Expression * visitBaseExpr_skipResultType(const ast::Expr * src, Expression * tgt) {
    555 
    556                 tgt->location  = src->location;
    557                 tgt->env       = convertTypeSubstitution(src->env);
    558                 tgt->extension = src->extension;
    559 
    560                 convertInferUnion(tgt->inferParams, tgt->resnSlots, src->inferred);
    561                 return tgt;
    562         }
    563 
    564         Expression * visitBaseExpr(const ast::Expr * src, Expression * tgt) {
    565 
    566                 tgt->result = get<Type>().accept1(src->result);
    567                 return visitBaseExpr_skipResultType(src, tgt);
     411                (void)node;
     412                return nullptr;
    568413        }
    569414
    570415        const ast::Expr * visit( const ast::ApplicationExpr * node ) override final {
    571                 auto expr = visitBaseExpr( node,
    572                         new ApplicationExpr(
    573                                 get<Expression>().accept1(node->func),
    574                                 get<Expression>().acceptL(node->args)
    575                         )
    576                 );
    577                 this->node = expr;
     416                (void)node;
    578417                return nullptr;
    579418        }
    580419
    581420        const ast::Expr * visit( const ast::UntypedExpr * node ) override final {
    582                 auto expr = visitBaseExpr( node,
    583                         new UntypedExpr(
    584                                 get<Expression>().accept1(node->func),
    585                                 get<Expression>().acceptL(node->args)
    586                         )
    587                 );
    588                 this->node = expr;
     421                (void)node;
    589422                return nullptr;
    590423        }
    591424
    592425        const ast::Expr * visit( const ast::NameExpr * node ) override final {
    593                 auto expr = visitBaseExpr( node,
    594                         new NameExpr(
    595                                 node->name
    596                         )
    597                 );
    598                 this->node = expr;
     426                (void)node;
    599427                return nullptr;
    600428        }
    601429
    602430        const ast::Expr * visit( const ast::AddressExpr * node ) override final {
    603                 auto expr = visitBaseExpr( node,
    604                         new AddressExpr(
    605                                 get<Expression>().accept1(node->arg)
    606                         )
    607                 );
    608                 this->node = expr;
     431                (void)node;
    609432                return nullptr;
    610433        }
    611434
    612435        const ast::Expr * visit( const ast::LabelAddressExpr * node ) override final {
    613                 auto expr = visitBaseExpr( node,
    614                         new LabelAddressExpr(
    615                                 makeLabel(nullptr, node->arg)
    616                         )
    617                 );
    618                 this->node = expr;
     436                (void)node;
    619437                return nullptr;
    620438        }
    621439
    622440        const ast::Expr * visit( const ast::CastExpr * node ) override final {
    623                 auto expr = visitBaseExpr( node,
    624                         new CastExpr(
    625                                 get<Expression>().accept1(node->arg),
    626                                 (node->isGenerated == ast::GeneratedCast)
    627                         )
    628                 );
    629                 this->node = expr;
     441                (void)node;
    630442                return nullptr;
    631443        }
    632444
    633445        const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final {
    634                 KeywordCastExpr::Target castTarget = KeywordCastExpr::NUMBER_OF_TARGETS;
    635                 switch (node->target) {
    636                         case ast::KeywordCastExpr::Coroutine:
    637                                 castTarget = KeywordCastExpr::Coroutine;
    638                                 break;
    639                         case ast::KeywordCastExpr::Thread:
    640                                 castTarget = KeywordCastExpr::Thread;
    641                                 break;
    642                         case ast::KeywordCastExpr::Monitor:
    643                                 castTarget = KeywordCastExpr::Monitor;
    644                                 break;
    645                         default:
    646                                 break;
    647                 }
    648                 assert ( castTarget < KeywordCastExpr::NUMBER_OF_TARGETS );
    649                 auto expr = visitBaseExpr( node,
    650                         new KeywordCastExpr(
    651                                 get<Expression>().accept1(node->arg),
    652                                 castTarget
    653                         )
    654                 );
    655                 this->node = expr;
     446                (void)node;
    656447                return nullptr;
    657448        }
    658449
    659450        const ast::Expr * visit( const ast::VirtualCastExpr * node ) override final {
    660                 auto expr = visitBaseExpr_skipResultType( node,
    661                         new VirtualCastExpr(
    662                                 get<Expression>().accept1(node->arg),
    663                                 get<Type>().accept1(node->result)
    664                         )
    665                 );
    666                 this->node = expr;
     451                (void)node;
    667452                return nullptr;
    668453        }
    669454
    670455        const ast::Expr * visit( const ast::UntypedMemberExpr * node ) override final {
    671                 auto expr = visitBaseExpr( node,
    672                         new UntypedMemberExpr(
    673                                 get<Expression>().accept1(node->member),
    674                                 get<Expression>().accept1(node->aggregate)
    675                         )
    676                 );
    677                 this->node = expr;
     456                (void)node;
    678457                return nullptr;
    679458        }
    680459
    681460        const ast::Expr * visit( const ast::MemberExpr * node ) override final {
    682                 auto expr = visitBaseExpr( node,
    683                         new MemberExpr(
    684                                 inCache(node->member) ?
    685                                         dynamic_cast<DeclarationWithType *>(this->node) :
    686                                         get<DeclarationWithType>().accept1(node->member),
    687                                 get<Expression>().accept1(node->aggregate)
    688                         )
    689                 );
    690                 this->node = expr;
     461                (void)node;
    691462                return nullptr;
    692463        }
    693464
    694465        const ast::Expr * visit( const ast::VariableExpr * node ) override final {
    695                 auto expr = visitBaseExpr( node,
    696                         new VariableExpr(
    697                                 inCache(node->var) ?
    698                                         dynamic_cast<DeclarationWithType *>(this->node) :
    699                                         get<DeclarationWithType>().accept1(node->var)
    700                         )
    701                 );
    702                 this->node = expr;
    703                 return nullptr;
    704         }
    705 
    706         bool isIntlikeConstantType(const ast::Type *t) {
    707                 if ( const ast::BasicType * basicType = dynamic_cast< const ast::BasicType * >( t ) ) {
    708                         if ( basicType->isInteger() ) {
    709                                 return true;
    710                         }
    711                 } else if ( dynamic_cast< const ast::OneType * >( t ) ) {
    712                         return true;
    713                 } else if ( dynamic_cast< const ast::ZeroType * >( t ) ) {
    714                         return true;
    715                 } else if ( dynamic_cast< const ast::PointerType * >( t ) ) {
    716                         // null pointer constants, with zero int-values
    717                         return true;
    718                 }
    719                 return false;
    720         }
    721 
    722         bool isFloatlikeConstantType(const ast::Type *t) {
    723                 if ( const ast::BasicType * bty = dynamic_cast< const ast::BasicType * >( t ) ) {
    724                         if ( ! bty->isInteger() ) {
    725                                 return true;
    726                         }
    727                 }
    728                 return false;
    729         }
    730 
    731         bool isStringlikeConstantType(const ast::Type *t) {
    732                 if ( const ast::ArrayType * aty = dynamic_cast< const ast::ArrayType * >( t ) ) {
    733                         if ( const ast::BasicType * bty = aty->base.as<ast::BasicType>() ) {
    734                            if ( bty->kind == ast::BasicType::Kind::Char ) {
    735                                    return true;
    736                            }
    737                         }
    738                 }
    739                 return false;
     466                (void)node;
     467                return nullptr;
    740468        }
    741469
    742470        const ast::Expr * visit( const ast::ConstantExpr * node ) override final {
    743                 ConstantExpr *rslt = nullptr;
    744                 if (isIntlikeConstantType(node->result)) {
    745                         rslt = new ConstantExpr(Constant(
    746                                 get<Type>().accept1(node->result),
    747                                 node->rep,
    748                                 (unsigned long long) node->intValue()
    749                         ));
    750                 } else if (isFloatlikeConstantType(node->result)) {
    751                         rslt = new ConstantExpr(Constant(
    752                                 get<Type>().accept1(node->result),
    753                                 node->rep,
    754                                 (double) node->floatValue()
    755                         ));
    756                 } else if (isStringlikeConstantType(node->result)) {
    757                         rslt = new ConstantExpr(Constant::from_string(
    758                                 node->rep
    759                         ));
    760                 }
    761                 assert(rslt);
    762                 auto expr = visitBaseExpr( node, rslt );
    763                 this->node = expr;
     471                (void)node;
    764472                return nullptr;
    765473        }
    766474
    767475        const ast::Expr * visit( const ast::SizeofExpr * node ) override final {
    768                 assert (node->expr || node->type);
    769                 assert (! (node->expr && node->type));
    770                 SizeofExpr *rslt;
    771                 if (node->expr) {
    772                         rslt = new SizeofExpr(
    773                                 get<Expression>().accept1(node->expr)
    774                         );
    775                         assert (!rslt->isType);
    776                 }
    777                 if (node->type) {
    778                         rslt = new SizeofExpr(
    779                                 get<Type>().accept1(node->type)
    780                         );
    781                         assert (rslt->isType);
    782                 }
    783                 auto expr = visitBaseExpr( node, rslt );
    784                 this->node = expr;
     476                (void)node;
    785477                return nullptr;
    786478        }
    787479
    788480        const ast::Expr * visit( const ast::AlignofExpr * node ) override final {
    789                 assert (node->expr || node->type);
    790                 assert (! (node->expr && node->type));
    791                 AlignofExpr *rslt;
    792                 if (node->expr) {
    793                         rslt = new AlignofExpr(
    794                                 get<Expression>().accept1(node->expr)
    795                         );
    796                         assert (!rslt->isType);
    797                 }
    798                 if (node->type) {
    799                         rslt = new AlignofExpr(
    800                                 get<Type>().accept1(node->type)
    801                         );
    802                         assert (rslt->isType);
    803                 }
    804                 auto expr = visitBaseExpr( node, rslt );
    805                 this->node = expr;
     481                (void)node;
    806482                return nullptr;
    807483        }
    808484
    809485        const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) override final {
    810                 auto expr = visitBaseExpr( node,
    811                         new UntypedOffsetofExpr(
    812                                 get<Type>().accept1(node->type),
    813                                 node->member
    814                         )
    815                 );
    816                 this->node = expr;
     486                (void)node;
    817487                return nullptr;
    818488        }
    819489
    820490        const ast::Expr * visit( const ast::OffsetofExpr * node ) override final {
    821                 auto expr = visitBaseExpr( node,
    822                         new OffsetofExpr(
    823                                 get<Type>().accept1(node->type),
    824                                 inCache(node->member) ?
    825                                         dynamic_cast<DeclarationWithType *>(this->node) :
    826                                         get<DeclarationWithType>().accept1(node->member)
    827                         )
    828                 );
    829                 this->node = expr;
     491                (void)node;
    830492                return nullptr;
    831493        }
    832494
    833495        const ast::Expr * visit( const ast::OffsetPackExpr * node ) override final {
    834                 auto expr = visitBaseExpr( node,
    835                         new OffsetPackExpr(
    836                                 get<StructInstType>().accept1(node->type)
    837                         )
    838                 );
    839                 this->node = expr;
     496                (void)node;
    840497                return nullptr;
    841498        }
    842499
    843500        const ast::Expr * visit( const ast::LogicalExpr * node ) override final {
    844                 assert (node->isAnd == ast::LogicalFlag::AndExpr ||
    845                                 node->isAnd == ast::LogicalFlag::OrExpr );
    846                 auto expr = visitBaseExpr( node,
    847                         new LogicalExpr(
    848                                 get<Expression>().accept1(node->arg1),
    849                                 get<Expression>().accept1(node->arg2),
    850                                 (node->isAnd == ast::LogicalFlag::AndExpr)
    851                         )
    852                 );
    853                 this->node = expr;
     501                (void)node;
    854502                return nullptr;
    855503        }
    856504
    857505        const ast::Expr * visit( const ast::ConditionalExpr * node ) override final {
    858                 auto expr = visitBaseExpr( node,
    859                         new ConditionalExpr(
    860                                 get<Expression>().accept1(node->arg1),
    861                                 get<Expression>().accept1(node->arg2),
    862                                 get<Expression>().accept1(node->arg3)
    863                         )
    864                 );
    865                 this->node = expr;
     506                (void)node;
    866507                return nullptr;
    867508        }
    868509
    869510        const ast::Expr * visit( const ast::CommaExpr * node ) override final {
    870                 auto expr = visitBaseExpr( node,
    871                         new CommaExpr(
    872                                 get<Expression>().accept1(node->arg1),
    873                                 get<Expression>().accept1(node->arg2)
    874                         )
    875                 );
    876                 this->node = expr;
     511                (void)node;
    877512                return nullptr;
    878513        }
    879514
    880515        const ast::Expr * visit( const ast::TypeExpr * node ) override final {
    881                 auto expr = visitBaseExpr( node,
    882                         new TypeExpr(
    883                                 get<Type>().accept1(node->type)
    884                         )
    885                 );
    886                 this->node = expr;
     516                (void)node;
    887517                return nullptr;
    888518        }
    889519
    890520        const ast::Expr * visit( const ast::AsmExpr * node ) override final {
    891                 auto expr = visitBaseExpr( node,
    892                         new AsmExpr(
    893                                 get<Expression>().accept1(node->inout),
    894                                 get<Expression>().accept1(node->constraint),
    895                                 get<Expression>().accept1(node->operand)
    896                         )
    897                 );
    898                 this->node = expr;
     521                (void)node;
    899522                return nullptr;
    900523        }
    901524
    902525        const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) override final {
    903                 auto rslt = new ImplicitCopyCtorExpr(
    904                         get<ApplicationExpr>().accept1(node->callExpr)
    905                 );
    906 
    907                 rslt->tempDecls = get<ObjectDecl>().acceptL(node->tempDecls);
    908                 rslt->returnDecls = get<ObjectDecl>().acceptL(node->returnDecls);
    909                 rslt->dtors = get<Expression>().acceptL(node->dtors);
    910 
    911                 auto expr = visitBaseExpr( node, rslt );
    912                 this->node = expr;
     526                (void)node;
    913527                return nullptr;
    914528        }
    915529
    916530        const ast::Expr * visit( const ast::ConstructorExpr * node ) override final {
    917                 auto expr = visitBaseExpr( node,
    918                         new ConstructorExpr(
    919                                 get<Expression>().accept1(node->callExpr)
    920                         )
    921                 );
    922                 this->node = expr;
     531                (void)node;
    923532                return nullptr;
    924533        }
    925534
    926535        const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) override final {
    927                 auto expr = visitBaseExpr_skipResultType( node,
    928                         new CompoundLiteralExpr(
    929                                 get<Type>().accept1(node->result),
    930                                 get<Initializer>().accept1(node->init)
    931                         )
    932                 );
    933                 this->node = expr;
     536                (void)node;
    934537                return nullptr;
    935538        }
    936539
    937540        const ast::Expr * visit( const ast::RangeExpr * node ) override final {
    938                 auto expr = visitBaseExpr( node,
    939                         new RangeExpr(
    940                                 get<Expression>().accept1(node->low),
    941                                 get<Expression>().accept1(node->high)
    942                         )
    943                 );
    944                 this->node = expr;
     541                (void)node;
    945542                return nullptr;
    946543        }
    947544
    948545        const ast::Expr * visit( const ast::UntypedTupleExpr * node ) override final {
    949                 auto expr = visitBaseExpr( node,
    950                         new UntypedTupleExpr(
    951                                 get<Expression>().acceptL(node->exprs)
    952                         )
    953                 );
    954                 this->node = expr;
     546                (void)node;
    955547                return nullptr;
    956548        }
    957549
    958550        const ast::Expr * visit( const ast::TupleExpr * node ) override final {
    959                 auto expr = visitBaseExpr( node,
    960                         new UntypedTupleExpr(
    961                                 get<Expression>().acceptL(node->exprs)
    962                         )
    963                 );
    964                 this->node = expr;
     551                (void)node;
    965552                return nullptr;
    966553        }
    967554
    968555        const ast::Expr * visit( const ast::TupleIndexExpr * node ) override final {
    969                 auto expr = visitBaseExpr( node,
    970                         new TupleIndexExpr(
    971                                 get<Expression>().accept1(node->tuple),
    972                                 node->index
    973                         )
    974                 );
    975                 this->node = expr;
     556                (void)node;
    976557                return nullptr;
    977558        }
    978559
    979560        const ast::Expr * visit( const ast::TupleAssignExpr * node ) override final {
    980                 auto expr = visitBaseExpr( node,
    981                         new TupleAssignExpr(
    982                                 get<StmtExpr>().accept1(node->stmtExpr)
    983                         )
    984                 );
    985                 this->node = expr;
     561                (void)node;
    986562                return nullptr;
    987563        }
    988564
    989565        const ast::Expr * visit( const ast::StmtExpr * node ) override final {
    990                 auto rslt = new StmtExpr(
    991                         get<CompoundStmt>().accept1(node->stmts)
    992                 );
    993 
    994                 rslt->returnDecls = get<ObjectDecl>().acceptL(node->returnDecls);
    995                 rslt->dtors       = get<Expression>().acceptL(node->dtors);
    996 
    997                 auto expr = visitBaseExpr( node, rslt );
    998                 this->node = expr;
     566                (void)node;
    999567                return nullptr;
    1000568        }
    1001569
    1002570        const ast::Expr * visit( const ast::UniqueExpr * node ) override final {
    1003                 auto rslt = new UniqueExpr(
    1004                         get<Expression>().accept1(node->expr)
    1005                 );
    1006 
    1007                 rslt->object = get<ObjectDecl>  ().accept1(node->object);
    1008                 rslt->var    = get<VariableExpr>().accept1(node->var);
    1009 
    1010                 auto expr = visitBaseExpr( node, rslt );
    1011                 this->node = expr;
     571                (void)node;
    1012572                return nullptr;
    1013573        }
    1014574
    1015575        const ast::Expr * visit( const ast::UntypedInitExpr * node ) override final {
    1016                 std::list<InitAlternative> initAlts;
    1017                 for (auto ia : node->initAlts) {
    1018                         initAlts.push_back(InitAlternative(
    1019                                 get<Type>       ().accept1(ia.type),
    1020                                 get<Designation>().accept1(ia.designation)
    1021                         ));
    1022                 }
    1023                 auto expr = visitBaseExpr( node,
    1024                         new UntypedInitExpr(
    1025                                 get<Expression>().accept1(node->expr),
    1026                                 initAlts
    1027                         )
    1028                 );
    1029                 this->node = expr;
     576                (void)node;
    1030577                return nullptr;
    1031578        }
    1032579
    1033580        const ast::Expr * visit( const ast::InitExpr * node ) override final {
    1034                 auto expr = visitBaseExpr( node,
    1035                         new InitExpr(
    1036                                 get<Expression>().accept1(node->expr),
    1037                                 get<Designation>().accept1(node->designation)
    1038                         )
    1039                 );
    1040                 this->node = expr;
     581                (void)node;
    1041582                return nullptr;
    1042583        }
    1043584
    1044585        const ast::Expr * visit( const ast::DeletedExpr * node ) override final {
    1045                 auto expr = visitBaseExpr( node,
    1046                         new DeletedExpr(
    1047                                 get<Expression>().accept1(node->expr),
    1048                                 inCache(node->deleteStmt) ?
    1049                                         this->node :
    1050                                         get<BaseSyntaxNode>().accept1(node->deleteStmt)
    1051                         )
    1052                 );
    1053                 this->node = expr;
     586                (void)node;
    1054587                return nullptr;
    1055588        }
    1056589
    1057590        const ast::Expr * visit( const ast::DefaultArgExpr * node ) override final {
    1058                 auto expr = visitBaseExpr( node,
    1059                         new DefaultArgExpr(
    1060                                 get<Expression>().accept1(node->expr)
    1061                         )
    1062                 );
    1063                 this->node = expr;
     591                (void)node;
    1064592                return nullptr;
    1065593        }
    1066594
    1067595        const ast::Expr * visit( const ast::GenericExpr * node ) override final {
    1068                 std::list<GenericExpr::Association> associations;
    1069                 for (auto association : node->associations) {
    1070                         associations.push_back(GenericExpr::Association(
    1071                                 get<Type>      ().accept1(association.type),
    1072                                 get<Expression>().accept1(association.expr)
    1073                         ));
    1074                 }
    1075                 auto expr = visitBaseExpr( node,
    1076                         new GenericExpr(
    1077                                 get<Expression>().accept1(node->control),
    1078                                 associations
    1079                         )
    1080                 );
    1081                 this->node = expr;
     596                (void)node;
    1082597                return nullptr;
    1083598        }
    1084599
    1085600        const ast::Type * visit( const ast::VoidType * node ) override final {
    1086                 this->node = new VoidType{ cv( node ) };
     601                (void)node;
    1087602                return nullptr;
    1088603        }
    1089604
    1090605        const ast::Type * visit( const ast::BasicType * node ) override final {
    1091                 this->node = new BasicType{ cv( node ), (BasicType::Kind)(unsigned)node->kind };
     606                (void)node;
    1092607                return nullptr;
    1093608        }
    1094609
    1095610        const ast::Type * visit( const ast::PointerType * node ) override final {
    1096                 this->node = new PointerType{
    1097                         cv( node ),
    1098                         get<Type>().accept1( node->base ),
    1099                         get<Expression>().accept1( node->dimension ),
    1100                         (bool)node->isVarLen,
    1101                         (bool)node->isStatic
    1102                 };
     611                (void)node;
    1103612                return nullptr;
    1104613        }
    1105614
    1106615        const ast::Type * visit( const ast::ArrayType * node ) override final {
    1107                 this->node = new ArrayType{
    1108                         cv( node ),
    1109                         get<Type>().accept1( node->base ),
    1110                         get<Expression>().accept1( node->dimension ),
    1111                         (bool)node->isVarLen,
    1112                         (bool)node->isStatic
    1113                 };
     616                (void)node;
    1114617                return nullptr;
    1115618        }
    1116619
    1117620        const ast::Type * visit( const ast::ReferenceType * node ) override final {
    1118                 this->node = new ReferenceType{
    1119                         cv( node ),
    1120                         get<Type>().accept1( node->base )
    1121                 };
     621                (void)node;
    1122622                return nullptr;
    1123623        }
    1124624
    1125625        const ast::Type * visit( const ast::QualifiedType * node ) override final {
    1126                 this->node = new QualifiedType{
    1127                         cv( node ),
    1128                         get<Type>().accept1( node->parent ),
    1129                         get<Type>().accept1( node->child )
    1130                 };
     626                (void)node;
    1131627                return nullptr;
    1132628        }
    1133629
    1134630        const ast::Type * visit( const ast::FunctionType * node ) override final {
    1135                 auto ty = new FunctionType {
    1136                         cv( node ),
    1137                         (bool)node->isVarArgs
    1138                 };
    1139                 ty->returnVals = get<DeclarationWithType>().acceptL( node->returns );
    1140                 ty->parameters = get<DeclarationWithType>().acceptL( node->params );
    1141                 ty->forall = get<TypeDecl>().acceptL( node->forall );
    1142                 this->node = ty;
    1143                 return nullptr;
    1144         }
    1145 
    1146         void postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) {
    1147                 ty->forall = get<TypeDecl>().acceptL( old->forall );
    1148                 ty->parameters = get<Expression>().acceptL( old->params );
    1149                 ty->hoistType = old->hoistType;
     631                (void)node;
     632                return nullptr;
    1150633        }
    1151634
    1152635        const ast::Type * visit( const ast::StructInstType * node ) override final {
    1153                 StructInstType * ty;
    1154                 if ( node->base ) {
    1155                         ty = new StructInstType{
    1156                                 cv( node ),
    1157                                 get<StructDecl>().accept1( node->base ),
    1158                                 get<Attribute>().acceptL( node->attributes )
    1159                         };
    1160                 } else {
    1161                         ty = new StructInstType{
    1162                                 cv( node ),
    1163                                 node->name,
    1164                                 get<Attribute>().acceptL( node->attributes )
    1165                         };
    1166                 }
    1167                 postvisit( node, ty );
    1168                 this->node = ty;
     636                (void)node;
    1169637                return nullptr;
    1170638        }
    1171639
    1172640        const ast::Type * visit( const ast::UnionInstType * node ) override final {
    1173                 UnionInstType * ty;
    1174                 if ( node->base ) {
    1175                         ty = new UnionInstType{
    1176                                 cv( node ),
    1177                                 get<UnionDecl>().accept1( node->base ),
    1178                                 get<Attribute>().acceptL( node->attributes )
    1179                         };
    1180                 } else {
    1181                         ty = new UnionInstType{
    1182                                 cv( node ),
    1183                                 node->name,
    1184                                 get<Attribute>().acceptL( node->attributes )
    1185                         };
    1186                 }
    1187                 postvisit( node, ty );
    1188                 this->node = ty;
     641                (void)node;
    1189642                return nullptr;
    1190643        }
    1191644
    1192645        const ast::Type * visit( const ast::EnumInstType * node ) override final {
    1193                 EnumInstType * ty;
    1194                 if ( node->base ) {
    1195                         ty = new EnumInstType{
    1196                                 cv( node ),
    1197                                 get<EnumDecl>().accept1( node->base ),
    1198                                 get<Attribute>().acceptL( node->attributes )
    1199                         };
    1200                 } else {
    1201                         ty = new EnumInstType{
    1202                                 cv( node ),
    1203                                 node->name,
    1204                                 get<Attribute>().acceptL( node->attributes )
    1205                         };
    1206                 }
    1207                 postvisit( node, ty );
    1208                 this->node = ty;
     646                (void)node;
    1209647                return nullptr;
    1210648        }
    1211649
    1212650        const ast::Type * visit( const ast::TraitInstType * node ) override final {
    1213                 TraitInstType * ty;
    1214                 if ( node->base ) {
    1215                         ty = new TraitInstType{
    1216                                 cv( node ),
    1217                                 get<TraitDecl>().accept1( node->base ),
    1218                                 get<Attribute>().acceptL( node->attributes )
    1219                         };
    1220                 } else {
    1221                         ty = new TraitInstType{
    1222                                 cv( node ),
    1223                                 node->name,
    1224                                 get<Attribute>().acceptL( node->attributes )
    1225                         };
    1226                 }
    1227                 postvisit( node, ty );
    1228                 this->node = ty;
     651                (void)node;
    1229652                return nullptr;
    1230653        }
    1231654
    1232655        const ast::Type * visit( const ast::TypeInstType * node ) override final {
    1233                 TypeInstType * ty;
    1234                 if ( node->base ) {
    1235                         ty = new TypeInstType{
    1236                                 cv( node ),
    1237                                 node->name,
    1238                                 get<TypeDecl>().accept1( node->base ),
    1239                                 get<Attribute>().acceptL( node->attributes )
    1240                         };
    1241                 } else {
    1242                         ty = new TypeInstType{
    1243                                 cv( node ),
    1244                                 node->name,
    1245                                 node->kind == ast::TypeVar::Ftype,
    1246                                 get<Attribute>().acceptL( node->attributes )
    1247                         };
    1248                 }
    1249                 postvisit( node, ty );
    1250                 this->node = ty;
     656                (void)node;
    1251657                return nullptr;
    1252658        }
    1253659
    1254660        const ast::Type * visit( const ast::TupleType * node ) override final {
    1255                 this->node = new TupleType{
    1256                         cv( node ),
    1257                         get<Type>().acceptL( node->types )
    1258                         // members generated by TupleType c'tor
    1259                 };
     661                (void)node;
    1260662                return nullptr;
    1261663        }
    1262664
    1263665        const ast::Type * visit( const ast::TypeofType * node ) override final {
    1264                 this->node = new TypeofType{
    1265                         cv( node ),
    1266                         get<Expression>().accept1( node->expr ),
    1267                         (bool)node->kind
    1268                 };
     666                (void)node;
    1269667                return nullptr;
    1270668        }
    1271669
    1272670        const ast::Type * visit( const ast::VarArgsType * node ) override final {
    1273                 this->node = new VarArgsType{ cv( node ) };
     671                (void)node;
    1274672                return nullptr;
    1275673        }
    1276674
    1277675        const ast::Type * visit( const ast::ZeroType * node ) override final {
    1278                 this->node = new ZeroType{ cv( node ) };
     676                (void)node;
    1279677                return nullptr;
    1280678        }
    1281679
    1282680        const ast::Type * visit( const ast::OneType * node ) override final {
    1283                 this->node = new OneType{ cv( node ) };
    1284                 return nullptr;
    1285         }
    1286 
    1287         const ast::Type * visit( const ast::GlobalScopeType * ) override final {
    1288                 this->node = new GlobalScopeType{};
     681                (void)node;
     682                return nullptr;
     683        }
     684
     685        const ast::Type * visit( const ast::GlobalScopeType * node ) override final {
     686                (void)node;
    1289687                return nullptr;
    1290688        }
    1291689
    1292690        const ast::Designation * visit( const ast::Designation * node ) override final {
    1293                 auto designation = new Designation( get<Expression>().acceptL( node->designators ) );
    1294                 designation->location = node->location;
    1295                 this->node = designation;
     691                (void)node;
    1296692                return nullptr;
    1297693        }
    1298694
    1299695        const ast::Init * visit( const ast::SingleInit * node ) override final {
    1300                 auto init = new SingleInit(
    1301                         get<Expression>().accept1( node->value ),
    1302                         ast::MaybeConstruct == node->maybeConstructed
    1303                 );
    1304                 init->location = node->location;
    1305                 this->node = init;
     696                (void)node;
    1306697                return nullptr;
    1307698        }
    1308699
    1309700        const ast::Init * visit( const ast::ListInit * node ) override final {
    1310                 auto init = new ListInit(
    1311                         get<Initializer>().acceptL( node->initializers ),
    1312                         get<Designation>().acceptL( node->designations ),
    1313                         ast::MaybeConstruct == node->maybeConstructed
    1314                 );
    1315                 init->location = node->location;
    1316                 this->node = init;
     701                (void)node;
    1317702                return nullptr;
    1318703        }
    1319704
    1320705        const ast::Init * visit( const ast::ConstructorInit * node ) override final {
    1321                 auto init = new ConstructorInit(
    1322                         get<Statement>().accept1( node->ctor ),
    1323                         get<Statement>().accept1( node->dtor ),
    1324                         get<Initializer>().accept1( node->init )
    1325                 );
    1326                 init->location = node->location;
    1327                 this->node = init;
     706                (void)node;
    1328707                return nullptr;
    1329708        }
    1330709
    1331710        const ast::Attribute * visit( const ast::Attribute * node ) override final {
    1332                 auto attr = new Attribute(
    1333                         node->name,
    1334                         get<Expression>().acceptL(node->params)
    1335                 );
    1336                 this->node = attr;
     711                (void)node;
    1337712                return nullptr;
    1338713        }
    1339714
    1340715        const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) override final {
    1341                 // Handled by convertTypeSubstitution helper instead.
    1342                 // TypeSubstitution is not a node in the old model, so the conversion result wouldn't fit in this->node.
    1343                 assert( 0 );
    1344716                (void)node;
    1345717                return nullptr;
     
    1347719};
    1348720
    1349 std::list< Declaration * > convert( const std::list< ast::ptr< ast::Decl > > && translationUnit ) {
     721std::list< Declaration * > convert( std::list< ast::ptr< ast::Decl > > && translationUnit ) {
    1350722        ConverterNewToOld c;
    1351723        std::list< Declaration * > decls;
    1352724        for(auto d : translationUnit) {
    1353725                decls.emplace_back( c.decl( d ) );
     726                delete d;
    1354727        }
    1355728        return decls;
     
    1364737        }
    1365738private:
    1366         /// conversion output
    1367739        ast::Node * node;
    1368         /// cache of nodes that might be referenced by readonly<> for de-duplication
    1369         std::unordered_map< BaseSyntaxNode *, ast::Node * > cache;
    1370740
    1371741        // Local Utilities:
     
    1373743        template<typename NewT, typename OldT>
    1374744        NewT * getAccept1( OldT old ) {
    1375                 if ( ! old ) return nullptr;
    1376745                old->accept(*this);
    1377746                return strict_dynamic_cast< NewT * >( node );
     
    1415784                to<std::vector>::from( make_labels( std::move( labels ) ) )
    1416785
    1417         static ast::CV::Qualifiers cv( Type * ty ) { return { ty->get_qualifiers().val }; }
    1418 
    1419         /// returns true and sets `node` if in cache
    1420         bool inCache( BaseSyntaxNode * old ) {
    1421                 auto it = cache.find( old );
    1422                 if ( it == cache.end() ) return false;
    1423                 node = it->second;
    1424                 return true;
    1425         }
    1426 
    1427786        // Now all the visit functions:
    1428787
    1429788        virtual void visit( ObjectDecl * old ) override final {
    1430                 if ( inCache( old ) ) return;
    1431789                auto decl = new ast::ObjectDecl(
    1432790                        old->location,
     
    1440798                        { old->get_funcSpec().val }
    1441799                );
    1442                 cache.emplace( old, decl );
    1443800                decl->scopeLevel = old->scopeLevel;
    1444801                decl->mangleName = old->mangleName;
     
    1450807        }
    1451808
    1452         virtual void visit( FunctionDecl * old ) override final {
    1453                 if ( inCache( old ) ) return;
    1454                 auto decl = new ast::FunctionDecl{
    1455                         old->location,
    1456                         old->name,
    1457                         GET_ACCEPT_1(type, FunctionType),
    1458                         GET_ACCEPT_1(statements, CompoundStmt),
    1459                         { old->storageClasses.val },
    1460                         { old->linkage.val },
    1461                         GET_ACCEPT_V(attributes, Attribute),
    1462                         { old->get_funcSpec().val }
    1463                 };
    1464                 cache.emplace( old, decl );
    1465                 decl->scopeLevel = old->scopeLevel;
    1466                 decl->mangleName = old->mangleName;
    1467                 decl->isDeleted  = old->isDeleted;
    1468                 decl->uniqueId   = old->uniqueId;
    1469                 decl->extension  = old->extension;
    1470 
    1471                 this->node = decl;
     809        virtual void visit( FunctionDecl * ) override final {
     810
    1472811        }
    1473812
    1474813        virtual void visit( StructDecl * old ) override final {
    1475                 if ( inCache( old ) ) return;
    1476814                auto decl = new ast::StructDecl(
    1477815                        old->location,
     
    1481819                        { old->linkage.val }
    1482820                );
    1483                 cache.emplace( old, decl );
    1484821                decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
    1485822                decl->body   = old->body;
     
    1494831
    1495832        virtual void visit( UnionDecl * old ) override final {
    1496                 if ( inCache( old ) ) return;
    1497833                auto decl = new ast::UnionDecl(
    1498834                        old->location,
     
    1501837                        { old->linkage.val }
    1502838                );
    1503                 cache.emplace( old, decl );
    1504839                decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
    1505840                decl->body   = old->body;
     
    1514849
    1515850        virtual void visit( EnumDecl * old ) override final {
    1516                 if ( inCache( old ) ) return;
    1517851                auto decl = new ast::UnionDecl(
    1518852                        old->location,
     
    1521855                        { old->linkage.val }
    1522856                );
    1523                 cache.emplace( old, decl );
    1524857                decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
    1525858                decl->body   = old->body;
     
    1534867
    1535868        virtual void visit( TraitDecl * old ) override final {
    1536                 if ( inCache( old ) ) return;
    1537869                auto decl = new ast::UnionDecl(
    1538870                        old->location,
     
    1541873                        { old->linkage.val }
    1542874                );
    1543                 cache.emplace( old, decl );
    1544875                decl->parent = GET_ACCEPT_1(parent, AggregateDecl);
    1545876                decl->body   = old->body;
     
    1553884        }
    1554885
    1555         virtual void visit( TypeDecl * old ) override final {
    1556                 if ( inCache( old ) ) return;
    1557                 auto decl = new ast::TypeDecl{
    1558                         old->location,
    1559                         old->name,
    1560                         { old->storageClasses.val },
    1561                         GET_ACCEPT_1(base, Type),
    1562                         (ast::TypeVar::Kind)(unsigned)old->kind,
    1563                         old->sized,
    1564                         GET_ACCEPT_1(init, Type)
    1565                 };
    1566                 cache.emplace( old, decl );
    1567                 decl->assertions = GET_ACCEPT_V(assertions, DeclWithType);
    1568                 decl->params     = GET_ACCEPT_V(parameters, TypeDecl);
    1569                 decl->extension  = old->extension;
    1570                 decl->uniqueId   = old->uniqueId;
    1571 
    1572                 this->node = decl;
     886        virtual void visit( TypeDecl * ) override final {
     887
    1573888        }
    1574889
     
    1590905        }
    1591906
    1592         virtual void visit( AsmDecl * old ) override final {
    1593                 auto decl = new ast::AsmDecl{
    1594                         old->location,
    1595                         GET_ACCEPT_1(stmt, AsmStmt)
    1596                 };
    1597                 decl->extension  = old->extension;
    1598                 decl->uniqueId   = old->uniqueId;
    1599                 decl->storage    = { old->storageClasses.val };
    1600 
    1601                 this->node = decl;
    1602         }
    1603 
    1604         virtual void visit( StaticAssertDecl * old ) override final {
    1605                 auto decl = new ast::StaticAssertDecl{
    1606                         old->location,
    1607                         GET_ACCEPT_1(condition, Expr),
    1608                         GET_ACCEPT_1(message, ConstantExpr)
    1609                 };
    1610                 decl->extension  = old->extension;
    1611                 decl->uniqueId   = old->uniqueId;
    1612                 decl->storage    = { old->storageClasses.val };
    1613 
    1614                 this->node = decl;
     907        virtual void visit( AsmDecl * ) override final {
     908
     909        }
     910
     911        virtual void visit( StaticAssertDecl * ) override final {
     912
    1615913        }
    1616914
    1617915        virtual void visit( CompoundStmt * old ) override final {
    1618                 if ( inCache( old ) ) return;
    1619916                auto stmt = new ast::CompoundStmt(
    1620917                        old->location,
     
    1624921
    1625922                this->node = stmt;
    1626                 cache.emplace( old, this->node );
    1627923        }
    1628924
    1629925        virtual void visit( ExprStmt * old ) override final {
    1630                 if ( inCache( old ) ) return;
    1631926                this->node = new ast::ExprStmt(
    1632927                        old->location,
     
    1634929                        GET_LABELS_V(old->labels)
    1635930                );
    1636                 cache.emplace( old, this->node );
    1637931        }
    1638932
    1639933        virtual void visit( AsmStmt * old ) override final {
    1640                 if ( inCache( old ) ) return;
    1641934                this->node = new ast::AsmStmt(
    1642935                        old->location,
     
    1649942                        GET_LABELS_V(old->labels)
    1650943                );
    1651                 cache.emplace( old, this->node );
    1652944        }
    1653945
    1654946        virtual void visit( DirectiveStmt * old ) override final {
    1655                 if ( inCache( old ) ) return;
    1656947                this->node = new ast::DirectiveStmt(
    1657948                        old->location,
     
    1659950                        GET_LABELS_V(old->labels)
    1660951                );
    1661                 cache.emplace( old, this->node );
    1662952        }
    1663953
    1664954        virtual void visit( IfStmt * old ) override final {
    1665                 if ( inCache( old ) ) return;
    1666955                this->node = new ast::IfStmt(
    1667956                        old->location,
     
    1672961                        GET_LABELS_V(old->labels)
    1673962                );
    1674                 cache.emplace( old, this->node );
    1675963        }
    1676964
    1677965        virtual void visit( SwitchStmt * old ) override final {
    1678                 if ( inCache( old ) ) return;
    1679966                this->node = new ast::SwitchStmt(
    1680967                        old->location,
     
    1683970                        GET_LABELS_V(old->labels)
    1684971                );
    1685                 cache.emplace( old, this->node );
    1686972        }
    1687973
    1688974        virtual void visit( CaseStmt * old ) override final {
    1689                 if ( inCache( old ) ) return;
    1690975                this->node = new ast::CaseStmt(
    1691976                        old->location,
     
    1694979                        GET_LABELS_V(old->labels)
    1695980                );
    1696                 cache.emplace( old, this->node );
    1697981        }
    1698982
    1699983        virtual void visit( WhileStmt * old ) override final {
    1700                 if ( inCache( old ) ) return;
    1701984                this->node = new ast::WhileStmt(
    1702985                        old->location,
     
    1707990                        GET_LABELS_V(old->labels)
    1708991                );
    1709                 cache.emplace( old, this->node );
    1710992        }
    1711993
    1712994        virtual void visit( ForStmt * old ) override final {
    1713                 if ( inCache( old ) ) return;
    1714995                this->node = new ast::ForStmt(
    1715996                        old->location,
     
    17201001                        GET_LABELS_V(old->labels)
    17211002                );
    1722                 cache.emplace( old, this->node );
    17231003        }
    17241004
    17251005        virtual void visit( BranchStmt * old ) override final {
    1726                 if ( inCache( old ) ) return;
    17271006                if (old->computedTarget) {
    17281007                        this->node = new ast::BranchStmt(
     
    17581037                        this->node = stmt;
    17591038                }
    1760                 cache.emplace( old, this->node );
    17611039        }
    17621040
    17631041        virtual void visit( ReturnStmt * old ) override final {
    1764                 if ( inCache( old ) ) return;
    17651042                this->node = new ast::ReturnStmt(
    17661043                        old->location,
     
    17681045                        GET_LABELS_V(old->labels)
    17691046                );
    1770                 cache.emplace( old, this->node );
    17711047        }
    17721048
    17731049        virtual void visit( ThrowStmt * old ) override final {
    1774                 if ( inCache( old ) ) return;
    17751050                ast::ThrowStmt::Kind kind;
    17761051                switch (old->kind) {
     
    17921067                        GET_LABELS_V(old->labels)
    17931068                );
    1794                 cache.emplace( old, this->node );
    17951069        }
    17961070
    17971071        virtual void visit( TryStmt * old ) override final {
    1798                 if ( inCache( old ) ) return;
    17991072                this->node = new ast::TryStmt(
    18001073                        old->location,
     
    18041077                        GET_LABELS_V(old->labels)
    18051078                );
    1806                 cache.emplace( old, this->node );
    18071079        }
    18081080
    18091081        virtual void visit( CatchStmt * old ) override final {
    1810                 if ( inCache( old ) ) return;
    18111082                ast::CatchStmt::Kind kind;
    18121083                switch (old->kind) {
     
    18291100                        GET_LABELS_V(old->labels)
    18301101                );
    1831                 cache.emplace( old, this->node );
    18321102        }
    18331103
    18341104        virtual void visit( FinallyStmt * old ) override final {
    1835                 if ( inCache( old ) ) return;
    18361105                this->node = new ast::FinallyStmt(
    18371106                        old->location,
     
    18391108                        GET_LABELS_V(old->labels)
    18401109                );
    1841                 cache.emplace( old, this->node );
    18421110        }
    18431111
    18441112        virtual void visit( WaitForStmt * old ) override final {
    1845                 if ( inCache( old ) ) return;
    18461113                ast::WaitForStmt * stmt = new ast::WaitForStmt(
    18471114                        old->location,
     
    18711138
    18721139                this->node = stmt;
    1873                 cache.emplace( old, this->node );
    18741140        }
    18751141
    18761142        virtual void visit( WithStmt * old ) override final {
    1877                 if ( inCache( old ) ) return;
    18781143                this->node = new ast::WithStmt(
    18791144                        old->location,
     
    18821147                        GET_LABELS_V(old->labels)
    18831148                );
    1884                 cache.emplace( old, this->node );
    18851149        }
    18861150
    18871151        virtual void visit( NullStmt * old ) override final {
    1888                 if ( inCache( old ) ) return;
    18891152                this->node = new ast::NullStmt(
    18901153                        old->location,
    18911154                        GET_LABELS_V(old->labels)
    18921155                );
    1893                 cache.emplace( old, this->node );
    18941156        }
    18951157
    18961158        virtual void visit( DeclStmt * old ) override final {
    1897                 if ( inCache( old ) ) return;
    18981159                this->node = new ast::DeclStmt(
    18991160                        old->location,
     
    19011162                        GET_LABELS_V(old->labels)
    19021163                );
    1903                 cache.emplace( old, this->node );
    19041164        }
    19051165
    19061166        virtual void visit( ImplicitCtorDtorStmt * old ) override final {
    1907                 if ( inCache( old ) ) return;
    1908                 auto stmt = new ast::ImplicitCtorDtorStmt(
    1909                         old->location,
    1910                         nullptr,
    1911                         GET_LABELS_V(old->labels)
    1912                 );
    1913                 this->node = stmt;
    1914                 cache.emplace( old, this->node );
    1915                 stmt->callStmt = GET_ACCEPT_1(callStmt, Stmt);
    1916         }
    1917 
    1918         ast::TypeSubstitution * convertTypeSubstitution(const TypeSubstitution * old) {
    1919 
    1920                 if (!old) return nullptr;
    1921 
    1922                 ast::TypeSubstitution *rslt = new ast::TypeSubstitution();
    1923 
    1924                 for (decltype(old->begin()) old_i = old->begin(); old_i != old->end(); old_i++) {
    1925                         rslt->add( old_i->first,
    1926                                    getAccept1<ast::Type>(old_i->second) );
    1927                 }
    1928 
    1929                 for (decltype(old->beginVar()) old_i = old->beginVar(); old_i != old->endVar(); old_i++) {
    1930                         rslt->addVar( old_i->first,
    1931                                       getAccept1<ast::Expr>(old_i->second) );
    1932                 }
    1933 
    1934                 return rslt;
    1935         }
    1936 
    1937         void convertInferUnion(ast::Expr::InferUnion               &newInferred,
    1938                                                    const std::map<UniqueId,ParamEntry> &oldInferParams,
    1939                                                    const std::vector<UniqueId>         &oldResnSlots) {
    1940 
    1941                 assert( oldInferParams.empty() || oldResnSlots.empty() );
    1942                 assert( newInferred.mode == ast::Expr::InferUnion::Empty );
    1943 
    1944                 if ( !oldInferParams.empty() ) {
    1945                         ast::InferredParams &tgt = newInferred.inferParams();
    1946                         for (auto old : oldInferParams) {
    1947                                 tgt[old.first] = ast::ParamEntry(
    1948                                         old.second.decl,
    1949                                         getAccept1<ast::Type>(old.second.actualType),
    1950                                         getAccept1<ast::Type>(old.second.formalType),
    1951                                         getAccept1<ast::Expr>(old.second.expr)
    1952                                 );
    1953                         }
    1954                 } else if ( !oldResnSlots.empty() ) {
    1955                         ast::ResnSlots &tgt = newInferred.resnSlots();
    1956                         for (auto old : oldResnSlots) {
    1957                                 tgt.push_back(old);
    1958                         }
    1959                 }
    1960         }
    1961 
    1962         ast::Expr * visitBaseExpr_SkipResultType(Expression * old, ast::Expr * nw) {
    1963 
    1964                 nw->env    = convertTypeSubstitution(old->env);
    1965 
    1966                 nw->extension = old->extension;
    1967                 convertInferUnion(nw->inferred, old->inferParams, old->resnSlots);
    1968 
    1969                 return nw;
    1970         }
    1971 
    1972         ast::Expr * visitBaseExpr(Expression * old, ast::Expr * nw) {
    1973 
    1974                 nw->result = GET_ACCEPT_1(result, Type);
    1975                 return visitBaseExpr_SkipResultType(old, nw);;
    1976         }
    1977 
    1978         virtual void visit( ApplicationExpr * old ) override final {
    1979                 this->node = visitBaseExpr( old,
    1980                         new ast::ApplicationExpr(
    1981                                 old->location,
    1982                                 GET_ACCEPT_1(function, Expr),
    1983                                 GET_ACCEPT_V(args, Expr)
    1984                         )
    1985                 );
    1986         }
    1987 
    1988         virtual void visit( UntypedExpr * old ) override final {
    1989                 this->node = visitBaseExpr( old,
    1990                         new ast::UntypedExpr(
    1991                                 old->location,
    1992                                 GET_ACCEPT_1(function, Expr),
    1993                                 GET_ACCEPT_V(args, Expr)
    1994                         )
    1995                 );
    1996         }
    1997 
    1998         virtual void visit( NameExpr * old ) override final {
    1999                 this->node = visitBaseExpr( old,
    2000                         new ast::NameExpr(
    2001                                 old->location,
    2002                                 old->get_name()
    2003                         )
    2004                 );
    2005         }
    2006 
    2007         virtual void visit( CastExpr * old ) override final {
    2008                 this->node = visitBaseExpr( old,
    2009                         new ast::CastExpr(
    2010                                 old->location,
    2011                                 GET_ACCEPT_1(arg, Expr),
    2012                                 old->isGenerated ? ast::GeneratedCast : ast::ExplicitCast
    2013                         )
    2014                 );
    2015         }
    2016 
    2017         virtual void visit( KeywordCastExpr * old) override final {
    2018                 ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS;
    2019                 switch (old->target) {
    2020                         case KeywordCastExpr::Coroutine:
    2021                                 castTarget = ast::KeywordCastExpr::Coroutine;
    2022                                 break;
    2023                         case KeywordCastExpr::Thread:
    2024                                 castTarget = ast::KeywordCastExpr::Thread;
    2025                                 break;
    2026                         case KeywordCastExpr::Monitor:
    2027                                 castTarget = ast::KeywordCastExpr::Monitor;
    2028                                 break;
    2029                         default:
    2030                                 break;
    2031                 }
    2032                 assert ( castTarget < ast::KeywordCastExpr::NUMBER_OF_TARGETS );
    2033                 this->node = visitBaseExpr( old,
    2034                         new ast::KeywordCastExpr(
    2035                                 old->location,
    2036                                 GET_ACCEPT_1(arg, Expr),
    2037                                 castTarget
    2038                         )
    2039                 );
    2040         }
    2041 
    2042         virtual void visit( VirtualCastExpr * old ) override final {
    2043                 this->node = visitBaseExpr_SkipResultType( old,
    2044                         new ast::VirtualCastExpr(
    2045                                 old->location,
    2046                                 GET_ACCEPT_1(arg, Expr),
    2047                                 GET_ACCEPT_1(result, Type)
    2048                         )
    2049                 );
    2050         }
    2051 
    2052         virtual void visit( AddressExpr * old ) override final {
    2053                 this->node = visitBaseExpr( old,
    2054                         new ast::AddressExpr(
    2055                                 old->location,
    2056                                 GET_ACCEPT_1(arg, Expr)
    2057                         )
    2058                 );
    2059         }
    2060 
    2061         virtual void visit( LabelAddressExpr * old ) override final {
    2062                 this->node = visitBaseExpr( old,
    2063                         new ast::LabelAddressExpr(
    2064                                 old->location,
    2065                                 make_label(&old->arg)
    2066                         )
    2067                 );
    2068         }
    2069 
    2070         virtual void visit( UntypedMemberExpr * old ) override final {
    2071                 this->node = visitBaseExpr( old,
    2072                         new ast::UntypedMemberExpr(
    2073                                 old->location,
    2074                                 GET_ACCEPT_1(member, Expr),
    2075                                 GET_ACCEPT_1(aggregate, Expr)
    2076                         )
    2077                 );
    2078         }
    2079 
    2080         virtual void visit( MemberExpr * old ) override final {
    2081                 this->node = visitBaseExpr( old,
    2082                         new ast::MemberExpr(
    2083                                 old->location,
    2084                                 inCache(old->member) ?
    2085                                         dynamic_cast<ast::DeclWithType *>(this->node) :
    2086                                         GET_ACCEPT_1(member, DeclWithType),
    2087                                 GET_ACCEPT_1(aggregate, Expr)
    2088                         )
    2089                 );
    2090         }
    2091 
    2092         virtual void visit( VariableExpr * old ) override final {
    2093                 this->node = visitBaseExpr( old,
    2094                         new ast::VariableExpr(
    2095                                 old->location,
    2096                                 inCache(old->var) ?
    2097                                         dynamic_cast<ast::DeclWithType *>(this->node) :
    2098                                         GET_ACCEPT_1(var, DeclWithType)
    2099                         )
    2100                 );
    2101         }
    2102 
    2103         bool isIntlikeConstantType(const Type *t) {
    2104                 if ( const BasicType * basicType = dynamic_cast< const BasicType * >( t ) ) {
    2105                         if ( basicType->isInteger() ) {
    2106                                 return true;
    2107                         }
    2108                 } else if ( dynamic_cast< const OneType * >( t ) ) {
    2109                         return true;
    2110                 } else if ( dynamic_cast< const ZeroType * >( t ) ) {
    2111                         return true;
    2112                 } else if ( dynamic_cast< const PointerType * >( t ) ) {
    2113                         // null pointer constants, with zero int-values
    2114                         return true;
    2115                 }
    2116                 return false;
    2117         }
    2118 
    2119         int isFloatlikeConstantType(const Type *t) {
    2120                 if ( const BasicType * bty = dynamic_cast< const BasicType * >( t ) ) {
    2121                         if ( ! bty->isInteger() ) {
    2122                                 return true;
    2123                         }
    2124                 }
    2125                 return false;
    2126         }
    2127 
    2128         int isStringlikeConstantType(const Type *t) {
    2129                 if ( const ArrayType * aty = dynamic_cast< const ArrayType * >( t ) ) {
    2130                         if ( const BasicType * bty = dynamic_cast< const BasicType * >( aty->base ) ) {
    2131                            if ( bty->kind == BasicType::Kind::Char ) {
    2132                                    return true;
    2133                            }
    2134                         }
    2135                 }
    2136                 return false;
    2137         }
    2138 
    2139         virtual void visit( ConstantExpr * old ) override final {
    2140                 ast::ConstantExpr *rslt = nullptr;
    2141                 if (isIntlikeConstantType(old->result)) {
    2142                         rslt = new ast::ConstantExpr(
    2143                                 old->location,
    2144                                 GET_ACCEPT_1(result, Type),
    2145                                 old->constant.get_value(),
    2146                                 (unsigned long long) old->intValue()
    2147                         );
    2148                 } else if (isFloatlikeConstantType(old->result)) {
    2149                         rslt = new ast::ConstantExpr(
    2150                                 old->location,
    2151                                 GET_ACCEPT_1(result, Type),
    2152                                 old->constant.get_value(),
    2153                                 (double) old->constant.get_dval()
    2154                         );
    2155                 } else if (isStringlikeConstantType(old->result)) {
    2156                         rslt = ast::ConstantExpr::from_string(
    2157                                 old->location,
    2158                                 old->constant.get_value()
    2159                         );
    2160                 }
    2161                 assert(rslt);
    2162                 this->node = visitBaseExpr( old, rslt );
    2163         }
    2164 
    2165         virtual void visit( SizeofExpr * old ) override final {
    2166                 assert (old->expr || old->type);
    2167                 assert (! (old->expr && old->type));
    2168                 ast::SizeofExpr *rslt;
    2169                 if (old->expr) {
    2170                         assert(!old->isType);
    2171                         rslt = new ast::SizeofExpr(
    2172                                 old->location,
    2173                                 GET_ACCEPT_1(expr, Expr)
    2174                         );
    2175                 }
    2176                 if (old->type) {
    2177                         assert(old->isType);
    2178                         rslt = new ast::SizeofExpr(
    2179                                 old->location,
    2180                                 GET_ACCEPT_1(type, Type)
    2181                         );
    2182                 }
    2183                 this->node = visitBaseExpr( old, rslt );
    2184         }
    2185 
    2186         virtual void visit( AlignofExpr * old ) override final {
    2187                 assert (old->expr || old->type);
    2188                 assert (! (old->expr && old->type));
    2189                 ast::AlignofExpr *rslt;
    2190                 if (old->expr) {
    2191                         assert(!old->isType);
    2192                         rslt = new ast::AlignofExpr(
    2193                                 old->location,
    2194                                 GET_ACCEPT_1(expr, Expr)
    2195                         );
    2196                 }
    2197                 if (old->type) {
    2198                         assert(old->isType);
    2199                         rslt = new ast::AlignofExpr(
    2200                                 old->location,
    2201                                 GET_ACCEPT_1(type, Type)
    2202                         );
    2203                 }
    2204                 this->node = visitBaseExpr( old, rslt );
    2205         }
    2206 
    2207         virtual void visit( UntypedOffsetofExpr * old ) override final {
    2208                 this->node = visitBaseExpr( old,
    2209                         new ast::UntypedOffsetofExpr(
    2210                                 old->location,
    2211                                 GET_ACCEPT_1(type, Type),
    2212                                 old->member
    2213                         )
    2214                 );
    2215         }
    2216 
    2217         virtual void visit( OffsetofExpr * old ) override final {
    2218                 this->node = visitBaseExpr( old,
    2219                         new ast::OffsetofExpr(
    2220                                 old->location,
    2221                                 GET_ACCEPT_1(type, Type),
    2222                                 inCache(old->member) ?
    2223                                         dynamic_cast<ast::DeclWithType *>(this->node) :
    2224                                         GET_ACCEPT_1(member, DeclWithType)
    2225                         )
    2226                 );
    2227         }
    2228 
    2229         virtual void visit( OffsetPackExpr * old ) override final {
    2230                 this->node = visitBaseExpr( old,
    2231                         new ast::OffsetPackExpr(
    2232                                 old->location,
    2233                                 GET_ACCEPT_1(type, StructInstType)
    2234                         )
    2235                 );
    2236         }
    2237 
    2238         virtual void visit( LogicalExpr * old ) override final {
    2239                 this->node = visitBaseExpr( old,
    2240                         new ast::LogicalExpr(
    2241                                 old->location,
    2242                                 GET_ACCEPT_1(arg1, Expr),
    2243                                 GET_ACCEPT_1(arg2, Expr),
    2244                                 old->get_isAnd() ?
    2245                                         ast::LogicalFlag::AndExpr :
    2246                                         ast::LogicalFlag::OrExpr
    2247                         )
    2248                 );
    2249         }
    2250 
    2251         virtual void visit( ConditionalExpr * old ) override final {
    2252                 this->node = visitBaseExpr( old,
    2253                         new ast::ConditionalExpr(
    2254                                 old->location,
    2255                                 GET_ACCEPT_1(arg1, Expr),
    2256                                 GET_ACCEPT_1(arg2, Expr),
    2257                                 GET_ACCEPT_1(arg3, Expr)
    2258                         )
    2259                 );
    2260         }
    2261 
    2262         virtual void visit( CommaExpr * old ) override final {
    2263                 this->node = visitBaseExpr( old,
    2264                         new ast::CommaExpr(
    2265                                 old->location,
    2266                                 GET_ACCEPT_1(arg1, Expr),
    2267                                 GET_ACCEPT_1(arg2, Expr)
    2268                         )
    2269                 );
    2270         }
    2271 
    2272         virtual void visit( TypeExpr * old ) override final {
    2273                 this->node = visitBaseExpr( old,
    2274                         new ast::TypeExpr(
    2275                                 old->location,
    2276                                 GET_ACCEPT_1(type, Type)
    2277                         )
    2278                 );
    2279         }
    2280 
    2281         virtual void visit( AsmExpr * old ) override final {
    2282                 this->node = visitBaseExpr( old,
    2283                         new ast::AsmExpr(
    2284                                 old->location,
    2285                                 GET_ACCEPT_1(inout, Expr),
    2286                                 GET_ACCEPT_1(constraint, Expr),
    2287                                 GET_ACCEPT_1(operand, Expr)
    2288                         )
    2289                 );
    2290         }
    2291 
    2292         virtual void visit( ImplicitCopyCtorExpr * old ) override final {
    2293                 auto rslt = new ast::ImplicitCopyCtorExpr(
    2294                         old->location,
    2295                         GET_ACCEPT_1(callExpr, ApplicationExpr)
    2296                 );
    2297 
    2298                 rslt->tempDecls = GET_ACCEPT_V(tempDecls, ObjectDecl);
    2299                 rslt->returnDecls = GET_ACCEPT_V(returnDecls, ObjectDecl);
    2300                 rslt->dtors = GET_ACCEPT_V(dtors, Expr);
    2301 
    2302                 this->node = visitBaseExpr( old, rslt );
    2303         }
    2304 
    2305         virtual void visit( ConstructorExpr * old ) override final {
    2306                 this->node = visitBaseExpr( old,
    2307                         new ast::ConstructorExpr(
    2308                                 old->location,
    2309                                 GET_ACCEPT_1(callExpr, Expr)
    2310                         )
    2311                 );
    2312         }
    2313 
    2314         virtual void visit( CompoundLiteralExpr * old ) override final {
    2315                 this->node = visitBaseExpr_SkipResultType( old,
    2316                         new ast::CompoundLiteralExpr(
    2317                                 old->location,
    2318                                 GET_ACCEPT_1(result, Type),
    2319                                 GET_ACCEPT_1(initializer, Init)
    2320                         )
    2321                 );
    2322         }
    2323 
    2324         virtual void visit( RangeExpr * old ) override final {
    2325                 this->node = visitBaseExpr( old,
    2326                         new ast::RangeExpr(
    2327                                 old->location,
    2328                                 GET_ACCEPT_1(low, Expr),
    2329                                 GET_ACCEPT_1(high, Expr)
    2330                         )
    2331                 );
    2332         }
    2333 
    2334         virtual void visit( UntypedTupleExpr * old ) override final {
    2335                 this->node = visitBaseExpr( old,
    2336                         new ast::UntypedTupleExpr(
    2337                                 old->location,
    2338                                 GET_ACCEPT_V(exprs, Expr)
    2339                         )
    2340                 );
    2341         }
    2342 
    2343         virtual void visit( TupleExpr * old ) override final {
    2344                 this->node = visitBaseExpr( old,
    2345                         new ast::TupleExpr(
    2346                                 old->location,
    2347                                 GET_ACCEPT_V(exprs, Expr)
    2348                         )
    2349                 );
    2350         }
    2351 
    2352         virtual void visit( TupleIndexExpr * old ) override final {
    2353                 this->node = visitBaseExpr( old,
    2354                         new ast::TupleIndexExpr(
    2355                                 old->location,
    2356                                 GET_ACCEPT_1(tuple, Expr),
    2357                                 old->index
    2358                         )
    2359                 );
    2360         }
    2361 
    2362         virtual void visit( TupleAssignExpr * old ) override final {
    2363                 this->node = visitBaseExpr_SkipResultType( old,
    2364                         new ast::TupleAssignExpr(
    2365                                 old->location,
    2366                                 GET_ACCEPT_1(result, Type),
    2367                                 GET_ACCEPT_1(stmtExpr, StmtExpr)
    2368                         )
    2369                 );
    2370         }
    2371 
    2372         virtual void visit( StmtExpr * old ) override final {
    2373                 auto rslt = new ast::StmtExpr(
    2374                         old->location,
    2375                         GET_ACCEPT_1(statements, CompoundStmt)
    2376                 );
    2377                 rslt->returnDecls = GET_ACCEPT_V(returnDecls, ObjectDecl);
    2378                 rslt->dtors       = GET_ACCEPT_V(dtors      , Expr);
    2379 
    2380                 this->node = visitBaseExpr_SkipResultType( old, rslt );
    2381         }
    2382 
    2383         virtual void visit( UniqueExpr * old ) override final {
    2384                 auto rslt = new ast::UniqueExpr(
    2385                         old->location,
    2386                         GET_ACCEPT_1(expr, Expr)
    2387                 );
    2388                 rslt->object = GET_ACCEPT_1(object, ObjectDecl);
    2389                 rslt->var    = GET_ACCEPT_1(var   , VariableExpr);
    2390 
    2391                 this->node = visitBaseExpr( old, rslt );
    2392         }
    2393 
    2394         virtual void visit( UntypedInitExpr * old ) override final {
    2395                 std::vector<ast::InitAlternative> initAlts;
    2396                 for (auto ia : old->initAlts) {
    2397                         initAlts.push_back(ast::InitAlternative(
    2398                                 getAccept1< ast::Type, Type * >( ia.type ),
    2399                                 getAccept1< ast::Designation, Designation * >( ia.designation )
    2400                         ));
    2401                 }
    2402                 this->node = visitBaseExpr( old,
    2403                         new ast::UntypedInitExpr(
    2404                                 old->location,
    2405                                 GET_ACCEPT_1(expr, Expr),
    2406                                 std::move(initAlts)
    2407                         )
    2408                 );
    2409         }
    2410 
    2411         virtual void visit( InitExpr * old ) override final {
    2412                 this->node = visitBaseExpr( old,
    2413                         new ast::InitExpr(
    2414                                 old->location,
    2415                                 GET_ACCEPT_1(expr, Expr),
    2416                                 GET_ACCEPT_1(designation, Designation)
    2417                         )
    2418                 );
    2419         }
    2420 
    2421         virtual void visit( DeletedExpr * old ) override final {
    2422                 this->node = visitBaseExpr( old,
    2423                         new ast::DeletedExpr(
    2424                                 old->location,
    2425                                 GET_ACCEPT_1(expr, Expr),
    2426                                 inCache(old->deleteStmt) ?
    2427                                         this->node :
    2428                                         GET_ACCEPT_1(deleteStmt, Node)
    2429                         )
    2430                 );
    2431         }
    2432 
    2433         virtual void visit( DefaultArgExpr * old ) override final {
    2434                 this->node = visitBaseExpr( old,
    2435                         new ast::DefaultArgExpr(
    2436                                 old->location,
    2437                                 GET_ACCEPT_1(expr, Expr)
    2438                         )
    2439                 );
    2440         }
    2441 
    2442         virtual void visit( GenericExpr * old ) override final {
    2443                 std::vector<ast::GenericExpr::Association> associations;
    2444                 for (auto association : old->associations) {
    2445                         associations.push_back(ast::GenericExpr::Association(
    2446                                 getAccept1< ast::Type, Type * >( association.type ),
    2447                                 getAccept1< ast::Expr, Expression * >( association.expr )
    2448                         ));
    2449                 }
    2450                 this->node = visitBaseExpr( old,
    2451                         new ast::GenericExpr(
    2452                                 old->location,
    2453                                 GET_ACCEPT_1(control, Expr),
    2454                                 std::move(associations)
    2455                         )
    2456                 );
    2457         }
    2458 
    2459         virtual void visit( VoidType * old ) override final {
    2460                 this->node = new ast::VoidType{ cv( old ) };
    2461         }
    2462 
    2463         virtual void visit( BasicType * old ) override final {
    2464                 this->node = new ast::BasicType{ (ast::BasicType::Kind)(unsigned)old->kind, cv( old ) };
    2465         }
    2466 
    2467         virtual void visit( PointerType * old ) override final {
    2468                 this->node = new ast::PointerType{
    2469                         GET_ACCEPT_1( base, Type ),
    2470                         GET_ACCEPT_1( dimension, Expr ),
    2471                         (ast::LengthFlag)old->isVarLen,
    2472                         (ast::DimensionFlag)old->isStatic,
    2473                         cv( old )
    2474                 };
    2475         }
    2476 
    2477         virtual void visit( ArrayType * old ) override final {
    2478                 this->node = new ast::ArrayType{
    2479                         GET_ACCEPT_1( base, Type ),
    2480                         GET_ACCEPT_1( dimension, Expr ),
    2481                         (ast::LengthFlag)old->isVarLen,
    2482                         (ast::DimensionFlag)old->isStatic,
    2483                         cv( old )
    2484                 };
    2485         }
    2486 
    2487         virtual void visit( ReferenceType * old ) override final {
    2488                 this->node = new ast::ReferenceType{
    2489                         GET_ACCEPT_1( base, Type ),
    2490                         cv( old )
    2491                 };
    2492         }
    2493 
    2494         virtual void visit( QualifiedType * old ) override final {
    2495                 this->node = new ast::QualifiedType{
    2496                         GET_ACCEPT_1( parent, Type ),
    2497                         GET_ACCEPT_1( child, Type ),
    2498                         cv( old )
    2499                 };
    2500         }
    2501 
    2502         virtual void visit( FunctionType * old ) override final {
    2503                 auto ty = new ast::FunctionType {
    2504                         (ast::ArgumentFlag)old->isVarArgs,
    2505                         cv( old )
    2506                 };
    2507                 ty->returns = GET_ACCEPT_V( returnVals, DeclWithType );
    2508                 ty->params = GET_ACCEPT_V( parameters, DeclWithType );
    2509                 ty->forall = GET_ACCEPT_V( forall, TypeDecl );
    2510                 this->node = ty;
    2511         }
    2512 
    2513         void postvisit( ReferenceToType * old, ast::ReferenceToType * ty ) {
    2514                 ty->forall = GET_ACCEPT_V( forall, TypeDecl );
    2515                 ty->params = GET_ACCEPT_V( parameters, Expr );
    2516                 ty->hoistType = old->hoistType;
    2517         }
    2518 
    2519         virtual void visit( StructInstType * old ) override final {
    2520                 ast::StructInstType * ty;
    2521                 if ( old->baseStruct ) {
    2522                         ty = new ast::StructInstType{
    2523                                 GET_ACCEPT_1( baseStruct, StructDecl ),
    2524                                 cv( old ),
    2525                                 GET_ACCEPT_V( attributes, Attribute )
    2526                         };
    2527                 } else {
    2528                         ty = new ast::StructInstType{
    2529                                 old->name,
    2530                                 cv( old ),
    2531                                 GET_ACCEPT_V( attributes, Attribute )
    2532                         };
    2533                 }
    2534                 postvisit( old, ty );
    2535                 this->node = ty;
    2536         }
    2537 
    2538         virtual void visit( UnionInstType * old ) override final {
    2539                 ast::UnionInstType * ty;
    2540                 if ( old->baseUnion ) {
    2541                         ty = new ast::UnionInstType{
    2542                                 GET_ACCEPT_1( baseUnion, UnionDecl ),
    2543                                 cv( old ),
    2544                                 GET_ACCEPT_V( attributes, Attribute )
    2545                         };
    2546                 } else {
    2547                         ty = new ast::UnionInstType{
    2548                                 old->name,
    2549                                 cv( old ),
    2550                                 GET_ACCEPT_V( attributes, Attribute )
    2551                         };
    2552                 }
    2553                 postvisit( old, ty );
    2554                 this->node = ty;
    2555         }
    2556 
    2557         virtual void visit( EnumInstType * old ) override final {
    2558                 ast::EnumInstType * ty;
    2559                 if ( old->baseEnum ) {
    2560                         ty = new ast::EnumInstType{
    2561                                 GET_ACCEPT_1( baseEnum, EnumDecl ),
    2562                                 cv( old ),
    2563                                 GET_ACCEPT_V( attributes, Attribute )
    2564                         };
    2565                 } else {
    2566                         ty = new ast::EnumInstType{
    2567                                 old->name,
    2568                                 cv( old ),
    2569                                 GET_ACCEPT_V( attributes, Attribute )
    2570                         };
    2571                 }
    2572                 postvisit( old, ty );
    2573                 this->node = ty;
    2574         }
    2575 
    2576         virtual void visit( TraitInstType * old ) override final {
    2577                 ast::TraitInstType * ty;
    2578                 if ( old->baseTrait ) {
    2579                         ty = new ast::TraitInstType{
    2580                                 GET_ACCEPT_1( baseTrait, TraitDecl ),
    2581                                 cv( old ),
    2582                                 GET_ACCEPT_V( attributes, Attribute )
    2583                         };
    2584                 } else {
    2585                         ty = new ast::TraitInstType{
    2586                                 old->name,
    2587                                 cv( old ),
    2588                                 GET_ACCEPT_V( attributes, Attribute )
    2589                         };
    2590                 }
    2591                 postvisit( old, ty );
    2592                 this->node = ty;
    2593         }
    2594 
    2595         virtual void visit( TypeInstType * old ) override final {
    2596                 ast::TypeInstType * ty;
    2597                 if ( old->baseType ) {
    2598                         ty = new ast::TypeInstType{
    2599                                 old->name,
    2600                                 GET_ACCEPT_1( baseType, TypeDecl ),
    2601                                 cv( old ),
    2602                                 GET_ACCEPT_V( attributes, Attribute )
    2603                         };
    2604                 } else {
    2605                         ty = new ast::TypeInstType{
    2606                                 old->name,
    2607                                 old->isFtype ? ast::TypeVar::Ftype : ast::TypeVar::Dtype,
    2608                                 cv( old ),
    2609                                 GET_ACCEPT_V( attributes, Attribute )
    2610                         };
    2611                 }
    2612                 postvisit( old, ty );
    2613                 this->node = ty;
    2614         }
    2615 
    2616         virtual void visit( TupleType * old ) override final {
    2617                 this->node = new ast::TupleType{
    2618                         GET_ACCEPT_V( types, Type ),
    2619                         // members generated by TupleType c'tor
    2620                         cv( old )
    2621                 };
    2622         }
    2623 
    2624         virtual void visit( TypeofType * old ) override final {
    2625                 this->node = new ast::TypeofType{
    2626                         GET_ACCEPT_1( expr, Expr ),
    2627                         (ast::TypeofType::Kind)old->is_basetypeof,
    2628                         cv( old )
    2629                 };
     1167                this->node = new ast::ImplicitCtorDtorStmt(
     1168                        old->location,
     1169                        GET_ACCEPT_1(callStmt, Stmt),
     1170                        GET_LABELS_V(old->labels)
     1171                );
     1172        }
     1173
     1174        virtual void visit( ApplicationExpr * ) override final {
     1175
     1176        }
     1177
     1178        virtual void visit( UntypedExpr * ) override final {
     1179
     1180        }
     1181
     1182        virtual void visit( NameExpr * ) override final {
     1183
     1184        }
     1185
     1186        virtual void visit( CastExpr * ) override final {
     1187
     1188        }
     1189
     1190        virtual void visit( KeywordCastExpr * ) override final {
     1191
     1192        }
     1193
     1194        virtual void visit( VirtualCastExpr * ) override final {
     1195
     1196        }
     1197
     1198        virtual void visit( AddressExpr * ) override final {
     1199
     1200        }
     1201
     1202        virtual void visit( LabelAddressExpr * ) override final {
     1203
     1204        }
     1205
     1206        virtual void visit( UntypedMemberExpr * ) override final {
     1207
     1208        }
     1209
     1210        virtual void visit( MemberExpr * ) override final {
     1211
     1212        }
     1213
     1214        virtual void visit( VariableExpr * ) override final {
     1215
     1216        }
     1217
     1218        virtual void visit( ConstantExpr * ) override final {
     1219
     1220        }
     1221
     1222        virtual void visit( SizeofExpr * ) override final {
     1223
     1224        }
     1225
     1226        virtual void visit( AlignofExpr * ) override final {
     1227
     1228        }
     1229
     1230        virtual void visit( UntypedOffsetofExpr * ) override final {
     1231
     1232        }
     1233
     1234        virtual void visit( OffsetofExpr * ) override final {
     1235
     1236        }
     1237
     1238        virtual void visit( OffsetPackExpr * ) override final {
     1239
     1240        }
     1241
     1242        virtual void visit( LogicalExpr * ) override final {
     1243
     1244        }
     1245
     1246        virtual void visit( ConditionalExpr * ) override final {
     1247
     1248        }
     1249
     1250        virtual void visit( CommaExpr * ) override final {
     1251
     1252        }
     1253
     1254        virtual void visit( TypeExpr * ) override final {
     1255
     1256        }
     1257
     1258        virtual void visit( AsmExpr * ) override final {
     1259
     1260        }
     1261
     1262        virtual void visit( ImplicitCopyCtorExpr * ) override final {
     1263
     1264        }
     1265
     1266        virtual void visit( ConstructorExpr *  ) override final {
     1267
     1268        }
     1269
     1270        virtual void visit( CompoundLiteralExpr * ) override final {
     1271
     1272        }
     1273
     1274        virtual void visit( RangeExpr * ) override final {
     1275
     1276        }
     1277
     1278        virtual void visit( UntypedTupleExpr * ) override final {
     1279
     1280        }
     1281
     1282        virtual void visit( TupleExpr * ) override final {
     1283
     1284        }
     1285
     1286        virtual void visit( TupleIndexExpr * ) override final {
     1287
     1288        }
     1289
     1290        virtual void visit( TupleAssignExpr * ) override final {
     1291
     1292        }
     1293
     1294        virtual void visit( StmtExpr *  ) override final {
     1295
     1296        }
     1297
     1298        virtual void visit( UniqueExpr *  ) override final {
     1299
     1300        }
     1301
     1302        virtual void visit( UntypedInitExpr *  ) override final {
     1303
     1304        }
     1305
     1306        virtual void visit( InitExpr *  ) override final {
     1307
     1308        }
     1309
     1310        virtual void visit( DeletedExpr * ) override final {
     1311
     1312        }
     1313
     1314        virtual void visit( DefaultArgExpr * ) override final {
     1315
     1316        }
     1317
     1318        virtual void visit( GenericExpr * ) override final {
     1319
     1320        }
     1321
     1322        virtual void visit( VoidType * ) override final {
     1323
     1324        }
     1325
     1326        virtual void visit( BasicType * ) override final {
     1327
     1328        }
     1329
     1330        virtual void visit( PointerType * ) override final {
     1331
     1332        }
     1333
     1334        virtual void visit( ArrayType * ) override final {
     1335
     1336        }
     1337
     1338        virtual void visit( ReferenceType * ) override final {
     1339
     1340        }
     1341
     1342        virtual void visit( QualifiedType * ) override final {
     1343
     1344        }
     1345
     1346        virtual void visit( FunctionType * ) override final {
     1347
     1348        }
     1349
     1350        virtual void visit( StructInstType * ) override final {
     1351
     1352        }
     1353
     1354        virtual void visit( UnionInstType * ) override final {
     1355
     1356        }
     1357
     1358        virtual void visit( EnumInstType * ) override final {
     1359
     1360        }
     1361
     1362        virtual void visit( TraitInstType * ) override final {
     1363
     1364        }
     1365
     1366        virtual void visit( TypeInstType * ) override final {
     1367
     1368        }
     1369
     1370        virtual void visit( TupleType * ) override final {
     1371
     1372        }
     1373
     1374        virtual void visit( TypeofType * ) override final {
     1375
    26301376        }
    26311377
    26321378        virtual void visit( AttrType * ) override final {
    2633                 assertf( false, "AttrType deprecated in new AST." );
    2634         }
    2635 
    2636         virtual void visit( VarArgsType * old ) override final {
    2637                 this->node = new ast::VarArgsType{ cv( old ) };
    2638         }
    2639 
    2640         virtual void visit( ZeroType * old ) override final {
    2641                 this->node = new ast::ZeroType{ cv( old ) };
    2642         }
    2643 
    2644         virtual void visit( OneType * old ) override final {
    2645                 this->node = new ast::OneType{ cv( old ) };
     1379
     1380        }
     1381
     1382        virtual void visit( VarArgsType * ) override final {
     1383
     1384        }
     1385
     1386        virtual void visit( ZeroType * ) override final {
     1387
     1388        }
     1389
     1390        virtual void visit( OneType * ) override final {
     1391
    26461392        }
    26471393
    26481394        virtual void visit( GlobalScopeType * ) override final {
    2649                 this->node = new ast::GlobalScopeType{};
    2650         }
    2651 
    2652         virtual void visit( Designation * old ) override final {
    2653                 this->node = new ast::Designation(
    2654                         old->location,
    2655                         GET_ACCEPT_V(designators, Expr)
    2656                 );
    2657         }
    2658 
    2659         virtual void visit( SingleInit * old ) override final {
    2660                 this->node = new ast::SingleInit(
    2661                         old->location,
    2662                         GET_ACCEPT_1(value, Expr),
    2663                         (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast::DoConstruct
    2664                 );
    2665         }
    2666 
    2667         virtual void visit( ListInit * old ) override final {
    2668                 this->node = new ast::ListInit(
    2669                         old->location,
    2670                         GET_ACCEPT_V(initializers, Init),
    2671                         GET_ACCEPT_V(designations, Designation),
    2672                         (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast::DoConstruct
    2673                 );
    2674         }
    2675 
    2676         virtual void visit( ConstructorInit * old ) override final {
    2677                 this->node = new ast::ConstructorInit(
    2678                         old->location,
    2679                         GET_ACCEPT_1(ctor, Stmt),
    2680                         GET_ACCEPT_1(dtor, Stmt),
    2681                         GET_ACCEPT_1(init, Init)
    2682                 );
     1395
     1396        }
     1397
     1398        virtual void visit( Designation * ) override final {
     1399
     1400        }
     1401
     1402        virtual void visit( SingleInit * ) override final {
     1403
     1404        }
     1405
     1406        virtual void visit( ListInit * ) override final {
     1407
     1408        }
     1409
     1410        virtual void visit( ConstructorInit * ) override final {
     1411
    26831412        }
    26841413
    26851414        virtual void visit( Constant * ) override final {
    2686                 // Handled in visit( ConstantEpxr * ).
    2687                 // In the new tree, Constant fields are inlined into containing ConstantExpression.
     1415
     1416        }
     1417
     1418        virtual void visit( Attribute * ) override final {
     1419
     1420        }
     1421
     1422        virtual void visit( AttrExpr * ) override final {
     1423
    26881424                assert( 0 );
    2689         }
    2690 
    2691         virtual void visit( Attribute * old ) override final {
    2692                 this->node = new ast::Attribute(
    2693                         old->name,
    2694                         GET_ACCEPT_V( parameters, Expr )
    2695                 );
    2696         }
    2697 
    2698         virtual void visit( AttrExpr * ) override final {
    2699                 assertf( false, "AttrExpr deprecated in new AST." );
    27001425        }
    27011426};
     
    27111436                d->accept( c );
    27121437                decls.emplace_back( c.decl() );
    2713         }
    2714         deleteAll(translationUnit);
     1438                delete d;
     1439        }
    27151440        return decls;
    27161441}
Note: See TracChangeset for help on using the changeset viewer.