Changeset 85521c7 for src/Common
- Timestamp:
- Feb 1, 2018, 5:40:01 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 0188a0bc
- Parents:
- d0a045c7 (diff), 33c0ce8 (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. - Location:
- src/Common
- Files:
-
- 3 edited
-
PassVisitor.h (modified) (1 diff)
-
PassVisitor.impl.h (modified) (9 diffs)
-
PassVisitor.proto.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
rd0a045c7 r85521c7 291 291 bool_ref * get_visit_children_ptr() { return visit_children_impl(pass, 0); } 292 292 293 void indexerScopeEnter () { indexer_impl_enterScope ( pass, 0 ); }294 void indexerScopeLeave () { indexer_impl_leaveScope ( pass, 0 ); }295 void indexerAddId ( DeclarationWithType * node) { indexer_impl_addId ( pass, 0, node ); }296 void indexerAddType ( NamedTypeDecl * node) { indexer_impl_addType ( pass, 0, node ); }297 void indexerAddStruct ( const std::string & id) { indexer_impl_addStruct ( pass, 0, id ); }298 void indexerAddStruct ( StructDecl * node) { indexer_impl_addStruct ( pass, 0, node ); }299 void indexerAddStructFwd( StructDecl * node) { indexer_impl_addStructFwd( pass, 0, node ); }300 void indexerAddEnum ( EnumDecl * node) { indexer_impl_addEnum ( pass, 0, node ); }301 void indexerAddUnion ( const std::string & id) { indexer_impl_addUnion ( pass, 0, id ); }302 void indexerAddUnion ( UnionDecl * node) { indexer_impl_addUnion ( pass, 0, node ); }303 void indexerAddUnionFwd ( UnionDecl * node) { indexer_impl_addUnionFwd ( pass, 0, node ); }304 void indexerAddTrait ( TraitDecl * node) { indexer_impl_addTrait ( pass, 0, node ); }305 void indexerAddWith ( WithStmt * node ) { indexer_impl_addWith ( pass, 0, node); }293 void indexerScopeEnter () { indexer_impl_enterScope ( pass, 0 ); } 294 void indexerScopeLeave () { indexer_impl_leaveScope ( pass, 0 ); } 295 void indexerAddId ( DeclarationWithType * node ) { indexer_impl_addId ( pass, 0, node ); } 296 void indexerAddType ( NamedTypeDecl * node ) { indexer_impl_addType ( pass, 0, node ); } 297 void indexerAddStruct ( const std::string & id ) { indexer_impl_addStruct ( pass, 0, id ); } 298 void indexerAddStruct ( StructDecl * node ) { indexer_impl_addStruct ( pass, 0, node ); } 299 void indexerAddStructFwd( StructDecl * node ) { indexer_impl_addStructFwd( pass, 0, node ); } 300 void indexerAddEnum ( EnumDecl * node ) { indexer_impl_addEnum ( pass, 0, node ); } 301 void indexerAddUnion ( const std::string & id ) { indexer_impl_addUnion ( pass, 0, id ); } 302 void indexerAddUnion ( UnionDecl * node ) { indexer_impl_addUnion ( pass, 0, node ); } 303 void indexerAddUnionFwd ( UnionDecl * node ) { indexer_impl_addUnionFwd ( pass, 0, node ); } 304 void indexerAddTrait ( TraitDecl * node ) { indexer_impl_addTrait ( pass, 0, node ); } 305 void indexerAddWith ( std::list< Expression * > & exprs ) { indexer_impl_addWith ( pass, 0, exprs ); } 306 306 307 307 -
src/Common/PassVisitor.impl.h
rd0a045c7 r85521c7 365 365 maybeAccept_impl ( node->attributes , *this ); 366 366 367 if ( node->name != "" ) { 368 indexerAddId( node ); 369 } 367 indexerAddId( node ); 370 368 371 369 VISIT_END( node ); … … 381 379 maybeMutate_impl ( node->attributes , *this ); 382 380 383 if ( node->name != "" ) { 384 indexerAddId( node ); 385 } 381 indexerAddId( node ); 386 382 387 383 MUTATE_END( DeclarationWithType, node ); … … 394 390 VISIT_START( node ); 395 391 396 if ( node->name != "" ) { 397 indexerAddId( node ); 398 } 399 400 { 401 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 402 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 403 static ObjectDecl func( 404 "__func__", noStorageClasses, LinkageSpec::C, nullptr, 405 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), 406 nullptr 407 ); 408 indexerAddId( &func ); 409 maybeAccept_impl( node->type, *this ); 410 maybeAccept_impl( node->statements, *this ); 411 maybeAccept_impl( node->attributes, *this ); 392 indexerAddId( node ); 393 394 maybeAccept_impl( node->withExprs, *this ); 395 { 396 // with clause introduces a level of scope (for the with expression members). 397 // with clause exprs are added to the indexer before parameters so that parameters 398 // shadow with exprs and not the other way around. 399 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 400 indexerAddWith( node->withExprs ); 401 { 402 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 403 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 404 static ObjectDecl func( 405 "__func__", noStorageClasses, LinkageSpec::C, nullptr, 406 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), 407 nullptr 408 ); 409 indexerAddId( &func ); 410 maybeAccept_impl( node->type, *this ); 411 maybeAccept_impl( node->statements, *this ); 412 maybeAccept_impl( node->attributes, *this ); 413 } 412 414 } 413 415 … … 419 421 MUTATE_START( node ); 420 422 421 if ( node->name != "" ) { 422 indexerAddId( node ); 423 } 424 425 { 426 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 427 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 428 static ObjectDecl func( 429 "__func__", noStorageClasses, LinkageSpec::C, nullptr, 430 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), 431 nullptr 432 ); 433 indexerAddId( &func ); 434 maybeMutate_impl( node->type, *this ); 435 maybeMutate_impl( node->statements, *this ); 436 maybeMutate_impl( node->attributes, *this ); 423 indexerAddId( node ); 424 425 { 426 // with clause introduces a level of scope (for the with expression members). 427 // with clause exprs are added to the indexer before parameters so that parameters 428 // shadow with exprs and not the other way around. 429 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 430 indexerAddWith( node->withExprs ); 431 { 432 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 433 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 434 static ObjectDecl func( 435 "__func__", noStorageClasses, LinkageSpec::C, nullptr, 436 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), 437 nullptr 438 ); 439 indexerAddId( &func ); 440 maybeMutate_impl( node->type, *this ); 441 maybeMutate_impl( node->statements, *this ); 442 maybeMutate_impl( node->attributes, *this ); 443 } 437 444 } 438 445 … … 730 737 template< typename pass_type > 731 738 void PassVisitor< pass_type >::visit( AsmStmt * node ) { 732 VISIT_BODY( node ); 739 VISIT_START( node ) 740 741 maybeAccept_impl( node->instruction, *this ); 742 maybeAccept_impl( node->output, *this ); 743 maybeAccept_impl( node->input, *this ); 744 maybeAccept_impl( node->clobber, *this ); 745 746 VISIT_END( node ); 733 747 } 734 748 735 749 template< typename pass_type > 736 750 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { 737 MUTATE_BODY( Statement, node ); 751 MUTATE_START( node ); 752 753 maybeMutate_impl( node->instruction, *this ); 754 maybeMutate_impl( node->output, *this ); 755 maybeMutate_impl( node->input, *this ); 756 maybeMutate_impl( node->clobber, *this ); 757 758 MUTATE_END( Statement, node ); 738 759 } 739 760 … … 868 889 template< typename pass_type > 869 890 void PassVisitor< pass_type >::visit( BranchStmt * node ) { 870 VISIT_BODY( node ); 891 VISIT_START( node ); 892 VISIT_END( node ); 871 893 } 872 894 873 895 template< typename pass_type > 874 896 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { 875 MUTATE_BODY( Statement, node ); 897 MUTATE_START( node ); 898 MUTATE_END( Statement, node ); 876 899 } 877 900 … … 901 924 template< typename pass_type > 902 925 void PassVisitor< pass_type >::visit( ThrowStmt * node ) { 903 VISIT_BODY( node ); 926 VISIT_START( node ); 927 928 maybeAccept_impl( node->expr, *this ); 929 maybeAccept_impl( node->target, *this ); 930 931 VISIT_END( node ); 904 932 } 905 933 906 934 template< typename pass_type > 907 935 Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { 908 MUTATE_BODY( Statement, node ); 936 MUTATE_START( node ); 937 938 maybeMutate_impl( node->expr, *this ); 939 maybeMutate_impl( node->target, *this ); 940 941 MUTATE_END( Statement, node ); 909 942 } 910 943 … … 996 1029 // catch statements introduce a level of scope (for the caught exception) 997 1030 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 998 indexerAddWith( node );1031 indexerAddWith( node->exprs ); 999 1032 maybeAccept_impl( node->stmt, *this ); 1000 1033 } … … 1009 1042 // catch statements introduce a level of scope (for the caught exception) 1010 1043 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1011 indexerAddWith( node );1044 indexerAddWith( node->exprs ); 1012 1045 maybeMutate_impl( node->stmt, *this ); 1013 1046 } -
src/Common/PassVisitor.proto.h
rd0a045c7 r85521c7 202 202 static inline void indexer_impl_##func ( pass_type &, long, type ) { } \ 203 203 204 INDEXER_FUNC( addId , DeclarationWithType * );205 INDEXER_FUNC( addType , NamedTypeDecl * );206 INDEXER_FUNC( addStruct , StructDecl * );207 INDEXER_FUNC( addEnum , EnumDecl * );208 INDEXER_FUNC( addUnion , UnionDecl * );209 INDEXER_FUNC( addTrait , TraitDecl * );210 INDEXER_FUNC( addWith , WithStmt *);204 INDEXER_FUNC( addId , DeclarationWithType * ); 205 INDEXER_FUNC( addType , NamedTypeDecl * ); 206 INDEXER_FUNC( addStruct , StructDecl * ); 207 INDEXER_FUNC( addEnum , EnumDecl * ); 208 INDEXER_FUNC( addUnion , UnionDecl * ); 209 INDEXER_FUNC( addTrait , TraitDecl * ); 210 INDEXER_FUNC( addWith , std::list< Expression * > & ); 211 211 212 212
Note:
See TracChangeset
for help on using the changeset viewer.