Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r4eb3a7c5 r5bf685f  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb 23 18:25:57 2024
    13 // Update Count     : 1533
     12// Last Modified On : Thu Dec 14 19:05:17 2023
     13// Update Count     : 1407
    1414//
    1515
     
    159159
    160160        if ( ! attributes.empty() ) {
    161                 os << string( indent + 2, ' ' ) << "with attributes" << endl;
     161                os << string( indent + 2, ' ' ) << "with attributes " << endl;
    162162                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;
    165164                } // for
    166165        } // if
     
    538537} // DeclarationNode::checkSpecifiers
    539538
    540 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q, bool copyattr ) {
     539DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) {
    541540        funcSpecs |= q->funcSpecs;
    542541        storageClasses |= q->storageClasses;
    543542
    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 );
    552549
    553550        return this;
     
    684681}
    685682
    686 DeclarationNode * DeclarationNode::addType( DeclarationNode * o, bool copyattr ) {
     683DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) {
    687684        if ( o ) {
    688685                checkSpecifiers( o );
    689                 copySpecifiers( o, copyattr );
     686                copySpecifiers( o );
    690687                if ( o->type ) {
    691688                        if ( ! type ) {
    692689                                if ( o->type->kind == TypeData::Aggregate || o->type->kind == TypeData::Enum ) {
    693                                         // Hide type information aggregate instances.
    694690                                        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;
    697692                                        if ( o->type->kind == TypeData::Aggregate ) {
    698693                                                type->aggInst.hoistType = o->type->aggregate.body;
     
    705700                                        type = o->type;
    706701                                } // if
    707                                 o->type = nullptr;                                              // change ownership
     702                                o->type = nullptr;
    708703                        } else {
    709704                                addTypeToType( o->type, type );
     
    958953}
    959954
    960 DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o, bool copyattr ) {
     955DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o ) {
    961956        if ( ! o ) return nullptr;
    962957
    963         o->copySpecifiers( this, copyattr );
     958        o->copySpecifiers( this );
    964959        if ( type ) {
    965960                TypeData * srcType = type;
     
    1004999                        DeclarationNode * newnode = new DeclarationNode;
    10051000                        newnode->type = ret;
    1006                         if ( ret->kind == TypeData::Aggregate ) {
    1007                                 newnode->attributes.swap( ret->aggregate.attributes );
    1008                         } // if
    10091001                        return newnode;
    10101002                } // if
     
    11181110                                        if ( extr->type->kind == TypeData::Aggregate ) {
    11191111                                                // typedef struct { int A } B is the only case?
    1120                                                 extracted_named = ! extr->type->aggregate.anon;
     1112                                                extracted_named = !extr->type->aggregate.anon;
    11211113                                        } else if ( extr->type->kind == TypeData::Enum ) {
    11221114                                                // typedef enum { A } B is the only case?
    1123                                                 extracted_named = ! extr->type->enumeration.anon;
     1115                                                extracted_named = !extr->type->enumeration.anon;
    11241116                                        } else {
    11251117                                                extracted_named = true;
Note: See TracChangeset for help on using the changeset viewer.