Changeset af18713


Ignore:
Timestamp:
May 11, 2016, 1:09:37 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
228851d, 3e8fb3b
Parents:
cb4c607 (diff), 03e5d14 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rcb4c607 raf18713  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CodeGenerator.cc -- 
     7// CodeGenerator.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:32:16 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 15:40:35 2016
    1313// Update Count     : 243
    1414//
     
    7575        //*** Declarations
    7676        void CodeGenerator::visit( FunctionDecl *functionDecl ) {
     77                // generalize this
     78                FunctionDecl::Attribute attr = functionDecl->get_attribute();
     79                switch ( attr.type ) {
     80                        case FunctionDecl::Attribute::Constructor:
     81                                output << "__attribute__ ((constructor";
     82                                if ( attr.priority != FunctionDecl::Attribute::Default ) {
     83                                        output << "(" << attr.priority << ")";
     84                                }
     85                                output << ")) ";
     86                                break;
     87                        case FunctionDecl::Attribute::Destructor:
     88                                output << "__attribute__ ((destructor";
     89                                if ( attr.priority != FunctionDecl::Attribute::Default ) {
     90                                        output << "(" << attr.priority << ")";
     91                                }
     92                                output << ")) ";
     93                                break;
     94                        default:
     95                                break;
     96                }
    7797                handleStorageClass( functionDecl );
    7898                if ( functionDecl->get_isInline() ) {
     
    99119                handleStorageClass( objectDecl );
    100120                output << genType( objectDecl->get_type(), mangleName( objectDecl ) );
    101        
     121
    102122                if ( objectDecl->get_init() ) {
    103123                        output << " = ";
     
    113133                if ( aggDecl->get_name() != "" )
    114134                        output << aggDecl->get_name();
    115        
     135
    116136                std::list< Declaration * > &memb = aggDecl->get_members();
    117137
     
    119139                        output << " {" << endl;
    120140
    121                         cur_indent += CodeGenerator::tabsize; 
     141                        cur_indent += CodeGenerator::tabsize;
    122142                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    123                                 output << indent; 
     143                                output << indent;
    124144                                (*i)->accept( *this );
    125145                                output << ";" << endl;
    126146                        }
    127147
    128                         cur_indent -= CodeGenerator::tabsize; 
     148                        cur_indent -= CodeGenerator::tabsize;
    129149
    130150                        output << indent << "}";
     
    141161                handleAggregate( aggregateDecl );
    142162        }
    143  
     163
    144164        void CodeGenerator::visit( EnumDecl *aggDecl ) {
    145165                output << "enum ";
     
    147167                if ( aggDecl->get_name() != "" )
    148168                        output << aggDecl->get_name();
    149        
     169
    150170                std::list< Declaration* > &memb = aggDecl->get_members();
    151171
     
    153173                        output << " {" << endl;
    154174
    155                         cur_indent += CodeGenerator::tabsize; 
     175                        cur_indent += CodeGenerator::tabsize;
    156176                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    157177                                ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
    158178                                assert( obj );
    159                                 output << indent << mangleName( obj ); 
     179                                output << indent << mangleName( obj );
    160180                                if ( obj->get_init() ) {
    161181                                        output << " = ";
     
    165185                        } // for
    166186
    167                         cur_indent -= CodeGenerator::tabsize; 
     187                        cur_indent -= CodeGenerator::tabsize;
    168188
    169189                        output << indent << "}";
    170190                } // if
    171191        }
    172  
     192
    173193        void CodeGenerator::visit( TraitDecl *aggregateDecl ) {}
    174  
     194
    175195        void CodeGenerator::visit( TypedefDecl *typeDecl ) {
    176196                output << "typedef ";
    177197                output << genType( typeDecl->get_base(), typeDecl->get_name() );
    178198        }
    179  
     199
    180200        void CodeGenerator::visit( TypeDecl *typeDecl ) {
    181201                // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
     
    217237        }
    218238
    219         void CodeGenerator::visit( Constant *constant ) { 
     239        void CodeGenerator::visit( Constant *constant ) {
    220240                output << constant->get_value() ;
    221241        }
     
    234254                                                assert( arg != applicationExpr->get_args().end() );
    235255                                                if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
    236                
     256
    237257                                                        *arg = addrExpr->get_arg();
    238258                                                } else {
     
    243263                                                break;
    244264                                        }
    245              
     265
    246266                                  default:
    247267                                        // do nothing
    248268                                        ;
    249269                                }
    250            
     270
    251271                                switch ( opInfo.type ) {
    252272                                  case OT_INDEX:
     
    257277                                        output << "]";
    258278                                        break;
    259              
     279
    260280                                  case OT_CALL:
    261281                                        // there are no intrinsic definitions of the function call operator
    262282                                        assert( false );
    263283                                        break;
    264              
     284
    265285                                  case OT_PREFIX:
    266286                                  case OT_PREFIXASSIGN:
     
    271291                                        output << ")";
    272292                                        break;
    273              
     293
    274294                                  case OT_POSTFIX:
    275295                                  case OT_POSTFIXASSIGN:
     
    288308                                        output << ")";
    289309                                        break;
    290              
     310
    291311                                  case OT_CONSTANT:
    292312                                  case OT_LABELADDRESS:
     
    307327                } // if
    308328        }
    309  
     329
    310330        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
    311331                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
     
    321341                                        output << "]";
    322342                                        break;
    323              
     343
    324344                                  case OT_CALL:
    325345                                        assert( false );
    326346                                        break;
    327              
     347
    328348                                  case OT_PREFIX:
    329349                                  case OT_PREFIXASSIGN:
     
    335355                                        output << ")";
    336356                                        break;
    337              
     357
    338358                                  case OT_POSTFIX:
    339359                                  case OT_POSTFIXASSIGN:
     
    342362                                        output << opInfo.symbol;
    343363                                        break;
    344  
     364
    345365                                  case OT_INFIX:
    346366                                  case OT_INFIXASSIGN:
     
    352372                                        output << ")";
    353373                                        break;
    354                                        
     374
    355375                                  case OT_CONSTANT:
    356376                                        // there are no intrinsic definitions of 0 or 1 as functions
     
    370390                } // if
    371391        }
    372  
     392
    373393        void CodeGenerator::visit( NameExpr *nameExpr ) {
    374394                OperatorInfo opInfo;
     
    380400                } // if
    381401        }
    382  
     402
    383403        void CodeGenerator::visit( AddressExpr *addressExpr ) {
    384404                output << "(&";
     
    409429                output << ")";
    410430        }
    411  
     431
    412432        void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) {
    413433                assert( false );
    414434        }
    415  
     435
    416436        void CodeGenerator::visit( MemberExpr *memberExpr ) {
    417437                memberExpr->get_aggregate()->accept( *this );
    418438                output << "." << mangleName( memberExpr->get_member() );
    419439        }
    420  
     440
    421441        void CodeGenerator::visit( VariableExpr *variableExpr ) {
    422442                OperatorInfo opInfo;
     
    427447                } // if
    428448        }
    429  
     449
    430450        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    431451                assert( constantExpr->get_constant() );
    432452                constantExpr->get_constant()->accept( *this );
    433453        }
    434  
     454
    435455        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
    436456                output << "sizeof(";
     
    469489                assert( false && "OffsetPackExpr should not reach code generation" );
    470490        }
    471  
     491
    472492        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
    473493                output << "(";
     
    481501                output << ")";
    482502        }
    483  
     503
    484504        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
    485505                output << "(";
     
    491511                output << ")";
    492512        }
    493  
     513
    494514        void CodeGenerator::visit( CommaExpr *commaExpr ) {
    495515                output << "(";
     
    499519                output << ")";
    500520        }
    501  
     521
    502522        void CodeGenerator::visit( TupleExpr *tupleExpr ) {}
    503  
     523
    504524        void CodeGenerator::visit( TypeExpr *typeExpr ) {}
    505525
     
    532552                        }
    533553                }
    534                 cur_indent -= CodeGenerator::tabsize; 
     554                cur_indent -= CodeGenerator::tabsize;
    535555
    536556                output << indent << "}";
     
    538558
    539559        void CodeGenerator::visit( ExprStmt *exprStmt ) {
    540                 // I don't see why this check is necessary. 
    541                 // If this starts to cause problems then put it back in, 
     560                // I don't see why this check is necessary.
     561                // If this starts to cause problems then put it back in,
    542562                // with an explanation
    543563                assert( exprStmt );
     
    589609                switchStmt->get_condition()->accept( *this );
    590610                output << " ) ";
    591                
     611
    592612                output << "{" << std::endl;
    593613                cur_indent += CodeGenerator::tabsize;
     
    609629                } // if
    610630                output << ":\n";
    611                
     631
    612632                std::list<Statement *> sts = caseStmt->get_statements();
    613633
     
    626646                        if ( ! branchStmt->get_target().empty() )
    627647                                output << "goto " << branchStmt->get_target();
    628                         else { 
     648                        else {
    629649                                if ( branchStmt->get_computedTarget() != 0 ) {
    630650                                        output << "goto *";
     
    677697
    678698        void CodeGenerator::visit( ForStmt *forStmt ) {
    679                 // initialization is always hoisted, so don't 
    680                 // bother doing anything with that 
     699                // initialization is always hoisted, so don't
     700                // bother doing anything with that
    681701                output << "for (;";
    682702
     
    702722        void CodeGenerator::visit( DeclStmt *declStmt ) {
    703723                declStmt->get_decl()->accept( *this );
    704        
     724
    705725                if ( doSemicolon( declStmt->get_decl() ) ) {
    706726                        output << ";";
  • src/InitTweak/module.mk

    rcb4c607 raf18713  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Rob Schluntz
    13 ## Last Modified On : Mon Jan 11 14:40:16 2016
     13## Last Modified On : Wed May 04 16:03:49 2016
    1414## Update Count     : 2
    1515###############################################################################
    1616
    17 SRC += InitTweak/RemoveInit.cc
     17SRC += InitTweak/RemoveInit.cc \
     18        InitTweak/FixGlobalInit.cc
    1819
  • src/Makefile.in

    rcb4c607 raf18713  
    124124        GenPoly/driver_cfa_cpp-DeclMutator.$(OBJEXT) \
    125125        InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) \
     126        InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) \
    126127        Parser/driver_cfa_cpp-parser.$(OBJEXT) \
    127128        Parser/driver_cfa_cpp-lex.$(OBJEXT) \
     
    346347        GenPoly/CopyParams.cc GenPoly/FindFunction.cc \
    347348        GenPoly/DeclMutator.cc InitTweak/RemoveInit.cc \
    348         Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \
    349         Parser/ParseNode.cc Parser/DeclarationNode.cc \
    350         Parser/ExpressionNode.cc Parser/StatementNode.cc \
    351         Parser/InitializerNode.cc Parser/TypeData.cc \
    352         Parser/LinkageSpec.cc Parser/parseutility.cc Parser/Parser.cc \
     349        InitTweak/FixGlobalInit.cc Parser/parser.yy Parser/lex.ll \
     350        Parser/TypedefTable.cc Parser/ParseNode.cc \
     351        Parser/DeclarationNode.cc Parser/ExpressionNode.cc \
     352        Parser/StatementNode.cc Parser/InitializerNode.cc \
     353        Parser/TypeData.cc Parser/LinkageSpec.cc \
     354        Parser/parseutility.cc Parser/Parser.cc \
    353355        ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \
    354356        ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \
     
    562564        @: > InitTweak/$(DEPDIR)/$(am__dirstamp)
    563565InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT):  \
     566        InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)
     567InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT):  \
    564568        InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp)
    565569Parser/parser.h: Parser/parser.cc
     
    792796        -rm -f GenPoly/driver_cfa_cpp-ScrubTyVars.$(OBJEXT)
    793797        -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT)
     798        -rm -f InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT)
    794799        -rm -f InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT)
    795800        -rm -f Parser/driver_cfa_cpp-DeclarationNode.$(OBJEXT)
     
    897902@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-ScrubTyVars.Po@am__quote@
    898903@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@
     904@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po@am__quote@
    899905@AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po@am__quote@
    900906@AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-DeclarationNode.Po@am__quote@
     
    13801386@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi`
    13811387
     1388InitTweak/driver_cfa_cpp-FixGlobalInit.o: InitTweak/FixGlobalInit.cc
     1389@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc
     1390@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po
     1391@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.o' libtool=no @AMDEPBACKSLASH@
     1392@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1393@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc
     1394
     1395InitTweak/driver_cfa_cpp-FixGlobalInit.obj: InitTweak/FixGlobalInit.cc
     1396@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi`
     1397@am__fastdepCXX_TRUE@   $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po
     1398@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.obj' libtool=no @AMDEPBACKSLASH@
     1399@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1400@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi`
     1401
    13821402Parser/driver_cfa_cpp-parser.o: Parser/parser.cc
    13831403@am__fastdepCXX_TRUE@   $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parser.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parser.Tpo -c -o Parser/driver_cfa_cpp-parser.o `test -f 'Parser/parser.cc' || echo '$(srcdir)/'`Parser/parser.cc
  • src/SynTree/Declaration.h

    rcb4c607 raf18713  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Declaration.h -- 
     7// Declaration.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:28:11 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 15:39:02 2016
    1313// Update Count     : 33
    1414//
     
    106106        typedef DeclarationWithType Parent;
    107107  public:
    108         FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn );
     108        // temporary - merge this into general GCC attributes
     109        struct Attribute {
     110                enum Type {
     111                        NoAttribute, Constructor, Destructor,
     112                } type;
     113                enum Priority {
     114                        // priorities 0-100 are reserved by gcc, so it's okay to use 100 an exceptional case
     115                        Default = 100, High,
     116                } priority;
     117                Attribute(Type t = NoAttribute, Priority p = Default) : type(t), priority(p) {};
     118        };
     119
     120        FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = Attribute() );
    109121        FunctionDecl( const FunctionDecl &other );
    110122        virtual ~FunctionDecl();
     
    119131        std::list< std::string >& get_oldIdents() { return oldIdents; }
    120132        std::list< Declaration* >& get_oldDecls() { return oldDecls; }
     133        Attribute get_attribute() const { return attribute; }
     134        void set_attribute( Attribute newValue ) { attribute = newValue; }
    121135
    122136        virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
     
    130144        std::list< std::string > oldIdents;
    131145        std::list< Declaration* > oldDecls;
     146        Attribute attribute;
    132147};
    133148
  • src/SynTree/FunctionDecl.cc

    rcb4c607 raf18713  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FunctionDecl.cc -- 
     7// FunctionDecl.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 13 18:11:44 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 15:41:05 2016
    1313// Update Count     : 19
    1414//
     
    2121#include "Common/utility.h"
    2222
    23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )
    24                 : Parent( name, sc, linkage ), type( type ), statements( statements ) {
     23FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute )
     24                : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) {
    2525        set_isInline( isInline );
    2626        set_isNoreturn( isNoreturn );
     
    3232
    3333FunctionDecl::FunctionDecl( const FunctionDecl &other )
    34         : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     34        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) {
    3535}
    3636
     
    5252        using std::endl;
    5353        using std::string;
    54        
     54
    5555        if ( get_name() != "" ) {
    5656                os << get_name() << ": ";
     
    6565                os << "_Noreturn ";
    6666        } // if
     67        switch ( attribute.type ) {
     68                case Attribute::Constructor:
     69                        os << "Global Constructor ";
     70                        break;
     71                case Attribute::Destructor:
     72                        os << "Global Destructor ";
     73                        break;
     74                default:
     75                        break;
     76        }
     77        if ( attribute.priority != Attribute::Default ) {
     78                os << "with priority " << attribute.priority << " ";
     79        }
    6780        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    6881                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     
    94107        using std::endl;
    95108        using std::string;
    96        
     109
    97110        if ( get_name() != "" ) {
    98111                os << get_name() << ": ";
     
    104117                os << "_Noreturn ";
    105118        } // if
     119        switch ( attribute.type ) {
     120                case Attribute::Constructor:
     121                        os << " Global Constructor ";
     122                        break;
     123                case Attribute::Destructor:
     124                        os << " Global Destructor ";
     125                        break;
     126                default:
     127                        break;
     128        }
     129        if ( attribute.priority != Attribute::Default ) {
     130                os << "with priority " << attribute.priority << " ";
     131        }
    106132        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    107133                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
  • src/driver/cc1.cc

    rcb4c607 raf18713  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May  4 23:29:19 2016
    13 // Update Count     : 74
     12// Last Modified On : Thu May  5 16:04:30 2016
     13// Update Count     : 77
    1414//
    1515
     
    323323                cargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
    324324
    325                 // Source file-name without suffix used to generate routine names containing external initializations for TU.
    326                 string filename( cpp_in );
    327                 string::size_type posn = filename.find_last_of( "/" );
    328                 if ( posn != string::npos ) {
    329                         filename = filename.substr( posn + 1 );
    330                 } // if
    331                 posn = filename.find_last_of( "." );
    332                 if ( posn != string::npos ) {
    333                         filename = filename.substr( 0, posn );
    334                 } // if
     325                // Source file-name used to generate routine names containing global initializations for TU.
    335326                cargs[ncargs] = ( *new string( "-F" ) ).c_str();
    336327                ncargs += 1;
    337                 cargs[ncargs] = ( *new string( filename ) ).c_str();
     328                cargs[ncargs] = ( *new string( string( cpp_in ) ) ).c_str();
    338329                ncargs += 1;
    339330
  • src/main.cc

    rcb4c607 raf18713  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // main.cc -- 
     7// main.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May  4 23:32:59 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 06 15:29:42 2016
    1313// Update Count     : 203
    1414//
     
    4141#include "InitTweak/Mutate.h"
    4242#include "InitTweak/RemoveInit.h"
     43#include "InitTweak/FixGlobalInit.h"
    4344//#include "Explain/GenProlog.h"
    4445//#include "Try/Visit.h"
     
    9899        int long_index;
    99100        std::list< Declaration * > translationUnit;
    100         const char *filename = NULL;;
     101        const char *filename = NULL;
    101102
    102103        opterr = 0;                                                                                     // prevent getopt from printing error messages
    103        
     104
    104105        int c;
    105106        while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {
     
    180181                        input = fopen( argv[ optind ], "r" );
    181182                        if ( ! input ) {
    182                                 std::cout << "Error: can't open " << argv[optind] << std::endl;
     183                                std::cout << "Error: can't open " << argv[ optind ] << std::endl;
    183184                                exit( 1 );
    184185                        } // if
     186                        // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
     187                        if ( filename == NULL ) filename = argv[ optind ];
     188                        // prelude filename comes in differently
     189                        if ( libcfap ) filename = "prelude.cf";
    185190                        optind += 1;
    186191                } else {
     
    191196                        output = new ofstream( argv[ optind ] );
    192197                } // if
    193        
     198
    194199                Parser::get_parser().set_debug( grammarp );
    195200
     
    212217                                        exit( 1 );
    213218                                } // if
    214                    
     219
    215220                                parse( prelude, LinkageSpec::Intrinsic );
    216221                        } // if
    217222                } // if
    218223
    219                 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );     
    220  
     224                parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp );
     225
    221226                if ( parsep ) {
    222227                        Parser::get_parser().get_parseTree()->printList( std::cout );
     
    253258                OPTPRINT( "mutate" )
    254259                ControlStruct::mutate( translationUnit );
    255                 OPTPRINT( "fixNames" ) 
     260                OPTPRINT( "fixNames" )
    256261                CodeGen::fixNames( translationUnit );
     262                OPTPRINT( "fixGlobalInit" );
     263                InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep );
    257264                OPTPRINT( "tweak" )
    258265                InitTweak::tweak( translationUnit );
     
    282289                OPTPRINT( "box" )
    283290                GenPoly::box( translationUnit );
    284                
     291
    285292                // print tree right before code generation
    286293                if ( codegenp ) {
     
    338345        std::list< Declaration * > decls;
    339346        if ( noprotop ) {
    340                 filter( translationUnit.begin(), translationUnit.end(), 
     347                filter( translationUnit.begin(), translationUnit.end(),
    341348                                std::back_inserter( decls ), notPrelude );
    342349        } else {
Note: See TracChangeset for help on using the changeset viewer.