Changeset f53acdf8 for src/AST


Ignore:
Timestamp:
Jul 19, 2019, 2:16:01 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4eb43fa
Parents:
1f1c102 (diff), 8ac3b0e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into new-ast

Location:
src/AST
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r1f1c102 rf53acdf8  
    518518        }
    519519
    520         const ast::Stmt * visit( const ast::WithStmt * node ) override final {
     520        const ast::Decl * visit( const ast::WithStmt * node ) override final {
    521521                if ( inCache( node ) ) return nullptr;
    522522                auto stmt = new WithStmt(
     
    524524                        get<Statement>().accept1( node->stmt )
    525525                );
    526                 return stmtPostamble( stmt, node );
     526                declPostamble( stmt, node );
     527                return nullptr;
    527528        }
    528529
     
    10391040                                get<Expression>().accept1(node->expr),
    10401041                                inCache(node->deleteStmt) ?
    1041                                         this->node :
    1042                                         get<BaseSyntaxNode>().accept1(node->deleteStmt)
     1042                                        strict_dynamic_cast<Declaration*>(this->node) :
     1043                                        get<Declaration>().accept1(node->deleteStmt)
    10431044                        )
    10441045                );
     
    13551356        ast::Node * node = nullptr;
    13561357        /// cache of nodes that might be referenced by readonly<> for de-duplication
    1357         std::unordered_map< BaseSyntaxNode *, ast::Node * > cache = {};
     1358        std::unordered_map< const BaseSyntaxNode *, ast::Node * > cache = {};
    13581359
    13591360        // Local Utilities:
     
    14221423                to<std::vector>::from( make_labels( std::move( labels ) ) )
    14231424
    1424         static ast::CV::Qualifiers cv( Type * ty ) { return { ty->get_qualifiers().val }; }
     1425        static ast::CV::Qualifiers cv( const Type * ty ) { return { ty->tq.val }; }
    14251426
    14261427        /// returns true and sets `node` if in cache
    1427         bool inCache( BaseSyntaxNode * old ) {
     1428        bool inCache( const BaseSyntaxNode * old ) {
    14281429                auto it = cache.find( old );
    14291430                if ( it == cache.end() ) return false;
     
    14341435        // Now all the visit functions:
    14351436
    1436         virtual void visit( ObjectDecl * old ) override final {
     1437        virtual void visit( const ObjectDecl * old ) override final {
    14371438                auto&& type = GET_ACCEPT_1(type, Type);
    14381439                auto&& init = GET_ACCEPT_1(init, Init);
     
    14651466        }
    14661467
    1467         virtual void visit( FunctionDecl * old ) override final {
     1468        virtual void visit( const FunctionDecl * old ) override final {
    14681469                if ( inCache( old ) ) return;
    14691470                auto decl = new ast::FunctionDecl{
     
    14981499        }
    14991500
    1500         virtual void visit( StructDecl * old ) override final {
     1501        virtual void visit( const StructDecl * old ) override final {
    15011502                if ( inCache( old ) ) return;
    15021503                auto decl = new ast::StructDecl(
     
    15231524        }
    15241525
    1525         virtual void visit( UnionDecl * old ) override final {
     1526        virtual void visit( const UnionDecl * old ) override final {
    15261527                if ( inCache( old ) ) return;
    15271528                auto decl = new ast::UnionDecl(
     
    15431544        }
    15441545
    1545         virtual void visit( EnumDecl * old ) override final {
     1546        virtual void visit( const EnumDecl * old ) override final {
    15461547                if ( inCache( old ) ) return;
    15471548                auto decl = new ast::EnumDecl(
     
    15631564        }
    15641565
    1565         virtual void visit( TraitDecl * old ) override final {
     1566        virtual void visit( const TraitDecl * old ) override final {
    15661567                if ( inCache( old ) ) return;
    15671568                auto decl = new ast::TraitDecl(
     
    15831584        }
    15841585
    1585         virtual void visit( TypeDecl * old ) override final {
     1586        virtual void visit( const TypeDecl * old ) override final {
    15861587                if ( inCache( old ) ) return;
    15871588                auto decl = new ast::TypeDecl{
     
    16031604        }
    16041605
    1605         virtual void visit( TypedefDecl * old ) override final {
     1606        virtual void visit( const TypedefDecl * old ) override final {
    16061607                auto decl = new ast::TypedefDecl(
    16071608                        old->location,
     
    16201621        }
    16211622
    1622         virtual void visit( AsmDecl * old ) override final {
     1623        virtual void visit( const AsmDecl * old ) override final {
    16231624                auto decl = new ast::AsmDecl{
    16241625                        old->location,
     
    16321633        }
    16331634
    1634         virtual void visit( StaticAssertDecl * old ) override final {
     1635        virtual void visit( const StaticAssertDecl * old ) override final {
    16351636                auto decl = new ast::StaticAssertDecl{
    16361637                        old->location,
     
    16451646        }
    16461647
    1647         virtual void visit( CompoundStmt * old ) override final {
     1648        virtual void visit( const CompoundStmt * old ) override final {
    16481649                if ( inCache( old ) ) return;
    16491650                auto stmt = new ast::CompoundStmt(
     
    16571658        }
    16581659
    1659         virtual void visit( ExprStmt * old ) override final {
     1660        virtual void visit( const ExprStmt * old ) override final {
    16601661                if ( inCache( old ) ) return;
    16611662                this->node = new ast::ExprStmt(
     
    16671668        }
    16681669
    1669         virtual void visit( AsmStmt * old ) override final {
     1670        virtual void visit( const AsmStmt * old ) override final {
    16701671                if ( inCache( old ) ) return;
    16711672                this->node = new ast::AsmStmt(
     
    16821683        }
    16831684
    1684         virtual void visit( DirectiveStmt * old ) override final {
     1685        virtual void visit( const DirectiveStmt * old ) override final {
    16851686                if ( inCache( old ) ) return;
    16861687                this->node = new ast::DirectiveStmt(
     
    16921693        }
    16931694
    1694         virtual void visit( IfStmt * old ) override final {
     1695        virtual void visit( const IfStmt * old ) override final {
    16951696                if ( inCache( old ) ) return;
    16961697                this->node = new ast::IfStmt(
     
    17051706        }
    17061707
    1707         virtual void visit( SwitchStmt * old ) override final {
     1708        virtual void visit( const SwitchStmt * old ) override final {
    17081709                if ( inCache( old ) ) return;
    17091710                this->node = new ast::SwitchStmt(
     
    17161717        }
    17171718
    1718         virtual void visit( CaseStmt * old ) override final {
     1719        virtual void visit( const CaseStmt * old ) override final {
    17191720                if ( inCache( old ) ) return;
    17201721                this->node = new ast::CaseStmt(
     
    17271728        }
    17281729
    1729         virtual void visit( WhileStmt * old ) override final {
     1730        virtual void visit( const WhileStmt * old ) override final {
    17301731                if ( inCache( old ) ) return;
    17311732                this->node = new ast::WhileStmt(
     
    17401741        }
    17411742
    1742         virtual void visit( ForStmt * old ) override final {
     1743        virtual void visit( const ForStmt * old ) override final {
    17431744                if ( inCache( old ) ) return;
    17441745                this->node = new ast::ForStmt(
     
    17531754        }
    17541755
    1755         virtual void visit( BranchStmt * old ) override final {
     1756        virtual void visit( const BranchStmt * old ) override final {
    17561757                if ( inCache( old ) ) return;
    17571758                if (old->computedTarget) {
     
    17901791        }
    17911792
    1792         virtual void visit( ReturnStmt * old ) override final {
     1793        virtual void visit( const ReturnStmt * old ) override final {
    17931794                if ( inCache( old ) ) return;
    17941795                this->node = new ast::ReturnStmt(
     
    18001801        }
    18011802
    1802         virtual void visit( ThrowStmt * old ) override final {
     1803        virtual void visit( const ThrowStmt * old ) override final {
    18031804                if ( inCache( old ) ) return;
    18041805                ast::ExceptionKind kind;
     
    18241825        }
    18251826
    1826         virtual void visit( TryStmt * old ) override final {
     1827        virtual void visit( const TryStmt * old ) override final {
    18271828                if ( inCache( old ) ) return;
    18281829                this->node = new ast::TryStmt(
     
    18361837        }
    18371838
    1838         virtual void visit( CatchStmt * old ) override final {
     1839        virtual void visit( const CatchStmt * old ) override final {
    18391840                if ( inCache( old ) ) return;
    18401841                ast::ExceptionKind kind;
     
    18611862        }
    18621863
    1863         virtual void visit( FinallyStmt * old ) override final {
     1864        virtual void visit( const FinallyStmt * old ) override final {
    18641865                if ( inCache( old ) ) return;
    18651866                this->node = new ast::FinallyStmt(
     
    18711872        }
    18721873
    1873         virtual void visit( WaitForStmt * old ) override final {
     1874        virtual void visit( const WaitForStmt * old ) override final {
    18741875                if ( inCache( old ) ) return;
    18751876                ast::WaitForStmt * stmt = new ast::WaitForStmt(
     
    19031904        }
    19041905
    1905         virtual void visit( WithStmt * old ) override final {
     1906        virtual void visit( const WithStmt * old ) override final {
    19061907                if ( inCache( old ) ) return;
    19071908                this->node = new ast::WithStmt(
    19081909                        old->location,
    19091910                        GET_ACCEPT_V(exprs, Expr),
    1910                         GET_ACCEPT_1(stmt, Stmt),
    1911                         GET_LABELS_V(old->labels)
     1911                        GET_ACCEPT_1(stmt, Stmt)
    19121912                );
    19131913                cache.emplace( old, this->node );
    19141914        }
    19151915
    1916         virtual void visit( NullStmt * old ) override final {
     1916        virtual void visit( const NullStmt * old ) override final {
    19171917                if ( inCache( old ) ) return;
    19181918                this->node = new ast::NullStmt(
     
    19231923        }
    19241924
    1925         virtual void visit( DeclStmt * old ) override final {
     1925        virtual void visit( const DeclStmt * old ) override final {
    19261926                if ( inCache( old ) ) return;
    19271927                this->node = new ast::DeclStmt(
     
    19331933        }
    19341934
    1935         virtual void visit( ImplicitCtorDtorStmt * old ) override final {
     1935        virtual void visit( const ImplicitCtorDtorStmt * old ) override final {
    19361936                if ( inCache( old ) ) return;
    19371937                auto stmt = new ast::ImplicitCtorDtorStmt(
     
    19901990        }
    19911991
    1992         ast::Expr * visitBaseExpr_SkipResultType(Expression * old, ast::Expr * nw) {
     1992        ast::Expr * visitBaseExpr_SkipResultType( const Expression * old, ast::Expr * nw) {
    19931993
    19941994                nw->env    = convertTypeSubstitution(old->env);
     
    20002000        }
    20012001
    2002         ast::Expr * visitBaseExpr(Expression * old, ast::Expr * nw) {
     2002        ast::Expr * visitBaseExpr( const Expression * old, ast::Expr * nw) {
    20032003
    20042004                nw->result = GET_ACCEPT_1(result, Type);
     
    20062006        }
    20072007
    2008         virtual void visit( ApplicationExpr * old ) override final {
     2008        virtual void visit( const ApplicationExpr * old ) override final {
    20092009                this->node = visitBaseExpr( old,
    20102010                        new ast::ApplicationExpr(
     
    20162016        }
    20172017
    2018         virtual void visit( UntypedExpr * old ) override final {
     2018        virtual void visit( const UntypedExpr * old ) override final {
    20192019                this->node = visitBaseExpr( old,
    20202020                        new ast::UntypedExpr(
     
    20262026        }
    20272027
    2028         virtual void visit( NameExpr * old ) override final {
     2028        virtual void visit( const NameExpr * old ) override final {
    20292029                this->node = visitBaseExpr( old,
    20302030                        new ast::NameExpr(
     
    20352035        }
    20362036
    2037         virtual void visit( CastExpr * old ) override final {
     2037        virtual void visit( const CastExpr * old ) override final {
    20382038                this->node = visitBaseExpr( old,
    20392039                        new ast::CastExpr(
     
    20452045        }
    20462046
    2047         virtual void visit( KeywordCastExpr * old) override final {
     2047        virtual void visit( const KeywordCastExpr * old) override final {
    20482048                ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS;
    20492049                switch (old->target) {
     
    20702070        }
    20712071
    2072         virtual void visit( VirtualCastExpr * old ) override final {
     2072        virtual void visit( const VirtualCastExpr * old ) override final {
    20732073                this->node = visitBaseExpr_SkipResultType( old,
    20742074                        new ast::VirtualCastExpr(
     
    20802080        }
    20812081
    2082         virtual void visit( AddressExpr * old ) override final {
     2082        virtual void visit( const AddressExpr * old ) override final {
    20832083                this->node = visitBaseExpr( old,
    20842084                        new ast::AddressExpr(
     
    20892089        }
    20902090
    2091         virtual void visit( LabelAddressExpr * old ) override final {
     2091        virtual void visit( const LabelAddressExpr * old ) override final {
    20922092                this->node = visitBaseExpr( old,
    20932093                        new ast::LabelAddressExpr(
     
    20982098        }
    20992099
    2100         virtual void visit( UntypedMemberExpr * old ) override final {
     2100        virtual void visit( const UntypedMemberExpr * old ) override final {
    21012101                this->node = visitBaseExpr( old,
    21022102                        new ast::UntypedMemberExpr(
     
    21082108        }
    21092109
    2110         virtual void visit( MemberExpr * old ) override final {
     2110        virtual void visit( const MemberExpr * old ) override final {
    21112111                this->node = visitBaseExpr( old,
    21122112                        new ast::MemberExpr(
     
    21182118        }
    21192119
    2120         virtual void visit( VariableExpr * old ) override final {
     2120        virtual void visit( const VariableExpr * old ) override final {
    21212121                auto expr = new ast::VariableExpr(
    21222122                        old->location
     
    21292129        }
    21302130
    2131         virtual void visit( ConstantExpr * old ) override final {
     2131        virtual void visit( const ConstantExpr * old ) override final {
    21322132                ast::ConstantExpr *rslt = new ast::ConstantExpr(
    21332133                        old->location,
    21342134                        GET_ACCEPT_1(result, Type),
    2135                         old->constant.get_value(),
     2135                        old->constant.rep,
    21362136                        old->constant.ival
    21372137                );
    2138                 rslt->underlyer = getAccept1< ast::Type, Type* >( old->constant.get_type() );
     2138                rslt->underlyer = getAccept1< ast::Type, Type* >( old->constant.type );
    21392139                this->node = visitBaseExpr( old, rslt );
    21402140        }
    21412141
    2142         virtual void visit( SizeofExpr * old ) override final {
     2142        virtual void visit( const SizeofExpr * old ) override final {
    21432143                assert (old->expr || old->type);
    21442144                assert (! (old->expr && old->type));
     
    21612161        }
    21622162
    2163         virtual void visit( AlignofExpr * old ) override final {
     2163        virtual void visit( const AlignofExpr * old ) override final {
    21642164                assert (old->expr || old->type);
    21652165                assert (! (old->expr && old->type));
     
    21822182        }
    21832183
    2184         virtual void visit( UntypedOffsetofExpr * old ) override final {
     2184        virtual void visit( const UntypedOffsetofExpr * old ) override final {
    21852185                this->node = visitBaseExpr( old,
    21862186                        new ast::UntypedOffsetofExpr(
     
    21922192        }
    21932193
    2194         virtual void visit( OffsetofExpr * old ) override final {
     2194        virtual void visit( const OffsetofExpr * old ) override final {
    21952195                this->node = visitBaseExpr( old,
    21962196                        new ast::OffsetofExpr(
     
    22022202        }
    22032203
    2204         virtual void visit( OffsetPackExpr * old ) override final {
     2204        virtual void visit( const OffsetPackExpr * old ) override final {
    22052205                this->node = visitBaseExpr( old,
    22062206                        new ast::OffsetPackExpr(
     
    22112211        }
    22122212
    2213         virtual void visit( LogicalExpr * old ) override final {
     2213        virtual void visit( const LogicalExpr * old ) override final {
    22142214                this->node = visitBaseExpr( old,
    22152215                        new ast::LogicalExpr(
     
    22242224        }
    22252225
    2226         virtual void visit( ConditionalExpr * old ) override final {
     2226        virtual void visit( const ConditionalExpr * old ) override final {
    22272227                this->node = visitBaseExpr( old,
    22282228                        new ast::ConditionalExpr(
     
    22352235        }
    22362236
    2237         virtual void visit( CommaExpr * old ) override final {
     2237        virtual void visit( const CommaExpr * old ) override final {
    22382238                this->node = visitBaseExpr( old,
    22392239                        new ast::CommaExpr(
     
    22452245        }
    22462246
    2247         virtual void visit( TypeExpr * old ) override final {
     2247        virtual void visit( const TypeExpr * old ) override final {
    22482248                this->node = visitBaseExpr( old,
    22492249                        new ast::TypeExpr(
     
    22542254        }
    22552255
    2256         virtual void visit( AsmExpr * old ) override final {
     2256        virtual void visit( const AsmExpr * old ) override final {
    22572257                this->node = visitBaseExpr( old,
    22582258                        new ast::AsmExpr(
     
    22652265        }
    22662266
    2267         virtual void visit( ImplicitCopyCtorExpr * old ) override final {
     2267        virtual void visit( const ImplicitCopyCtorExpr * old ) override final {
    22682268                auto rslt = new ast::ImplicitCopyCtorExpr(
    22692269                        old->location,
     
    22742274        }
    22752275
    2276         virtual void visit( ConstructorExpr * old ) override final {
     2276        virtual void visit( const ConstructorExpr * old ) override final {
    22772277                this->node = visitBaseExpr( old,
    22782278                        new ast::ConstructorExpr(
     
    22832283        }
    22842284
    2285         virtual void visit( CompoundLiteralExpr * old ) override final {
     2285        virtual void visit( const CompoundLiteralExpr * old ) override final {
    22862286                this->node = visitBaseExpr_SkipResultType( old,
    22872287                        new ast::CompoundLiteralExpr(
     
    22932293        }
    22942294
    2295         virtual void visit( RangeExpr * old ) override final {
     2295        virtual void visit( const RangeExpr * old ) override final {
    22962296                this->node = visitBaseExpr( old,
    22972297                        new ast::RangeExpr(
     
    23032303        }
    23042304
    2305         virtual void visit( UntypedTupleExpr * old ) override final {
     2305        virtual void visit( const UntypedTupleExpr * old ) override final {
    23062306                this->node = visitBaseExpr( old,
    23072307                        new ast::UntypedTupleExpr(
     
    23122312        }
    23132313
    2314         virtual void visit( TupleExpr * old ) override final {
     2314        virtual void visit( const TupleExpr * old ) override final {
    23152315                this->node = visitBaseExpr( old,
    23162316                        new ast::TupleExpr(
     
    23212321        }
    23222322
    2323         virtual void visit( TupleIndexExpr * old ) override final {
     2323        virtual void visit( const TupleIndexExpr * old ) override final {
    23242324                this->node = visitBaseExpr( old,
    23252325                        new ast::TupleIndexExpr(
     
    23312331        }
    23322332
    2333         virtual void visit( TupleAssignExpr * old ) override final {
     2333        virtual void visit( const TupleAssignExpr * old ) override final {
    23342334                this->node = visitBaseExpr_SkipResultType( old,
    23352335                        new ast::TupleAssignExpr(
     
    23412341        }
    23422342
    2343         virtual void visit( StmtExpr * old ) override final {
     2343        virtual void visit( const StmtExpr * old ) override final {
    23442344                auto rslt = new ast::StmtExpr(
    23452345                        old->location,
     
    23522352        }
    23532353
    2354         virtual void visit( UniqueExpr * old ) override final {
     2354        virtual void visit( const UniqueExpr * old ) override final {
    23552355                auto rslt = new ast::UniqueExpr(
    23562356                        old->location,
     
    23642364        }
    23652365
    2366         virtual void visit( UntypedInitExpr * old ) override final {
     2366        virtual void visit( const UntypedInitExpr * old ) override final {
    23672367                std::deque<ast::InitAlternative> initAlts;
    23682368                for (auto ia : old->initAlts) {
     
    23812381        }
    23822382
    2383         virtual void visit( InitExpr * old ) override final {
     2383        virtual void visit( const InitExpr * old ) override final {
    23842384                this->node = visitBaseExpr( old,
    23852385                        new ast::InitExpr(
     
    23912391        }
    23922392
    2393         virtual void visit( DeletedExpr * old ) override final {
     2393        virtual void visit( const DeletedExpr * old ) override final {
    23942394                this->node = visitBaseExpr( old,
    23952395                        new ast::DeletedExpr(
     
    23972397                                GET_ACCEPT_1(expr, Expr),
    23982398                                inCache(old->deleteStmt) ?
    2399                                         this->node :
    2400                                         GET_ACCEPT_1(deleteStmt, Node)
    2401                         )
    2402                 );
    2403         }
    2404 
    2405         virtual void visit( DefaultArgExpr * old ) override final {
     2399                                        strict_dynamic_cast<ast::Decl*>(this->node) :
     2400                                        GET_ACCEPT_1(deleteStmt, Decl)
     2401                        )
     2402                );
     2403        }
     2404
     2405        virtual void visit( const DefaultArgExpr * old ) override final {
    24062406                this->node = visitBaseExpr( old,
    24072407                        new ast::DefaultArgExpr(
     
    24122412        }
    24132413
    2414         virtual void visit( GenericExpr * old ) override final {
     2414        virtual void visit( const GenericExpr * old ) override final {
    24152415                std::vector<ast::GenericExpr::Association> associations;
    24162416                for (auto association : old->associations) {
     
    24292429        }
    24302430
    2431         void visitType( Type * old, ast::Type * type ) {
     2431        void visitType( const Type * old, ast::Type * type ) {
    24322432                // Some types do this in their constructor so add a check.
    24332433                if ( !old->attributes.empty() && type->attributes.empty() ) {
     
    24372437        }
    24382438
    2439         virtual void visit( VoidType * old ) override final {
     2439        virtual void visit( const VoidType * old ) override final {
    24402440                visitType( old, new ast::VoidType{ cv( old ) } );
    24412441        }
    24422442
    2443         virtual void visit( BasicType * old ) override final {
     2443        virtual void visit( const BasicType * old ) override final {
    24442444                auto type = new ast::BasicType{ (ast::BasicType::Kind)(unsigned)old->kind, cv( old ) };
    24452445                // I believe this should always be a BasicType.
     
    24502450        }
    24512451
    2452         virtual void visit( PointerType * old ) override final {
     2452        virtual void visit( const PointerType * old ) override final {
    24532453                visitType( old, new ast::PointerType{
    24542454                        GET_ACCEPT_1( base, Type ),
     
    24602460        }
    24612461
    2462         virtual void visit( ArrayType * old ) override final {
     2462        virtual void visit( const ArrayType * old ) override final {
    24632463                visitType( old, new ast::ArrayType{
    24642464                        GET_ACCEPT_1( base, Type ),
     
    24702470        }
    24712471
    2472         virtual void visit( ReferenceType * old ) override final {
     2472        virtual void visit( const ReferenceType * old ) override final {
    24732473                visitType( old, new ast::ReferenceType{
    24742474                        GET_ACCEPT_1( base, Type ),
     
    24772477        }
    24782478
    2479         virtual void visit( QualifiedType * old ) override final {
     2479        virtual void visit( const QualifiedType * old ) override final {
    24802480                visitType( old, new ast::QualifiedType{
    24812481                        GET_ACCEPT_1( parent, Type ),
     
    24852485        }
    24862486
    2487         virtual void visit( FunctionType * old ) override final {
     2487        virtual void visit( const FunctionType * old ) override final {
    24882488                auto ty = new ast::FunctionType {
    24892489                        (ast::ArgumentFlag)old->isVarArgs,
     
    24962496        }
    24972497
    2498         void postvisit( ReferenceToType * old, ast::ReferenceToType * ty ) {
     2498        void postvisit( const ReferenceToType * old, ast::ReferenceToType * ty ) {
    24992499                ty->forall = GET_ACCEPT_V( forall, TypeDecl );
    25002500                ty->params = GET_ACCEPT_V( parameters, Expr );
     
    25032503        }
    25042504
    2505         virtual void visit( StructInstType * old ) override final {
     2505        virtual void visit( const StructInstType * old ) override final {
    25062506                ast::StructInstType * ty;
    25072507                if ( old->baseStruct ) {
     
    25212521        }
    25222522
    2523         virtual void visit( UnionInstType * old ) override final {
     2523        virtual void visit( const UnionInstType * old ) override final {
    25242524                ast::UnionInstType * ty;
    25252525                if ( old->baseUnion ) {
     
    25392539        }
    25402540
    2541         virtual void visit( EnumInstType * old ) override final {
     2541        virtual void visit( const EnumInstType * old ) override final {
    25422542                ast::EnumInstType * ty;
    25432543                if ( old->baseEnum ) {
     
    25572557        }
    25582558
    2559         virtual void visit( TraitInstType * old ) override final {
     2559        virtual void visit( const TraitInstType * old ) override final {
    25602560                ast::TraitInstType * ty;
    25612561                if ( old->baseTrait ) {
     
    25752575        }
    25762576
    2577         virtual void visit( TypeInstType * old ) override final {
     2577        virtual void visit( const TypeInstType * old ) override final {
    25782578                ast::TypeInstType * ty;
    25792579                if ( old->baseType ) {
     
    25952595        }
    25962596
    2597         virtual void visit( TupleType * old ) override final {
     2597        virtual void visit( const TupleType * old ) override final {
    25982598                visitType( old, new ast::TupleType{
    25992599                        GET_ACCEPT_V( types, Type ),
     
    26032603        }
    26042604
    2605         virtual void visit( TypeofType * old ) override final {
     2605        virtual void visit( const TypeofType * old ) override final {
    26062606                visitType( old, new ast::TypeofType{
    26072607                        GET_ACCEPT_1( expr, Expr ),
     
    26112611        }
    26122612
    2613         virtual void visit( AttrType * ) override final {
     2613        virtual void visit( const AttrType * ) override final {
    26142614                assertf( false, "AttrType deprecated in new AST." );
    26152615        }
    26162616
    2617         virtual void visit( VarArgsType * old ) override final {
     2617        virtual void visit( const VarArgsType * old ) override final {
    26182618                visitType( old, new ast::VarArgsType{ cv( old ) } );
    26192619        }
    26202620
    2621         virtual void visit( ZeroType * old ) override final {
     2621        virtual void visit( const ZeroType * old ) override final {
    26222622                visitType( old, new ast::ZeroType{ cv( old ) } );
    26232623        }
    26242624
    2625         virtual void visit( OneType * old ) override final {
     2625        virtual void visit( const OneType * old ) override final {
    26262626                visitType( old, new ast::OneType{ cv( old ) } );
    26272627        }
    26282628
    2629         virtual void visit( GlobalScopeType * old ) override final {
     2629        virtual void visit( const GlobalScopeType * old ) override final {
    26302630                visitType( old, new ast::GlobalScopeType{} );
    26312631        }
    26322632
    2633         virtual void visit( Designation * old ) override final {
     2633        virtual void visit( const Designation * old ) override final {
    26342634                this->node = new ast::Designation(
    26352635                        old->location,
     
    26382638        }
    26392639
    2640         virtual void visit( SingleInit * old ) override final {
     2640        virtual void visit( const SingleInit * old ) override final {
    26412641                this->node = new ast::SingleInit(
    26422642                        old->location,
     
    26462646        }
    26472647
    2648         virtual void visit( ListInit * old ) override final {
     2648        virtual void visit( const ListInit * old ) override final {
    26492649                this->node = new ast::ListInit(
    26502650                        old->location,
     
    26552655        }
    26562656
    2657         virtual void visit( ConstructorInit * old ) override final {
     2657        virtual void visit( const ConstructorInit * old ) override final {
    26582658                this->node = new ast::ConstructorInit(
    26592659                        old->location,
     
    26642664        }
    26652665
    2666         virtual void visit( Constant * ) override final {
     2666        virtual void visit( const Constant * ) override final {
    26672667                // Handled in visit( ConstantEpxr * ).
    26682668                // In the new tree, Constant fields are inlined into containing ConstantExpression.
     
    26702670        }
    26712671
    2672         virtual void visit( Attribute * old ) override final {
     2672        virtual void visit( const Attribute * old ) override final {
    26732673                this->node = new ast::Attribute(
    26742674                        old->name,
     
    26772677        }
    26782678
    2679         virtual void visit( AttrExpr * ) override final {
     2679        virtual void visit( const AttrExpr * ) override final {
    26802680                assertf( false, "AttrExpr deprecated in new AST." );
    26812681        }
  • src/AST/Decl.hpp

    r1f1c102 rf53acdf8  
    102102        ptr<Expr> bitfieldWidth;
    103103
    104         ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, 
    105                 const Init * init = nullptr, Storage::Classes storage = {}, 
    106                 Linkage::Spec linkage = Linkage::C, const Expr * bitWd = nullptr, 
     104        ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type,
     105                const Init * init = nullptr, Storage::Classes storage = {},
     106                Linkage::Spec linkage = Linkage::C, const Expr * bitWd = nullptr,
    107107                std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} )
    108108        : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
     
    323323};
    324324
     325/// With statement `with (...) ...`
     326class WithStmt final : public Decl {
     327public:
     328        std::vector<ptr<Expr>> exprs;
     329        ptr<Stmt> stmt;
     330
     331        WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt * stmt )
     332        : Decl(loc, "", Storage::Auto, Linkage::Cforall), exprs(std::move(exprs)), stmt(stmt) {}
     333
     334        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     335private:
     336        WithStmt * clone() const override { return new WithStmt{ *this }; }
     337        MUTATE_FRIEND
     338};
     339
    325340class AsmDecl : public Decl {
    326341public:
  • src/AST/Expr.hpp

    r1f1c102 rf53acdf8  
    4747
    4848        ParamEntry() : decl( 0 ), declptr( nullptr ), actualType( nullptr ), formalType( nullptr ), expr( nullptr ) {}
    49         ParamEntry( 
    50                 UniqueId id, const Decl * declptr, const Type * actual, const Type * formal, 
     49        ParamEntry(
     50                UniqueId id, const Decl * declptr, const Type * actual, const Type * formal,
    5151                const Expr * e )
    5252        : decl( id ), declptr( declptr ), actualType( actual ), formalType( formal ), expr( e ) {}
     
    112112                        case Empty: new(&data.resnSlots) ResnSlots{}; mode = Slots; // fallthrough
    113113                        case Slots: return data.resnSlots;
    114                         case Params: assert(!"Cannot return to resnSlots from Params");
     114                        case Params: assertf(false, "Cannot return to resnSlots from Params"); abort();
    115115                        }
    116                         return *((ResnSlots*)nullptr);
     116                        assertf(false, "unreachable");
    117117                }
    118118
     
    121121                                return data.resnSlots;
    122122                        }
    123                         assert(!"Mode was not already resnSlots");
    124                         return *((ResnSlots*)nullptr);
     123                        assertf(false, "Mode was not already resnSlots");
     124                        abort();
    125125                }
    126126
     
    131131                        case Params: return data.inferParams;
    132132                        }
    133                         assert(!"unreachable");
    134                         return *((InferredParams*)nullptr);
     133                        assertf(false, "unreachable");
    135134                }
    136135
     
    139138                                return data.inferParams;
    140139                        }
    141                         assert(!"Mode was not already Params");
    142                         return *((InferredParams*)nullptr);
     140                        assertf(false, "Mode was not already Params");
     141                        abort();
    143142                }
    144143
    145144                void set_inferParams( InferredParams && ps ) {
    146145                        switch(mode) {
    147                         case Slots: 
     146                        case Slots:
    148147                                data.resnSlots.~ResnSlots();
    149148                                // fallthrough
    150                         case Empty: 
     149                        case Empty:
    151150                                new(&data.inferParams) InferredParams{ std::move( ps ) };
    152151                                mode = Params;
     
    172171                                        data.inferParams[p.first] = std::move(p.second);
    173172                                }
    174                         } else assert(!"invalid mode");
     173                        } else assertf(false, "invalid mode");
    175174                }
    176175        };
     
    384383
    385384        ConstantExpr(
    386                 const CodeLocation & loc, const Type * ty, const std::string & r, 
     385                const CodeLocation & loc, const Type * ty, const std::string & r,
    387386                        std::optional<unsigned long long> i )
    388387        : Expr( loc, ty ), rep( r ), ival( i ) {}
     
    770769public:
    771770        ptr<Expr> expr;
    772         readonly<Node> deleteStmt;
    773 
    774         DeletedExpr( const CodeLocation & loc, const Expr * e, const Node * del )
     771        readonly<Decl> deleteStmt;
     772
     773        DeletedExpr( const CodeLocation & loc, const Expr * e, const Decl * del )
    775774        : Expr( loc, e->result ), expr( e ), deleteStmt( del ) { assert( expr->result ); }
    776775
  • src/AST/Pass.hpp

    r1f1c102 rf53acdf8  
    115115        const ast::Stmt *             visit( const ast::FinallyStmt          * ) override final;
    116116        const ast::Stmt *             visit( const ast::WaitForStmt          * ) override final;
    117         const ast::Stmt *             visit( const ast::WithStmt             * ) override final;
     117        const ast::Decl *             visit( const ast::WithStmt             * ) override final;
    118118        const ast::NullStmt *         visit( const ast::NullStmt             * ) override final;
    119119        const ast::Stmt *             visit( const ast::DeclStmt             * ) override final;
  • src/AST/Pass.impl.hpp

    r1f1c102 rf53acdf8  
    909909// WithStmt
    910910template< typename pass_t >
    911 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WithStmt * node ) {
     911const ast::Decl * ast::Pass< pass_t >::visit( const ast::WithStmt * node ) {
    912912        VISIT_START( node );
    913913
  • src/AST/Print.cpp

    r1f1c102 rf53acdf8  
    3737}
    3838
    39 class Printer : public Visitor {
     39class Printer final : public Visitor {
    4040public:
    4141        ostream & os;
     
    272272
    273273public:
    274         virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) {
     274        virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final {
    275275                if ( ! node->name.empty() ) os << node->name << ": ";
    276276
     
    314314        }
    315315
    316         virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) {
     316        virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) override final {
    317317                if ( !node->name.empty() ) os << node->name << ": ";
    318318
     
    342342        }
    343343
    344         virtual const ast::Decl * visit( const ast::StructDecl * node ) {
     344        virtual const ast::Decl * visit( const ast::StructDecl * node ) override final {
    345345                print(node);
    346346                return node;
    347347        }
    348348
    349         virtual const ast::Decl * visit( const ast::UnionDecl * node ) {
     349        virtual const ast::Decl * visit( const ast::UnionDecl * node ) override final {
    350350                print(node);
    351351                return node;
    352352        }
    353353
    354         virtual const ast::Decl * visit( const ast::EnumDecl * node ) {
     354        virtual const ast::Decl * visit( const ast::EnumDecl * node ) override final {
    355355                print(node);
    356356                return node;
    357357        }
    358358
    359         virtual const ast::Decl * visit( const ast::TraitDecl * node ) {
     359        virtual const ast::Decl * visit( const ast::TraitDecl * node ) override final {
    360360                print(node);
    361361                return node;
    362362        }
    363363
    364         virtual const ast::Decl * visit( const ast::TypeDecl * node ) {
     364        virtual const ast::Decl * visit( const ast::TypeDecl * node ) override final {
    365365                preprint( node );
    366366                if ( ! short_mode && node->init ) {
     
    374374        }
    375375
    376         virtual const ast::Decl * visit( const ast::TypedefDecl * node ) {
    377                 preprint( node );
    378                 return node;
    379         }
    380 
    381         virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) {
     376        virtual const ast::Decl * visit( const ast::TypedefDecl * node ) override final {
     377                preprint( node );
     378                return node;
     379        }
     380
     381        virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final {
    382382                safe_print( node->stmt );
    383383                return node;
    384384        }
    385385
    386         virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) {
     386        virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) override final {
    387387                os << "Static Assert with condition: ";
    388388                ++indent;
     
    396396        }
    397397
    398         virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) {
     398        virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final {
    399399                os << "Compound Statement:" << endl;
    400400                ++indent;
     
    404404        }
    405405
    406         virtual const ast::Stmt * visit( const ast::ExprStmt * node ) {
     406        virtual const ast::Stmt * visit( const ast::ExprStmt * node ) override final {
    407407                ++indent;
    408408                os << "Expression Statement:" << endl << indent;
     
    412412        }
    413413
    414         virtual const ast::Stmt * visit( const ast::AsmStmt * node ) {
     414        virtual const ast::Stmt * visit( const ast::AsmStmt * node ) override final {
    415415                os << "Assembler Statement:" << endl;
    416416                ++indent;
     
    433433        }
    434434
    435         virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) {
     435        virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final {
    436436                os << "GCC Directive: " << node->directive << endl;
    437437                return node;
    438438        }
    439439
    440         virtual const ast::Stmt * visit( const ast::IfStmt * node ) {
     440        virtual const ast::Stmt * visit( const ast::IfStmt * node ) override final {
    441441                os << "If on condition:" << endl;
    442442                ++indent;
     
    473473        }
    474474
    475         virtual const ast::Stmt * visit( const ast::WhileStmt * node ) {
     475        virtual const ast::Stmt * visit( const ast::WhileStmt * node ) override final {
    476476                if ( node->isDoWhile ) { os << "Do-"; }
    477477                os << "While on condition:" << endl;
     
    490490        }
    491491
    492         virtual const ast::Stmt * visit( const ast::ForStmt * node ) {
     492        virtual const ast::Stmt * visit( const ast::ForStmt * node ) override final {
    493493                os << "For Statement" << endl;
    494494
     
    532532        }
    533533
    534         virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) {
     534        virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) override final {
    535535                os << "Switch on condition: ";
    536536                safe_print( node->cond );
     
    546546        }
    547547
    548         virtual const ast::Stmt * visit( const ast::CaseStmt * node ) {
     548        virtual const ast::Stmt * visit( const ast::CaseStmt * node ) override final {
    549549                if ( node->isDefault() ) {
    550550                        os << indent << "Default ";
     
    565565        }
    566566
    567         virtual const ast::Stmt * visit( const ast::BranchStmt * node ) {
     567        virtual const ast::Stmt * visit( const ast::BranchStmt * node ) override final {
    568568                os << "Branch (" << node->kindName() << ")" << endl;
    569569                ++indent;
     
    586586        }
    587587
    588         virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) {
     588        virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) override final {
    589589                os << "Return Statement, returning";
    590590                if ( node->expr ) {
     
    601601        }
    602602
    603         virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) {
     603        virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) override final {
    604604                if ( node->target ) os << "Non-Local ";
    605605
     
    621621        }
    622622
    623         virtual const ast::Stmt * visit( const ast::TryStmt * node ) {
     623        virtual const ast::Stmt * visit( const ast::TryStmt * node ) override final {
    624624                ++indent;
    625625                os << "Try Statement" << endl << indent-1
     
    642642        }
    643643
    644         virtual const ast::Stmt * visit( const ast::CatchStmt * node ) {
     644        virtual const ast::Stmt * visit( const ast::CatchStmt * node ) override final {
    645645                os << "Catch ";
    646646                switch ( node->kind ) {
     
    667667        }
    668668
    669         virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) {
     669        virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) override final {
    670670                os << "Finally Statement" << endl;
    671671                os << indent << "... with block:" << endl;
     
    678678        }
    679679
    680         virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) {
     680        virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) override final {
    681681                os << "Waitfor Statement" << endl;
    682682                indent += 2;
     
    732732        }
    733733
    734         virtual const ast::Stmt * visit( const ast::WithStmt * node ) {
     734        virtual const ast::Decl * visit( const ast::WithStmt * node ) override final {
    735735                os << "With statement" << endl;
    736736                os << indent << "... with expressions:" << endl;
     
    744744        }
    745745
    746         virtual const ast::NullStmt * visit( const ast::NullStmt * node ) {
     746        virtual const ast::NullStmt * visit( const ast::NullStmt * node ) override final {
    747747                os << "Null Statement" << endl;
    748748                print( node->labels );
     
    751751        }
    752752
    753         virtual const ast::Stmt * visit( const ast::DeclStmt * node ) {
     753        virtual const ast::Stmt * visit( const ast::DeclStmt * node ) override final {
    754754                os << "Declaration of ";
    755755                safe_print( node->decl );
     
    758758        }
    759759
    760         virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) {
     760        virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final {
    761761                os << "Implicit Ctor Dtor Statement" << endl;
    762762                os << indent << "... with Ctor/Dtor: ";
     
    769769        }
    770770
    771         virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) {
     771        virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) override final {
    772772                ++indent;
    773773                os << "Application of" << endl << indent;
     
    784784        }
    785785
    786         virtual const ast::Expr * visit( const ast::UntypedExpr * node ) {
     786        virtual const ast::Expr * visit( const ast::UntypedExpr * node ) override final {
    787787                ++indent;
    788788                os << "Applying untyped:" << endl;
     
    797797        }
    798798
    799         virtual const ast::Expr * visit( const ast::NameExpr * node ) {
     799        virtual const ast::Expr * visit( const ast::NameExpr * node ) override final {
    800800                os << "Name: " << node->name;
    801801                postprint( node );
     
    804804        }
    805805
    806         virtual const ast::Expr * visit( const ast::AddressExpr * node ) {
     806        virtual const ast::Expr * visit( const ast::AddressExpr * node ) override final {
    807807                os << "Address of:" << endl;
    808808                ++indent;
     
    815815        }
    816816
    817         virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) {
     817        virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) override final {
    818818                os << "Address of label:" << node->arg;
    819819
     
    821821        }
    822822
    823         virtual const ast::Expr * visit( const ast::CastExpr * node ) {
     823        virtual const ast::Expr * visit( const ast::CastExpr * node ) override final {
    824824                ++indent;
    825825                os << (node->isGenerated ? "Generated" : "Explicit") << " cast of:" << endl << indent;
     
    841841        }
    842842
    843         virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) {
     843        virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final {
    844844                ++indent;
    845845                os << "Keyword Cast of:" << endl << indent;
     
    852852        }
    853853
    854         virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) {
     854        virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) override final {
    855855                ++indent;
    856856                os << "Virtual Cast of:" << endl << indent;
     
    869869        }
    870870
    871         virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) {
     871        virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) override final {
    872872                ++indent;
    873873                os << "Untyped Member Expression, with field: " << endl << indent;
     
    881881        }
    882882
    883         virtual const ast::Expr * visit( const ast::MemberExpr * node ) {
     883        virtual const ast::Expr * visit( const ast::MemberExpr * node ) override final {
    884884                ++indent;
    885885                os << "Member Expression, with field:" << endl << indent;
     
    893893        }
    894894
    895         virtual const ast::Expr * visit( const ast::VariableExpr * node ) {
     895        virtual const ast::Expr * visit( const ast::VariableExpr * node ) override final {
    896896                os << "Variable Expression: ";
    897897                short_print( node->var );
     
    901901        }
    902902
    903         virtual const ast::Expr * visit( const ast::ConstantExpr * node ) {
     903        virtual const ast::Expr * visit( const ast::ConstantExpr * node ) override final {
    904904                os << "Constant Expression (" << node->rep;
    905905                if ( node->result ) {
     
    913913        }
    914914
    915         virtual const ast::Expr * visit( const ast::SizeofExpr * node ) {
     915        virtual const ast::Expr * visit( const ast::SizeofExpr * node ) override final {
    916916                os << "Sizeof Expression on: ";
    917917                ++indent;
     
    924924        }
    925925
    926         virtual const ast::Expr * visit( const ast::AlignofExpr * node ) {
     926        virtual const ast::Expr * visit( const ast::AlignofExpr * node ) override final {
    927927                os << "Alignof Expression on: ";
    928928                ++indent;
     
    935935        }
    936936
    937         virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) {
     937        virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) override final {
    938938                os << "Untyped Offsetof Expression on member " << node->member << " of ";
    939939                ++indent;
     
    945945        }
    946946
    947         virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) {
     947        virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) override final {
    948948                os << "Offsetof Expression on member " << node->member->name << " of ";
    949949                ++indent;
     
    955955        }
    956956
    957         virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) {
     957        virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) override final {
    958958                os << "Offset Pack Expression on: ";
    959959                ++indent;
     
    965965        }
    966966
    967         virtual const ast::Expr * visit( const ast::LogicalExpr * node ) {
     967        virtual const ast::Expr * visit( const ast::LogicalExpr * node ) override final {
    968968                os << "Short-circuited operation (" << (node->isAnd ? "and" : "or") << ") on: ";
    969969                safe_print( node->arg1 );
     
    975975        }
    976976
    977         virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) {
     977        virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) override final {
    978978                ++indent;
    979979                os << "Conditional expression on:" << endl << indent;
     
    989989        }
    990990
    991         virtual const ast::Expr * visit( const ast::CommaExpr * node ) {
     991        virtual const ast::Expr * visit( const ast::CommaExpr * node ) override final {
    992992                ++indent;
    993993                os << "Comma Expression:" << endl << indent;
     
    10011001        }
    10021002
    1003         virtual const ast::Expr * visit( const ast::TypeExpr * node ) {
     1003        virtual const ast::Expr * visit( const ast::TypeExpr * node ) override final {
    10041004                safe_print( node->type );
    10051005                postprint( node );
     
    10081008        }
    10091009
    1010         virtual const ast::Expr * visit( const ast::AsmExpr * node ) {
     1010        virtual const ast::Expr * visit( const ast::AsmExpr * node ) override final {
    10111011                os << "Asm Expression:" << endl;
    10121012                ++indent;
     
    10191019        }
    10201020
    1021         virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) {
     1021        virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) override final {
    10221022                ++indent;
    10231023                os << "Implicit Copy Constructor Expression:" << endl << indent;
     
    10291029        }
    10301030
    1031         virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) {
     1031        virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) override final {
    10321032                os <<  "Constructor Expression:" << endl << indent+1;
    10331033                indent += 2;
     
    10391039        }
    10401040
    1041         virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) {
     1041        virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) override final {
    10421042                ++indent;
    10431043                os << "Compound Literal Expression: " << endl << indent;
     
    10511051        }
    10521052
    1053         virtual const ast::Expr * visit( const ast::RangeExpr * node ) {
     1053        virtual const ast::Expr * visit( const ast::RangeExpr * node ) override final {
    10541054                os << "Range Expression: ";
    10551055                safe_print( node->low );
     
    10611061        }
    10621062
    1063         virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) {
     1063        virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) override final {
    10641064                os << "Untyped Tuple:" << endl;
    10651065                ++indent;
     
    10711071        }
    10721072
    1073         virtual const ast::Expr * visit( const ast::TupleExpr * node ) {
     1073        virtual const ast::Expr * visit( const ast::TupleExpr * node ) override final {
    10741074                os << "Tuple:" << endl;
    10751075                ++indent;
     
    10811081        }
    10821082
    1083         virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) {
     1083        virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) override final {
    10841084                os << "Tuple Index Expression, with tuple:" << endl;
    10851085                ++indent;
     
    10931093        }
    10941094
    1095         virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) {
     1095        virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) override final {
    10961096                os << "Tuple Assignment Expression, with stmt expr:" << endl;
    10971097                ++indent;
     
    11041104        }
    11051105
    1106         virtual const ast::Expr * visit( const ast::StmtExpr * node ) {
     1106        virtual const ast::Expr * visit( const ast::StmtExpr * node ) override final {
    11071107                ++indent;
    11081108                os << "Statement Expression:" << endl << indent;
     
    11221122        }
    11231123
    1124         virtual const ast::Expr * visit( const ast::UniqueExpr * node ) {
     1124        virtual const ast::Expr * visit( const ast::UniqueExpr * node ) override final {
    11251125                ++indent;
    11261126                os << "Unique Expression with id: " << node->id << endl << indent;
     
    11361136        }
    11371137
    1138         virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) {
     1138        virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) override final {
    11391139                ++indent;
    11401140                os << "Untyped Init Expression" << endl << indent;
     
    11521152        }
    11531153
    1154         virtual const ast::Expr * visit( const ast::InitExpr * node ) {
     1154        virtual const ast::Expr * visit( const ast::InitExpr * node ) override final {
    11551155                ++indent;
    11561156                os << "Init Expression" << endl << indent;
     
    11631163        }
    11641164
    1165         virtual const ast::Expr * visit( const ast::DeletedExpr * node ) {
     1165        virtual const ast::Expr * visit( const ast::DeletedExpr * node ) override final {
    11661166                ++indent;
    11671167                os << "Deleted Expression" << endl << indent;
     
    11741174        }
    11751175
    1176         virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) {
     1176        virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) override final {
    11771177                ++indent;
    11781178                os << "Default Argument Expression" << endl << indent;
     
    11831183        }
    11841184
    1185         virtual const ast::Expr * visit( const ast::GenericExpr * node ) {
     1185        virtual const ast::Expr * visit( const ast::GenericExpr * node ) override final {
    11861186                ++indent;
    11871187                os << "C11 _Generic Expression" << endl << indent;
     
    12061206        }
    12071207
    1208         virtual const ast::Type * visit( const ast::VoidType * node ) {
     1208        virtual const ast::Type * visit( const ast::VoidType * node ) override final {
    12091209                preprint( node );
    12101210                os << "void";
     
    12121212        }
    12131213
    1214         virtual const ast::Type * visit( const ast::BasicType * node ) {
     1214        virtual const ast::Type * visit( const ast::BasicType * node ) override final {
    12151215                preprint( node );
    12161216                os << ast::BasicType::typeNames[ node->kind ];
     
    12181218        }
    12191219
    1220         virtual const ast::Type * visit( const ast::PointerType * node ) {
     1220        virtual const ast::Type * visit( const ast::PointerType * node ) override final {
    12211221                preprint( node );
    12221222                if ( ! node->isArray() ) {
     
    12411241        }
    12421242
    1243         virtual const ast::Type * visit( const ast::ArrayType * node ) {
     1243        virtual const ast::Type * visit( const ast::ArrayType * node ) override final {
    12441244                preprint( node );
    12451245                if ( node->isStatic ) {
     
    12651265        }
    12661266
    1267         virtual const ast::Type * visit( const ast::ReferenceType * node ) {
     1267        virtual const ast::Type * visit( const ast::ReferenceType * node ) override final {
    12681268                preprint( node );
    12691269                os << "reference to ";
     
    12731273        }
    12741274
    1275         virtual const ast::Type * visit( const ast::QualifiedType * node ) {
     1275        virtual const ast::Type * visit( const ast::QualifiedType * node ) override final {
    12761276                preprint( node );
    12771277                ++indent;
     
    12861286        }
    12871287
    1288         virtual const ast::Type * visit( const ast::FunctionType * node ) {
     1288        virtual const ast::Type * visit( const ast::FunctionType * node ) override final {
    12891289                preprint( node );
    12901290
     
    13151315        }
    13161316
    1317         virtual const ast::Type * visit( const ast::StructInstType * node ) {
     1317        virtual const ast::Type * visit( const ast::StructInstType * node ) override final {
    13181318                preprint( node );
    13191319                os << "instance of struct " << node->name;
     
    13261326        }
    13271327
    1328         virtual const ast::Type * visit( const ast::UnionInstType * node ) {
     1328        virtual const ast::Type * visit( const ast::UnionInstType * node ) override final {
    13291329                preprint( node );
    13301330                os << "instance of union " << node->name;
     
    13371337        }
    13381338
    1339         virtual const ast::Type * visit( const ast::EnumInstType * node ) {
     1339        virtual const ast::Type * visit( const ast::EnumInstType * node ) override final {
    13401340                preprint( node );
    13411341                os << "instance of enum " << node->name;
     
    13481348        }
    13491349
    1350         virtual const ast::Type * visit( const ast::TraitInstType * node ) {
     1350        virtual const ast::Type * visit( const ast::TraitInstType * node ) override final {
    13511351                preprint( node );
    13521352                os << "instance of trait " << node->name;
     
    13561356        }
    13571357
    1358         virtual const ast::Type * visit( const ast::TypeInstType * node ) {
     1358        virtual const ast::Type * visit( const ast::TypeInstType * node ) override final {
    13591359                preprint( node );
    13601360                os << "instance of type " << node->name
     
    13651365        }
    13661366
    1367         virtual const ast::Type * visit( const ast::TupleType * node ) {
     1367        virtual const ast::Type * visit( const ast::TupleType * node ) override final {
    13681368                preprint( node );
    13691369                os << "tuple of types" << endl;
     
    13751375        }
    13761376
    1377         virtual const ast::Type * visit( const ast::TypeofType * node ) {
     1377        virtual const ast::Type * visit( const ast::TypeofType * node ) override final {
    13781378                preprint( node );
    13791379                if ( node->kind == ast::TypeofType::Basetypeof ) { os << "base-"; }
     
    13841384        }
    13851385
    1386         virtual const ast::Type * visit( const ast::VarArgsType * node ) {
     1386        virtual const ast::Type * visit( const ast::VarArgsType * node ) override final {
    13871387                preprint( node );
    13881388                os << "builtin var args pack";
     
    13901390        }
    13911391
    1392         virtual const ast::Type * visit( const ast::ZeroType * node ) {
     1392        virtual const ast::Type * visit( const ast::ZeroType * node ) override final {
    13931393                preprint( node );
    13941394                os << "zero_t";
     
    13961396        }
    13971397
    1398         virtual const ast::Type * visit( const ast::OneType * node ) {
     1398        virtual const ast::Type * visit( const ast::OneType * node ) override final {
    13991399                preprint( node );
    14001400                os << "one_t";
     
    14021402        }
    14031403
    1404         virtual const ast::Type * visit( const ast::GlobalScopeType * node ) {
     1404        virtual const ast::Type * visit( const ast::GlobalScopeType * node ) override final {
    14051405                preprint( node );
    14061406                os << "Global Scope Type";
     
    14081408        }
    14091409
    1410         virtual const ast::Designation * visit( const ast::Designation * node ) {
     1410        virtual const ast::Designation * visit( const ast::Designation * node ) override final {
    14111411                if ( node->designators.empty() ) return node;
    14121412                os << "... designated by: " << endl;
     
    14211421        }
    14221422
    1423         virtual const ast::Init * visit( const ast::SingleInit * node ) {
     1423        virtual const ast::Init * visit( const ast::SingleInit * node ) override final {
    14241424                os << "Simple Initializer: ";
    14251425                safe_print( node->value );
     
    14271427        }
    14281428
    1429         virtual const ast::Init * visit( const ast::ListInit * node ) {
     1429        virtual const ast::Init * visit( const ast::ListInit * node ) override final {
    14301430                os << "Compound initializer: " << endl;
    14311431                ++indent;
     
    14451445        }
    14461446
    1447         virtual const ast::Init * visit( const ast::ConstructorInit * node ) {
     1447        virtual const ast::Init * visit( const ast::ConstructorInit * node ) override final {
    14481448                os << "Constructor initializer: " << endl;
    14491449                if ( node->ctor ) {
     
    14701470        }
    14711471
    1472         virtual const ast::Attribute * visit( const ast::Attribute * node ) {
     1472        virtual const ast::Attribute * visit( const ast::Attribute * node ) override final {
    14731473                if ( node->empty() ) return node;
    14741474                os << "Attribute with name: " << node->name;
     
    14811481        }
    14821482
    1483         virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) {
     1483        virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) override final {
    14841484                os << indent << "Types:" << endl;
    14851485                for ( const auto& i : *node ) {
  • src/AST/Stmt.hpp

    r1f1c102 rf53acdf8  
    380380};
    381381
    382 /// With statement `with (...) ...`
    383 class WithStmt final : public Stmt {
    384 public:
    385         std::vector<ptr<Expr>> exprs;
    386         ptr<Stmt> stmt;
    387 
    388         WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt * stmt,
    389                 std::vector<Label> && labels = {} )
    390         : Stmt(loc, std::move(labels)), exprs(std::move(exprs)), stmt(stmt) {}
    391 
    392         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    393 private:
    394         WithStmt * clone() const override { return new WithStmt{ *this }; }
    395         MUTATE_FRIEND
    396 };
    397 
    398382/// Any declaration in a (compound) statement.
    399383class DeclStmt final : public Stmt {
  • src/AST/SymbolTable.cpp

    r1f1c102 rf53acdf8  
    7373
    7474SymbolTable::SymbolTable()
    75 : idTable(), typeTable(), structTable(), enumTable(), unionTable(), traitTable(), 
     75: idTable(), typeTable(), structTable(), enumTable(), unionTable(), traitTable(),
    7676  prevScope(), scope( 0 ), repScope( 0 ) { ++*stats().count; }
    7777
     
    171171}
    172172
    173 void SymbolTable::addDeletedId( const DeclWithType * decl, const Node * deleter ) {
     173void SymbolTable::addDeletedId( const DeclWithType * decl, const Decl * deleter ) {
    174174        // default handling of conflicts is to raise an error
    175175        addId( decl, OnConflict::error(), nullptr, deleter );
     
    189189                        }
    190190                }
    191                 // does not need to be added to the table if both existing and added have a base that are 
     191                // does not need to be added to the table if both existing and added have a base that are
    192192                // the same
    193193                return true;
     
    209209        const std::string &id = decl->name;
    210210
    211         if ( ! typeTable ) { 
     211        if ( ! typeTable ) {
    212212                typeTable = TypeTable::new_ptr();
    213213        } else {
    214214                ++*stats().map_lookups;
    215215                auto existing = typeTable->find( id );
    216                 if ( existing != typeTable->end() 
    217                         && existing->second.scope == scope 
     216                if ( existing != typeTable->end()
     217                        && existing->second.scope == scope
    218218                        && addedTypeConflicts( existing->second.decl, decl ) ) return;
    219219        }
    220        
     220
    221221        lazyInitScope();
    222222        ++*stats().map_mutations;
     
    237237                ++*stats().map_lookups;
    238238                auto existing = structTable->find( id );
    239                 if ( existing != structTable->end() 
    240                         && existing->second.scope == scope 
     239                if ( existing != structTable->end()
     240                        && existing->second.scope == scope
    241241                        && addedDeclConflicts( existing->second.decl, decl ) ) return;
    242242        }
     
    256256                ++*stats().map_lookups;
    257257                auto existing = enumTable->find( id );
    258                 if ( existing != enumTable->end() 
    259                         && existing->second.scope == scope 
     258                if ( existing != enumTable->end()
     259                        && existing->second.scope == scope
    260260                        && addedDeclConflicts( existing->second.decl, decl ) ) return;
    261261        }
    262        
     262
    263263        lazyInitScope();
    264264        ++*stats().map_mutations;
     
    279279                ++*stats().map_lookups;
    280280                auto existing = unionTable->find( id );
    281                 if ( existing != unionTable->end() 
    282                         && existing->second.scope == scope 
     281                if ( existing != unionTable->end()
     282                        && existing->second.scope == scope
    283283                        && addedDeclConflicts( existing->second.decl, decl ) ) return;
    284284        }
     
    298298                ++*stats().map_lookups;
    299299                auto existing = traitTable->find( id );
    300                 if ( existing != traitTable->end() 
    301                         && existing->second.scope == scope 
     300                if ( existing != traitTable->end()
     301                        && existing->second.scope == scope
    302302                        && addedDeclConflicts( existing->second.decl, decl ) ) return;
    303303        }
     
    309309
    310310
    311 void SymbolTable::addWith( const std::vector< ptr<Expr> > & withExprs, const Node * withStmt ) {
     311void SymbolTable::addWith( const std::vector< ptr<Expr> > & withExprs, const Decl * withStmt ) {
    312312        for ( const Expr * expr : withExprs ) {
    313313                if ( ! expr->result ) continue;
    314314                const Type * resTy = expr->result->stripReferences();
    315315                auto aggrType = dynamic_cast< const ReferenceToType * >( resTy );
    316                 assertf( aggrType, "WithStmt expr has non-aggregate type: %s", 
     316                assertf( aggrType, "WithStmt expr has non-aggregate type: %s",
    317317                        toString( expr->result ).c_str() );
    318318                const AggregateDecl * aggr = aggrType->aggr();
    319                 assertf( aggr, "WithStmt has null aggregate from type: %s", 
     319                assertf( aggr, "WithStmt has null aggregate from type: %s",
    320320                        toString( expr->result ).c_str() );
    321                
     321
    322322                addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
    323323        }
     
    373373        }
    374374
    375         /// gets the declaration for the function acting on a type specified by otype key, 
     375        /// gets the declaration for the function acting on a type specified by otype key,
    376376        /// nullptr if none such
    377         const FunctionDecl * getFunctionForOtype( 
     377        const FunctionDecl * getFunctionForOtype(
    378378                        const DeclWithType * decl, const std::string & otypeKey ) {
    379379                auto func = dynamic_cast< const FunctionDecl * >( decl );
     
    383383}
    384384
    385 bool SymbolTable::removeSpecialOverrides( 
     385bool SymbolTable::removeSpecialOverrides(
    386386                SymbolTable::IdData & data, SymbolTable::MangleTable::Ptr & mangleTable ) {
    387         // if a type contains user defined ctor/dtor/assign, then special rules trigger, which 
    388         // determine the set of ctor/dtor/assign that can be used  by the requester. In particular, 
    389         // if the user defines a default ctor, then the generated default ctor is unavailable, 
    390         // likewise for copy ctor and dtor. If the user defines any ctor/dtor, then no generated 
    391         // field ctors are available. If the user defines any ctor then the generated default ctor 
    392         // is unavailable (intrinsic default ctor must be overridden exactly). If the user defines 
    393         // anything that looks like a copy constructor, then the generated copy constructor is 
     387        // if a type contains user defined ctor/dtor/assign, then special rules trigger, which
     388        // determine the set of ctor/dtor/assign that can be used  by the requester. In particular,
     389        // if the user defines a default ctor, then the generated default ctor is unavailable,
     390        // likewise for copy ctor and dtor. If the user defines any ctor/dtor, then no generated
     391        // field ctors are available. If the user defines any ctor then the generated default ctor
     392        // is unavailable (intrinsic default ctor must be overridden exactly). If the user defines
     393        // anything that looks like a copy constructor, then the generated copy constructor is
    394394        // unavailable, and likewise for the assignment operator.
    395395
     
    450450                // if this is the first user-defined function, delete non-user-defined overloads
    451451                std::vector< MangleTable::value_type > deleted;
    452                
     452
    453453                for ( const auto& entry : *mangleTable ) {
    454454                        // skip decls that aren't functions or are for the wrong type
     
    489489                        if ( dataIsCopyFunc ) {
    490490                                // remove current function if exists a user-defined copy function
    491                                 // since the signatures for copy functions don't need to match exactly, using 
     491                                // since the signatures for copy functions don't need to match exactly, using
    492492                                // a delete statement is the wrong approach
    493493                                if ( InitTweak::isCopyFunction( decl ) ) return false;
     
    499499                }
    500500        }
    501        
     501
    502502        // nothing (more) to fix, return true
    503503        return true;
     
    525525
    526526bool SymbolTable::addedIdConflicts(
    527                 const SymbolTable::IdData & existing, const DeclWithType * added, 
    528                 SymbolTable::OnConflict handleConflicts, const Node * deleter ) {
    529         // if we're giving the same name mangling to things of different types then there is something 
     527                const SymbolTable::IdData & existing, const DeclWithType * added,
     528                SymbolTable::OnConflict handleConflicts, const Decl * deleter ) {
     529        // if we're giving the same name mangling to things of different types then there is something
    530530        // wrong
    531531        assert( (isObject( added ) && isObject( existing.id ) )
    532532                || ( isFunction( added ) && isFunction( existing.id ) ) );
    533        
     533
    534534        if ( existing.id->linkage.is_overrideable ) {
    535535                // new definition shadows the autogenerated one, even at the same scope
    536536                return false;
    537         } else if ( existing.id->linkage.is_mangled 
    538                         || ResolvExpr::typesCompatible( 
     537        } else if ( existing.id->linkage.is_mangled
     538                        || ResolvExpr::typesCompatible(
    539539                                added->get_type(), existing.id->get_type(), SymbolTable{} ) ) {
    540                
     540
    541541                // it is a conflict if one declaration is deleted and the other is not
    542542                if ( deleter && ! existing.deleter ) {
     
    555555                if ( isDefinition( added ) && isDefinition( existing.id ) ) {
    556556                        if ( handleConflicts.mode == OnConflict::Error ) {
    557                                 SemanticError( added, 
    558                                         isFunction( added ) ? 
    559                                                 "duplicate function definition for " : 
     557                                SemanticError( added,
     558                                        isFunction( added ) ?
     559                                                "duplicate function definition for " :
    560560                                                "duplicate object definition for " );
    561561                        }
     
    572572}
    573573
    574 void SymbolTable::addId( 
    575                 const DeclWithType * decl, SymbolTable::OnConflict handleConflicts, const Expr * baseExpr, 
    576                 const Node * deleter ) {
     574void SymbolTable::addId(
     575                const DeclWithType * decl, SymbolTable::OnConflict handleConflicts, const Expr * baseExpr,
     576                const Decl * deleter ) {
    577577        ++*stats().add_calls;
    578578        const std::string &name = decl->name;
     
    581581        std::string mangleName;
    582582        if ( decl->linkage.is_overrideable ) {
    583                 // mangle the name without including the appropriate suffix, so overridable routines 
     583                // mangle the name without including the appropriate suffix, so overridable routines
    584584                // are placed into the same "bucket" as their user defined versions.
    585585                mangleName = Mangle::mangle( decl, Mangle::Mode{ Mangle::NoOverrideable } );
     
    588588        }
    589589
    590         // this ensures that no two declarations with the same unmangled name at the same scope 
     590        // this ensures that no two declarations with the same unmangled name at the same scope
    591591        // both have C linkage
    592592        if ( decl->linkage.is_mangled ) {
     
    596596                }
    597597        } else {
    598                 // NOTE: only correct if name mangling is completely isomorphic to C 
     598                // NOTE: only correct if name mangling is completely isomorphic to C
    599599                // type-compatibility, which it may not be.
    600600                if ( hasIncompatibleCDecl( name, mangleName ) ) {
     
    628628                                                idTable = idTable->set(
    629629                                                        name,
    630                                                         mangleTable->set( 
    631                                                                 mangleName, 
     630                                                        mangleTable->set(
     631                                                                mangleName,
    632632                                                                IdData{ existing->second, handleConflicts.deleter } ) );
    633633                                        }
     
    647647}
    648648
    649 void SymbolTable::addMembers( 
     649void SymbolTable::addMembers(
    650650                const AggregateDecl * aggr, const Expr * expr, SymbolTable::OnConflict handleConflicts ) {
    651651        for ( const Decl * decl : aggr->members ) {
     
    655655                                const Type * t = dwt->get_type()->stripReferences();
    656656                                if ( auto rty = dynamic_cast<const ReferenceToType *>( t ) ) {
    657                                         if ( ! dynamic_cast<const StructInstType *>(rty) 
     657                                        if ( ! dynamic_cast<const StructInstType *>(rty)
    658658                                                && ! dynamic_cast<const UnionInstType *>(rty) ) continue;
    659659                                        ResolvExpr::Cost cost = ResolvExpr::Cost::zero;
    660660                                        const Expr * base = ResolvExpr::referenceToRvalueConversion( expr, cost );
    661                                         addMembers( 
     661                                        addMembers(
    662662                                                rty->aggr(), new MemberExpr{ base->location, dwt, base }, handleConflicts );
    663663                                }
     
    680680                if ( ! decl.second.id->linkage.is_mangled && decl.first == mangleName ) return true;
    681681        }
    682        
     682
    683683        return false;
    684684}
  • src/AST/SymbolTable.hpp

    r1f1c102 rf53acdf8  
    3737                readonly<DeclWithType> id = nullptr;  ///< Identifier of declaration
    3838                readonly<Expr> baseExpr = nullptr;    ///< Implied containing aggregate (from WithExpr)
    39                 readonly<Node> deleter = nullptr;     ///< Node deleting this declaration (if non-null)
     39                readonly<Decl> deleter = nullptr;     ///< Node deleting this declaration (if non-null)
    4040                unsigned long scope = 0;              ///< Scope of identifier
    4141
    4242                IdData() = default;
    43                 IdData( const DeclWithType * i, const Expr * base, const Node * del, unsigned long s )
     43                IdData( const DeclWithType * i, const Expr * base, const Decl * del, unsigned long s )
    4444                : id( i ), baseExpr( base ), deleter( del ), scope( s ) {}
    45                
     45
    4646                /// Modify an existing node with a new deleter
    47                 IdData( const IdData & o, const Node * del )
     47                IdData( const IdData & o, const Decl * del )
    4848                : id( o.id ), baseExpr( o.baseExpr ), deleter( del ), scope( o.scope ) {}
    4949
     
    5858        struct scoped {
    5959                readonly<D> decl;     ///< wrapped declaration
    60                 unsigned long scope;  ///< scope of this declaration 
     60                unsigned long scope;  ///< scope of this declaration
    6161
    6262                scoped(const D * d, unsigned long s) : decl(d), scope(s) {}
     
    8888        ~SymbolTable();
    8989
    90         // when using an indexer manually (e.g., within a mutator traversal), it is necessary to 
     90        // when using an indexer manually (e.g., within a mutator traversal), it is necessary to
    9191        // tell the indexer explicitly when scopes begin and end
    9292        void enterScope();
     
    118118        void addId( const DeclWithType * decl, const Expr * baseExpr = nullptr );
    119119        /// Adds a deleted identifier declaration to the symbol table
    120         void addDeletedId( const DeclWithType * decl, const Node * deleter );
     120        void addDeletedId( const DeclWithType * decl, const Decl * deleter );
    121121
    122122        /// Adds a type to the symbol table
     
    136136
    137137        /// adds all of the IDs from WithStmt exprs
    138         void addWith( const std::vector< ptr<Expr> > & withExprs, const Node * withStmt );
     138        void addWith( const std::vector< ptr<Expr> > & withExprs, const Decl * withStmt );
    139139
    140140        /// convenience function for adding a list of Ids to the indexer
     
    154154        const SymbolTable * atScope( unsigned long i ) const;
    155155
    156         /// Removes matching autogenerated constructors and destructors so that they will not be 
     156        /// Removes matching autogenerated constructors and destructors so that they will not be
    157157        /// selected. If returns false, passed decl should not be added.
    158158        bool removeSpecialOverrides( IdData & decl, MangleTable::Ptr & mangleTable );
     
    164164                        Delete  ///< Delete the earlier version with the delete statement
    165165                } mode;
    166                 const Node * deleter;  ///< Statement that deletes this expression
     166                const Decl * deleter;  ///< Statement that deletes this expression
    167167
    168168        private:
    169169                OnConflict() : mode(Error), deleter(nullptr) {}
    170                 OnConflict( const Node * d ) : mode(Delete), deleter(d) {}
     170                OnConflict( const Decl * d ) : mode(Delete), deleter(d) {}
    171171        public:
    172172                OnConflict( const OnConflict& ) = default;
    173173
    174174                static OnConflict error() { return {}; }
    175                 static OnConflict deleteWith( const Node * d ) { return { d }; }
     175                static OnConflict deleteWith( const Decl * d ) { return { d }; }
    176176        };
    177177
    178178        /// true if the existing identifier conflicts with the added identifier
    179179        bool addedIdConflicts(
    180                 const IdData & existing, const DeclWithType * added, OnConflict handleConflicts, 
    181                 const Node * deleter );
     180                const IdData & existing, const DeclWithType * added, OnConflict handleConflicts,
     181                const Decl * deleter );
    182182
    183183        /// common code for addId, addDeletedId, etc.
    184         void addId( 
    185                 const DeclWithType * decl, OnConflict handleConflicts, const Expr * baseExpr = nullptr, 
    186                 const Node * deleter = nullptr );
     184        void addId(
     185                const DeclWithType * decl, OnConflict handleConflicts, const Expr * baseExpr = nullptr,
     186                const Decl * deleter = nullptr );
    187187
    188188        /// adds all of the members of the Aggregate (addWith helper)
  • src/AST/Type.hpp

    r1f1c102 rf53acdf8  
    3535
    3636template< typename T > class Pass;
    37 class ForallSubstitutor;
     37
     38struct ForallSubstitutor;
    3839
    3940class Type : public Node {
     
    167168        static const char *typeNames[];
    168169
    169         BasicType( Kind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 
     170        BasicType( Kind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    170171        : Type(q, std::move(as)), kind(k) {}
    171172
     
    274275public:
    275276        using ForallList = std::vector<ptr<TypeDecl>>;
    276        
     277
    277278        ForallList forall;
    278279
     
    338339        bool hoistType = false;
    339340
    340         ReferenceToType( 
     341        ReferenceToType(
    341342                const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    342343        : ParameterizedType(q, std::move(as)), params(), name(n) {}
     
    359360        readonly<StructDecl> base;
    360361
    361         StructInstType( 
     362        StructInstType(
    362363                const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    363364        : ReferenceToType( n, q, std::move(as) ), base() {}
    364365
    365         StructInstType( 
     366        StructInstType(
    366367                const StructDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );
    367368
     
    381382        readonly<UnionDecl> base;
    382383
    383         UnionInstType( 
     384        UnionInstType(
    384385                const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    385386        : ReferenceToType( n, q, std::move(as) ), base() {}
    386387
    387         UnionInstType( 
     388        UnionInstType(
    388389                const UnionDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );
    389390
     
    403404        readonly<EnumDecl> base;
    404405
    405         EnumInstType( 
     406        EnumInstType(
    406407                const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    407408        : ReferenceToType( n, q, std::move(as) ), base() {}
    408409
    409         EnumInstType( 
     410        EnumInstType(
    410411                const EnumDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );
    411412
     
    425426        readonly<TraitDecl> base;
    426427
    427         TraitInstType( 
     428        TraitInstType(
    428429                const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    429430        : ReferenceToType( n, q, std::move(as) ), base() {}
    430        
    431         TraitInstType( 
     431
     432        TraitInstType(
    432433                const TraitDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );
    433434
     
    449450        TypeVar::Kind kind;
    450451
    451         TypeInstType( 
     452        TypeInstType(
    452453                const std::string& n, const TypeDecl * b, CV::Qualifiers q = {},
    453454                std::vector<ptr<Attribute>> && as = {} )
    454455        : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {}
    455        
    456         TypeInstType( 
     456
     457        TypeInstType(
    457458                const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {},
    458459                std::vector<ptr<Attribute>> && as = {} )
  • src/AST/Visitor.hpp

    r1f1c102 rf53acdf8  
    4848    virtual const ast::Stmt *             visit( const ast::FinallyStmt          * ) = 0;
    4949    virtual const ast::Stmt *             visit( const ast::WaitForStmt          * ) = 0;
    50     virtual const ast::Stmt *             visit( const ast::WithStmt             * ) = 0;
     50    virtual const ast::Decl *             visit( const ast::WithStmt             * ) = 0;
    5151    virtual const ast::NullStmt *         visit( const ast::NullStmt             * ) = 0;
    5252    virtual const ast::Stmt *             visit( const ast::DeclStmt             * ) = 0;
Note: See TracChangeset for help on using the changeset viewer.