Changeset 37024fd for src


Ignore:
Timestamp:
May 6, 2016, 3:01:28 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
03e5d14
Parents:
9a92216
Message:

cleanup global init code, don't need to disambiguate with libcfa prefix

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r9a92216 r37024fd  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 11:39:01 2016
     12// Last Modified On : Fri May 06 14:57:16 2016
    1313// Update Count     : 243
    1414//
     
    7575        //*** Declarations
    7676        void CodeGenerator::visit( FunctionDecl *functionDecl ) {
    77                 handleStorageClass( functionDecl );
    78                 if ( functionDecl->get_isInline() ) {
    79                         output << "inline ";
    80                 } // if
    81                 if ( functionDecl->get_isNoreturn() ) {
    82                         output << "_Noreturn ";
    83                 } // if
    84                 output << genType( functionDecl->get_functionType(), mangleName( functionDecl ) );
    85 
    8677                // generalize this
    8778                switch ( functionDecl->get_attribute() ) {
    8879                        case FunctionDecl::Constructor:
    89                                 output << " __attribute__ ((constructor))";
     80                                output << "__attribute__ ((constructor)) ";
    9081                                break;
    9182                        case FunctionDecl::Destructor:
    92                                 output << " __attribute__ ((destructor))";
     83                                output << "__attribute__ ((destructor)) ";
    9384                                break;
    9485                        default:
    9586                                break;
    9687                }
     88                handleStorageClass( functionDecl );
     89                if ( functionDecl->get_isInline() ) {
     90                        output << "inline ";
     91                } // if
     92                if ( functionDecl->get_isNoreturn() ) {
     93                        output << "_Noreturn ";
     94                } // if
     95                output << genType( functionDecl->get_functionType(), mangleName( functionDecl ) );
    9796
    9897                // how to get this to the Functype?
  • src/InitTweak/FixGlobalInit.cc

    r9a92216 r37024fd  
    1010// Created On       : Mon May 04 15:14:56 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 13:51:00 2016
     12// Last Modified On : Fri May 06 14:59:26 2016
    1313// Update Count     : 2
    1414//
     
    3030        class GlobalFixer : public Visitor {
    3131          public:
    32                 GlobalFixer();
     32                GlobalFixer( const std::string & name );
    3333
    3434                virtual void visit( ObjectDecl *objDecl );
     
    4141
    4242                UniqueName tempNamer;
    43                 CompoundStmt * block;
     43                FunctionDecl * initFunction;
    4444        };
    4545
     
    8888
    8989        void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name ) {
    90                 GlobalFixer fixer;
     90                GlobalFixer fixer( name );
    9191                acceptAll( translationUnit, fixer );
    92                 // attribute only appears on the forward declaration, so need to make two function decls:
    93                 // one with the body, one with the attribute.
    94                 FunctionDecl * initFunction = new FunctionDecl( initName( name ), DeclarationNode::NoStorageClass, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), 0, false, false );
    95                 FunctionDecl * forward = initFunction->clone();
    96                 forward->set_attribute( FunctionDecl::Constructor );
    97                 initFunction->set_statements( fixer.block );
    98                 translationUnit.push_back( forward );
    99                 translationUnit.push_back( initFunction );
     92                translationUnit.push_back( fixer.initFunction );
    10093        }
    10194
     
    109102  }
    110103
    111         GlobalFixer::GlobalFixer() : tempNamer( "_global_init" ), block( new CompoundStmt( noLabels ) ) {
     104        GlobalFixer::GlobalFixer( const std::string & name ) : tempNamer( "_global_init" ) {
     105                initFunction = new FunctionDecl( initName( name ), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Constructor );
    112106        }
    113107
    114108        void GlobalFixer::visit( ObjectDecl *objDecl ) {
    115                 std::list< Statement * > & statements = block->get_kids();
     109                std::list< Statement * > & statements = initFunction->get_statements()->get_kids();
    116110
    117111                if ( objDecl->get_init() == NULL ) return;
  • src/main.cc

    r9a92216 r37024fd  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 14:20:26 2016
     12// Last Modified On : Fri May 06 14:56:40 2016
    1313// Update Count     : 203
    1414//
     
    186186                        // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
    187187                        if ( filename == NULL ) filename = argv[ optind ];
    188                         // prepend libcfa prefix to disambiguate library code from user programs
    189                         if ( libcfap ) {
    190                                 filename = "libcfa/prelude.cf";
    191                         } else if ( treep ) {
    192                                 filename = (*new string(string("libcfa/") + filename)).c_str();
    193                         }
     188                        // prelude filename comes in differently
     189                        if ( libcfap ) filename = "prelude.cf";
    194190                        optind += 1;
    195191                } else {
Note: See TracChangeset for help on using the changeset viewer.