Changes in src/Parser/DeclarationNode.cc [4eb3a7c5:5bf685f]
- File:
-
- 1 edited
-
src/Parser/DeclarationNode.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r4eb3a7c5 r5bf685f 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 23 18:25:57 202413 // Update Count : 1 53312 // Last Modified On : Thu Dec 14 19:05:17 2023 13 // Update Count : 1407 14 14 // 15 15 … … 159 159 160 160 if ( ! attributes.empty() ) { 161 os << string( indent + 2, ' ' ) << "with attributes " << endl;161 os << string( indent + 2, ' ' ) << "with attributes " << endl; 162 162 for ( ast::ptr<ast::Attribute> const & attr : reverseIterate( attributes ) ) { 163 os << string( indent + 4, ' ' ); 164 ast::print( os, attr, indent + 2 ); 163 os << string( indent + 4, ' ' ) << attr->name.c_str() << endl; 165 164 } // for 166 165 } // if … … 538 537 } // DeclarationNode::checkSpecifiers 539 538 540 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q , bool copyattr) {539 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 541 540 funcSpecs |= q->funcSpecs; 542 541 storageClasses |= q->storageClasses; 543 542 544 if ( copyattr ) { 545 std::vector<ast::ptr<ast::Attribute>> tmp; 546 tmp.reserve( q->attributes.size() ); 547 for ( auto const & attr : q->attributes ) { 548 tmp.emplace_back( ast::shallowCopy( attr.get() ) ); 549 } // for 550 spliceBegin( attributes, tmp ); 551 } // if 543 std::vector<ast::ptr<ast::Attribute>> tmp; 544 tmp.reserve( q->attributes.size() ); 545 for ( auto const & attr : q->attributes ) { 546 tmp.emplace_back( ast::shallowCopy( attr.get() ) ); 547 } 548 spliceBegin( attributes, tmp ); 552 549 553 550 return this; … … 684 681 } 685 682 686 DeclarationNode * DeclarationNode::addType( DeclarationNode * o , bool copyattr) {683 DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) { 687 684 if ( o ) { 688 685 checkSpecifiers( o ); 689 copySpecifiers( o , copyattr);686 copySpecifiers( o ); 690 687 if ( o->type ) { 691 688 if ( ! type ) { 692 689 if ( o->type->kind == TypeData::Aggregate || o->type->kind == TypeData::Enum ) { 693 // Hide type information aggregate instances.694 690 type = new TypeData( TypeData::AggregateInst ); 695 type->aggInst.aggregate = o->type; // change ownership 696 type->aggInst.aggregate->aggregate.attributes.swap( o->attributes ); // change ownership 691 type->aggInst.aggregate = o->type; 697 692 if ( o->type->kind == TypeData::Aggregate ) { 698 693 type->aggInst.hoistType = o->type->aggregate.body; … … 705 700 type = o->type; 706 701 } // if 707 o->type = nullptr; // change ownership702 o->type = nullptr; 708 703 } else { 709 704 addTypeToType( o->type, type ); … … 958 953 } 959 954 960 DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o , bool copyattr) {955 DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o ) { 961 956 if ( ! o ) return nullptr; 962 957 963 o->copySpecifiers( this , copyattr);958 o->copySpecifiers( this ); 964 959 if ( type ) { 965 960 TypeData * srcType = type; … … 1004 999 DeclarationNode * newnode = new DeclarationNode; 1005 1000 newnode->type = ret; 1006 if ( ret->kind == TypeData::Aggregate ) {1007 newnode->attributes.swap( ret->aggregate.attributes );1008 } // if1009 1001 return newnode; 1010 1002 } // if … … 1118 1110 if ( extr->type->kind == TypeData::Aggregate ) { 1119 1111 // typedef struct { int A } B is the only case? 1120 extracted_named = ! extr->type->aggregate.anon;1112 extracted_named = !extr->type->aggregate.anon; 1121 1113 } else if ( extr->type->kind == TypeData::Enum ) { 1122 1114 // typedef enum { A } B is the only case? 1123 extracted_named = ! extr->type->enumeration.anon;1115 extracted_named = !extr->type->enumeration.anon; 1124 1116 } else { 1125 1117 extracted_named = true;
Note:
See TracChangeset
for help on using the changeset viewer.