Changeset 2d019af
- Timestamp:
- Mar 12, 2021, 11:14:29 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 41ca6fa, e867b44
- Parents:
- 6083392
- Location:
- src
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r6083392 r2d019af 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 09 15::37::05 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Nov 12 10:07:00 202013 // Update Count : 3 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:43:51 2021 13 // Update Count : 36 14 14 // 15 15 … … 327 327 const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final { 328 328 auto decl = new AsmDecl( get<AsmStmt>().accept1( node->stmt ) ); 329 declPostamble( decl, node ); 330 return nullptr; 331 } 332 333 const ast::DirectiveDecl * visit( const ast::DirectiveDecl * node ) override final { 334 auto decl = new DirectiveDecl( get<DirectiveStmt>().accept1( node->stmt ) ); 329 335 declPostamble( decl, node ); 330 336 return nullptr; … … 1769 1775 } 1770 1776 1777 virtual void visit( const DirectiveDecl * old ) override final { 1778 auto decl = new ast::DirectiveDecl{ 1779 old->location, 1780 GET_ACCEPT_1(stmt, DirectiveStmt) 1781 }; 1782 decl->extension = old->extension; 1783 decl->uniqueId = old->uniqueId; 1784 decl->storage = { old->storageClasses.val }; 1785 1786 this->node = decl; 1787 } 1788 1771 1789 virtual void visit( const StaticAssertDecl * old ) override final { 1772 1790 auto decl = new ast::StaticAssertDecl{ -
src/AST/Decl.hpp
r6083392 r2d019af 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 11 20:48:38202113 // Update Count : 3 012 // Last Modified On : Fri Mar 12 18:25:05 2021 13 // Update Count : 32 14 14 // 15 15 … … 365 365 }; 366 366 367 /// C-preprocessor directive `#...` 368 class DirectiveDecl : public Decl { 369 public: 370 ptr<DirectiveStmt> stmt; 371 372 DirectiveDecl( const CodeLocation & loc, DirectiveStmt * stmt ) 373 : Decl( loc, "", {}, {} ), stmt(stmt) {} 374 375 const DirectiveDecl * accept( Visitor & v ) const override { return v.visit( this ); } 376 private: 377 DirectiveDecl * clone() const override { return new DirectiveDecl( *this ); } 378 MUTATE_FRIEND 379 }; 380 367 381 class StaticAssertDecl : public Decl { 368 382 public: -
src/AST/Fwd.hpp
r6083392 r2d019af 9 9 // Author : Andrew Beach 10 10 // Created On : Wed May 8 16:05:00 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Jul 23 14:15:00 202013 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:37:39 2021 13 // Update Count : 4 14 14 // 15 15 … … 35 35 class TypedefDecl; 36 36 class AsmDecl; 37 class DirectiveDecl; 37 38 class StaticAssertDecl; 38 39 -
src/AST/Node.cpp
r6083392 r2d019af 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 16 14:16:00 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Jun 5 10:21:00 202013 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:25:06 2021 13 // Update Count : 2 14 14 // 15 15 … … 130 130 template class ast::ptr_base< ast::AsmDecl, ast::Node::ref_type::weak >; 131 131 template class ast::ptr_base< ast::AsmDecl, ast::Node::ref_type::strong >; 132 template class ast::ptr_base< ast::DirectiveDecl, ast::Node::ref_type::weak >; 133 template class ast::ptr_base< ast::DirectiveDecl, ast::Node::ref_type::strong >; 132 134 template class ast::ptr_base< ast::StaticAssertDecl, ast::Node::ref_type::weak >; 133 135 template class ast::ptr_base< ast::StaticAssertDecl, ast::Node::ref_type::strong >; -
src/AST/Pass.hpp
r6083392 r2d019af 139 139 const ast::Decl * visit( const ast::TypedefDecl * ) override final; 140 140 const ast::AsmDecl * visit( const ast::AsmDecl * ) override final; 141 const ast::DirectiveDecl * visit( const ast::DirectiveDecl * ) override final; 141 142 const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * ) override final; 142 143 const ast::CompoundStmt * visit( const ast::CompoundStmt * ) override final; -
src/AST/Pass.impl.hpp
r6083392 r2d019af 646 646 647 647 //-------------------------------------------------------------------------- 648 // DirectiveDecl 649 template< typename core_t > 650 const ast::DirectiveDecl * ast::Pass< core_t >::visit( const ast::DirectiveDecl * node ) { 651 VISIT_START( node ); 652 653 VISIT( 654 maybe_accept( node, &DirectiveDecl::stmt ); 655 ) 656 657 VISIT_END( DirectiveDecl, node ); 658 } 659 660 //-------------------------------------------------------------------------- 648 661 // StaticAssertDecl 649 662 template< typename core_t > -
src/AST/Print.cpp
r6083392 r2d019af 387 387 388 388 virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final { 389 safe_print( node->stmt ); 390 return node; 391 } 392 393 virtual const ast::DirectiveDecl * visit( const ast::DirectiveDecl * node ) override final { 389 394 safe_print( node->stmt ); 390 395 return node; -
src/AST/Visitor.hpp
r6083392 r2d019af 9 9 // Author : Andrew Beach 10 10 // Created On : Thr May 9 15:28:00 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr May 9 15:33:00 201913 // Update Count : 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:25:07 2021 13 // Update Count : 1 14 14 // 15 15 … … 31 31 virtual const ast::Decl * visit( const ast::TypedefDecl * ) = 0; 32 32 virtual const ast::AsmDecl * visit( const ast::AsmDecl * ) = 0; 33 virtual const ast::DirectiveDecl * visit( const ast::DirectiveDecl * ) = 0; 33 34 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * ) = 0; 34 35 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * ) = 0; -
src/CodeGen/CodeGenerator.cc
r6083392 r2d019af 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 08:32:48 202013 // Update Count : 53 212 // Last Modified On : Fri Mar 12 19:00:42 2021 13 // Update Count : 536 14 14 // 15 15 #include "CodeGenerator.h" … … 935 935 if ( asmStmt->get_instruction() ) asmStmt->get_instruction()->accept( *visitor ); 936 936 output << " )"; 937 } 938 939 void CodeGenerator::postvisit( DirectiveDecl * directiveDecl ) { 940 output << endl << directiveDecl->get_stmt()->directive; // endl prevents spaces before directive 937 941 } 938 942 -
src/CodeGen/CodeGenerator.h
r6083392 r2d019af 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 03:58:31 202013 // Update Count : 6 212 // Last Modified On : Fri Mar 12 18:35:38 2021 13 // Update Count : 63 14 14 // 15 15 … … 105 105 void postvisit( DirectiveStmt * ); 106 106 void postvisit( AsmDecl * ); // special: statement in declaration context 107 void postvisit( DirectiveDecl * ); // special: statement in declaration context 107 108 void postvisit( IfStmt * ); 108 109 void postvisit( SwitchStmt * ); -
src/Common/CodeLocationTools.cpp
r6083392 r2d019af 9 9 // Author : Andrew Beach 10 10 // Created On : Fri Dec 4 15:42:00 2020 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Dec 9 9:42:00 202013 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:35:37 2021 13 // Update Count : 2 14 14 // 15 15 … … 102 102 macro(TypedefDecl, Decl) \ 103 103 macro(AsmDecl, AsmDecl) \ 104 macro(DirectiveDecl, DirectiveDecl) \ 104 105 macro(StaticAssertDecl, StaticAssertDecl) \ 105 106 macro(CompoundStmt, CompoundStmt) \ -
src/Common/PassVisitor.h
r6083392 r2d019af 77 77 virtual void visit( AsmDecl * asmDecl ) override final; 78 78 virtual void visit( const AsmDecl * asmDecl ) override final; 79 virtual void visit( DirectiveDecl * directiveDecl ) override final; 80 virtual void visit( const DirectiveDecl * directiveDecl ) override final; 79 81 virtual void visit( StaticAssertDecl * assertDecl ) override final; 80 82 virtual void visit( const StaticAssertDecl * assertDecl ) override final; … … 261 263 virtual Declaration * mutate( TypedefDecl * typeDecl ) override final; 262 264 virtual AsmDecl * mutate( AsmDecl * asmDecl ) override final; 265 virtual DirectiveDecl * mutate( DirectiveDecl * directiveDecl ) override final; 263 266 virtual StaticAssertDecl * mutate( StaticAssertDecl * assertDecl ) override final; 264 267 -
src/Common/PassVisitor.impl.h
r6083392 r2d019af 973 973 974 974 //-------------------------------------------------------------------------- 975 // DirectiveDecl 976 template< typename pass_type > 977 void PassVisitor< pass_type >::visit( DirectiveDecl * node ) { 978 VISIT_START( node ); 979 980 maybeAccept_impl( node->stmt, *this ); 981 982 VISIT_END( node ); 983 } 984 985 template< typename pass_type > 986 void PassVisitor< pass_type >::visit( const DirectiveDecl * node ) { 987 VISIT_START( node ); 988 989 maybeAccept_impl( node->stmt, *this ); 990 991 VISIT_END( node ); 992 } 993 994 template< typename pass_type > 995 DirectiveDecl * PassVisitor< pass_type >::mutate( DirectiveDecl * node ) { 996 MUTATE_START( node ); 997 998 maybeMutate_impl( node->stmt, *this ); 999 1000 MUTATE_END( DirectiveDecl, node ); 1001 } 1002 1003 //-------------------------------------------------------------------------- 975 1004 // StaticAssertDecl 976 1005 template< typename pass_type > -
src/Parser/DeclarationNode.cc
r6083392 r2d019af 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 11 20:58:07 202113 // Update Count : 11 3712 // Last Modified On : Fri Mar 12 18:35:37 2021 13 // Update Count : 1141 14 14 // 15 15 … … 424 424 newnode->attributes.push_back( new Attribute( *name, exprs ) ); 425 425 delete name; 426 return newnode; 427 } 428 429 DeclarationNode * DeclarationNode::newDirectiveStmt( StatementNode * stmt ) { 430 DeclarationNode * newnode = new DeclarationNode; 431 newnode->directiveStmt = stmt; 426 432 return newnode; 427 433 } … … 1072 1078 return new AsmDecl( strict_dynamic_cast<AsmStmt *>( asmStmt->build() ) ); 1073 1079 } // if 1080 if ( directiveStmt ) { 1081 return new DirectiveDecl( strict_dynamic_cast<DirectiveStmt *>( directiveStmt->build() ) ); 1082 } // if 1074 1083 1075 1084 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { -
src/Parser/ParseNode.h
r6083392 r2d019af 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 3 18:23:01202113 // Update Count : 89 612 // Last Modified On : Fri Mar 12 15:19:04 2021 13 // Update Count : 897 14 14 // 15 15 … … 249 249 static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false ); 250 250 static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes 251 static DeclarationNode * newDirectiveStmt( StatementNode * stmt ); // gcc external directive statement 251 252 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement 252 253 static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message ); … … 345 346 std::string error; 346 347 StatementNode * asmStmt = nullptr; 348 StatementNode * directiveStmt = nullptr; 347 349 348 350 static UniqueName anonymous; -
src/Parser/parser.yy
r6083392 r2d019af 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 17 09:03:07202113 // Update Count : 472 212 // Last Modified On : Fri Mar 12 15:21:02 2021 13 // Update Count : 4728 14 14 // 15 15 … … 2639 2639 2640 2640 external_definition: 2641 declaration 2641 DIRECTIVE 2642 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); } 2643 | declaration 2642 2644 | external_function_definition 2643 2645 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown -
src/SynTree/Declaration.cc
r6083392 r2d019af 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 16:39:56 201913 // Update Count : 3 612 // Last Modified On : Fri Mar 12 18:35:39 2021 13 // Update Count : 37 14 14 // 15 15 … … 66 66 67 67 68 DirectiveDecl::DirectiveDecl( DirectiveStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) { 69 } 70 71 DirectiveDecl::DirectiveDecl( const DirectiveDecl &other ) : Declaration( other ), stmt( maybeClone( other.stmt ) ) { 72 } 73 74 DirectiveDecl::~DirectiveDecl() { 75 delete stmt; 76 } 77 78 void DirectiveDecl::print( std::ostream &os, Indenter indent ) const { 79 stmt->print( os, indent ); 80 } 81 82 void DirectiveDecl::printShort( std::ostream &os, Indenter indent ) const { 83 stmt->print( os, indent ); 84 } 85 86 68 87 StaticAssertDecl::StaticAssertDecl( Expression * condition, ConstantExpr * message ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), condition( condition ), message( message ) { 69 88 } -
src/SynTree/Declaration.h
r6083392 r2d019af 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 11 20:48:39202113 // Update Count : 15 812 // Last Modified On : Fri Mar 12 18:35:36 2021 13 // Update Count : 159 14 14 // 15 15 … … 400 400 }; 401 401 402 class DirectiveDecl : public Declaration { 403 public: 404 DirectiveStmt * stmt; 405 406 DirectiveDecl( DirectiveStmt * stmt ); 407 DirectiveDecl( const DirectiveDecl & other ); 408 virtual ~DirectiveDecl(); 409 410 DirectiveStmt * get_stmt() { return stmt; } 411 void set_stmt( DirectiveStmt * newValue ) { stmt = newValue; } 412 413 virtual DirectiveDecl * clone() const override { return new DirectiveDecl( *this ); } 414 virtual void accept( Visitor & v ) override { v.visit( this ); } 415 virtual void accept( Visitor & v ) const override { v.visit( this ); } 416 virtual DirectiveDecl * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 417 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 418 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override; 419 }; 420 402 421 class StaticAssertDecl : public Declaration { 403 422 public: -
src/SynTree/Mutator.h
r6083392 r2d019af 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:37:46 201913 // Update Count : 1 712 // Last Modified On : Fri Mar 12 18:35:36 2021 13 // Update Count : 18 14 14 // 15 15 #pragma once … … 34 34 virtual Declaration * mutate( TypedefDecl * typeDecl ) = 0; 35 35 virtual AsmDecl * mutate( AsmDecl * asmDecl ) = 0; 36 virtual DirectiveDecl * mutate( DirectiveDecl * directiveDecl ) = 0; 36 37 virtual StaticAssertDecl * mutate( StaticAssertDecl * assertDecl ) = 0; 37 38 -
src/SynTree/SynTree.h
r6083392 r2d019af 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:37:45 201913 // Update Count : 1 212 // Last Modified On : Fri Mar 12 18:56:44 2021 13 // Update Count : 13 14 14 // 15 15 … … 36 36 class TypedefDecl; 37 37 class AsmDecl; 38 class DirectiveDecl; 38 39 class StaticAssertDecl; 39 40 -
src/SynTree/Visitor.h
r6083392 r2d019af 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:21:49 201913 // Update Count : 1 412 // Last Modified On : Fri Mar 12 18:35:35 2021 13 // Update Count : 15 14 14 // 15 15 … … 45 45 virtual void visit( AsmDecl * node ) { visit( const_cast<const AsmDecl *>(node) ); } 46 46 virtual void visit( const AsmDecl * asmDecl ) = 0; 47 virtual void visit( DirectiveDecl * node ) { visit( const_cast<const DirectiveDecl *>(node) ); } 48 virtual void visit( const DirectiveDecl * directiveDecl ) = 0; 47 49 virtual void visit( StaticAssertDecl * node ) { visit( const_cast<const StaticAssertDecl *>(node) ); } 48 50 virtual void visit( const StaticAssertDecl * assertDecl ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.