Changeset d029162


Ignore:
Timestamp:
May 6, 2016, 2:07:41 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:
9a92216
Parents:
4e24610 (diff), 4acc87f (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' into global-init

Conflicts:

src/main.cc

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/driver/cc1.cc

    r4e24610 rd029162  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 25 16:05:15 2016
    13 // Update Count     : 56
     12// Last Modified On : Thu May  5 16:04:30 2016
     13// Update Count     : 77
    1414//
    1515
     
    108108        const char *args[argc + 100];                                           // leave space for 100 additional cpp command line values
    109109        int nargs = 1;                                                                          // number of arguments in args list; 0 => command name
    110         const char *uargs[20];                                                          // leave space for 20 additional cfa-cpp command line values
    111         int nuargs = 1;                                                                         // 0 => command name
     110        const char *cargs[20];                                                          // leave space for 20 additional cfa-cpp command line values
     111        int ncargs = 1;                                                                         // 0 => command name
    112112
    113113        signal( SIGINT,  sigTermHandler );
    114114        signal( SIGTERM, sigTermHandler );
     115
     116#ifdef __DEBUG_H__
     117        cerr << "Stage1" << endl;
     118#endif // __DEBUG_H__
    115119
    116120        // process all the arguments
     
    153157                                CFA_flag = true;
    154158                        } else if ( prefix( arg, D__CFA_FLAGPREFIX__ ) ) {
    155                                 uargs[nuargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
    156                                 nuargs += 1;
     159                                cargs[ncargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
     160                                ncargs += 1;
    157161                        } else if ( arg == "-D" && prefix( argv[i + 1], D__CFA_FLAGPREFIX__.substr(2) ) ) {
    158                                 uargs[nuargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str();
    159                                 nuargs += 1;
     162                                cargs[ncargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str();
     163                                ncargs += 1;
    160164                                i += 1;                                                                 // and the argument
    161165                        } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
     
    317321
    318322        if ( fork() == 0 ) {                                                            // child runs CFA
    319                 uargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
    320 
    321                 uargs[nuargs] = tmpname;
    322                 nuargs += 1;
     323                cargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
     324
     325                // Source file-name used to generate routine names containing global initializations for TU.
     326                cargs[ncargs] = ( *new string( "-F" ) ).c_str();
     327                ncargs += 1;
     328                cargs[ncargs] = ( *new string( string( cpp_in ) ) ).c_str();
     329                ncargs += 1;
     330
     331                cargs[ncargs] = tmpname;
     332                ncargs += 1;
    323333                if ( o_name != NULL ) {
    324                         uargs[nuargs] = o_name;
    325                         nuargs += 1;
     334                        cargs[ncargs] = o_name;
     335                        ncargs += 1;
    326336                } else if ( ! CFA_flag ) {                                              // run cfa-cpp ?
    327                         uargs[nuargs] = cpp_out;
    328                         nuargs += 1;
     337                        cargs[ncargs] = cpp_out;
     338                        ncargs += 1;
    329339                } // if
    330                 uargs[nuargs] = NULL;                                                   // terminate argument list
    331 
    332 #ifdef __DEBUG_H__
    333                 cerr << "cfa-cpp nuargs: " << o_name << " " << CFA_flag << " " << nuargs << endl;
    334                 for ( i = 0; uargs[i] != NULL; i += 1 ) {
    335                         cerr << uargs[i] << " ";
     340                cargs[ncargs] = NULL;                                                   // terminate argument list
     341
     342#ifdef __DEBUG_H__
     343                cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl;
     344                for ( i = 0; cargs[i] != NULL; i += 1 ) {
     345                        cerr << cargs[i] << " ";
    336346                } // for
    337347                cerr << endl;
    338348#endif // __DEBUG_H__
    339349
    340                 execvp( uargs[0], (char * const *)uargs );              // should not return
     350                execvp( cargs[0], (char * const *)cargs );              // should not return
    341351                perror( "CFA Translator error: cpp level, execvp" );
    342352                exit( EXIT_FAILURE );
     
    370380        const char *args[argc + 100];                                           // leave space for 100 additional cfa command line values
    371381        int nargs = 1;                                                                          // number of arguments in args list; 0 => command name
     382
     383#ifdef __DEBUG_H__
     384        cerr << "Stage2" << endl;
     385#endif // __DEBUG_H__
    372386
    373387        // process all the arguments
     
    467481
    468482        if ( arg == "-E" ) {
    469 #ifdef __DEBUG_H__
    470                 cerr << "Stage1" << endl;
    471 #endif // __DEBUG_H__
    472483                Stage1( argc, argv );
    473484        } else if ( arg == "-fpreprocessed" ) {
    474 #ifdef __DEBUG_H__
    475                 cerr << "Stage2" << endl;
    476 #endif // __DEBUG_H__
    477485                Stage2( argc, argv );
    478486        } else {
  • src/main.cc

    r4e24610 rd029162  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed May 04 16:54:52 2016
    13 // Update Count     : 199
     12// Last Modified On : Fri May 06 14:04:49 2016
     13// Update Count     : 203
    1414//
    1515
     
    9898        std::ostream *output = &std::cout;
    9999        int long_index;
    100         std::list< Declaration* > translationUnit;
     100        std::list< Declaration * > translationUnit;
     101        const char *filename = NULL;
    101102
    102103        opterr = 0;                                                                                     // prevent getopt from printing error messages
    103104
    104105        int c;
    105         while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     106        while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) {
    106107                switch ( c ) {
    107108                  case Ast:
     
    163164                        break;
    164165                  case 'D':                                                                             // ignore -Dxxx
     166                        break;
     167                  case 'F':                                                                             // source file-name without suffix
     168                        filename = optarg;
    165169                        break;
    166170                  case '?':
     
    173177
    174178        try {
    175                 std::string fileName;
    176 
    177179                // choose to read the program from a file or stdin
    178180                if ( optind < argc ) {
     
    182184                                exit( 1 );
    183185                        } // 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 ];
    184188                        optind += 1;
    185 
    186                         // assert( optind < argc );
    187                         fileName = argv[ optind-1 ]; // placeholder
    188                         // optind += 1;
    189189                } else {
    190190                        input = stdin;
     
    259259                CodeGen::fixNames( translationUnit );
    260260                OPTPRINT( "fixGlobalInit" );
    261                 InitTweak::fixGlobalInit( translationUnit, fileName );
     261                InitTweak::fixGlobalInit( translationUnit, filename );
    262262                OPTPRINT( "tweak" )
    263263                InitTweak::tweak( translationUnit );
Note: See TracChangeset for help on using the changeset viewer.