Changeset bbb1b35 for driver/cfa.cc


Ignore:
Timestamp:
Aug 23, 2019, 5:39:48 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
330d933
Parents:
ef22ad6
Message:

first attempt at -save-temp for cfa-cpp output, formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    ref22ad6 rbbb1b35  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 22 22:29:50 2019
    13 // Update Count     : 403
     12// Last Modified On : Fri Aug 23 16:27:07 2019
     13// Update Count     : 411
    1414//
    1515
     
    3939        static int flags = 0;                                                           // environment variables must have unique names
    4040
    41         if ( putenv( (char *)( *new string( string( "__CFA_FLAG" + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) != 0 ) {
     41        if ( putenv( (char *)( *new string( string( "__CFA_FLAG" + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) {
    4242                cerr << argv[0] << " error, cannot set environment variable." << endl;
    4343                exit( EXIT_FAILURE );
     
    8989
    9090        bool x_flag = false;                                                            // -x flag
    91         bool nonoptarg = false;                                                         // indicates non-option argument specified
    92         bool link = true;                                                                       // linking as well as compiling
     91        bool nonoptarg = false;                                                         // no non-option arguments specified, i.e., no file names
     92        bool link = true;                                                                       // link stage occurring
    9393        bool verbose = false;                                                           // -v flag
    9494        bool quiet = false;                                                                     // -quiet flag
     
    103103        bool m32 = false;                                                                       // -m32 flag
    104104        bool m64 = false;                                                                       // -m64 flag
    105         bool intree = false;
     105        bool intree = false;                                                            // build in tree
    106106        int o_file = 0;                                                                         // -o filename position
    107107
     
    176176                                debugging = true;                                               // symbolic debugging required
    177177                                args[nargs++] = argv[i];                                // pass argument along
     178                        } else if ( arg == "-save-temps" ) {
     179                                args[nargs++] = argv[i];                                // pass argument along
     180                                Putenv( argv, arg );                                    // save cfa-cpp output
    178181                        } else if ( prefix( arg, "-x" ) ) {                     // file suffix ?
    179182                                string lang;
     
    258261        #endif // __DEBUG_H__
    259262
    260         // if ( cpp_flag && CFA_flag ) {
    261         //      cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
    262         //      exit( EXIT_FAILURE );
    263         // } // if
     263        // -E flag stops at cc1 stage 1, so cfa-cpp in cc1 stage 2 is never executed.
     264        if ( cpp_flag && CFA_flag ) {
     265                cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
     266                exit( EXIT_FAILURE );
     267        } // if
    264268
    265269        // add the CFA include-library paths, which allow direct access to header files without directory qualification
     
    292296        } // if
    293297
    294         string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
     298        string arch( m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU) );
    295299        if ( ! m32 && ! m64 ) {
    296300                if ( arch == "x86" ) {
     
    301305        } // if
    302306
    303         string libdir = libbase + arch + "-" + (nolib ? "nolib" : (debug ? "debug": "nodebug"));
     307        string libdir( libbase + arch + "-" + (nolib ? "nolib" : (debug ? "debug": "nodebug")) );
    304308        if ( ! dirExists( libdir ) ) {
    305309                cerr << argv[0] << " internal error, cannot find prelude directory " << libdir << endl;
     
    350354                Putenv( argv, "-N" );
    351355                Putenv( argv, "-CFA" );
     356                // -CFA implies cc1 stage 2, but gcc does not pass the -o file to this stage because it believe the file is for
     357                // the linker. Hence, the -o file is explicit passed to cc1 stage 2 and used as cfa-cpp's output file.
    352358                if ( o_file ) Putenv( argv, string( "-o=" ) + argv[o_file] );
    353359        } else {
     
    401407        } // if
    402408
    403         args[nargs] = NULL;                                                                     // terminate
     409        args[nargs] = nullptr;                                                          // terminate
    404410
    405411        #ifdef __DEBUG_H__
    406412        cerr << "nargs: " << nargs << endl;
    407413        cerr << "args:" << endl;
    408         for ( int i = 0; args[i] != NULL; i += 1 ) {
     414        for ( int i = 0; args[i] != nullptr; i += 1 ) {
    409415                cerr << " \"" << args[i] << "\"" << endl;
    410416        } // for
     
    428434                if ( argc == 2 ) exit( EXIT_SUCCESS );                  // if only the -v flag is specified, do not invoke gcc
    429435
    430                 for ( int i = 0; args[i] != NULL; i += 1 ) {
     436                for ( int i = 0; args[i] != nullptr; i += 1 ) {
    431437                        cerr << args[i] << " ";
    432438                } // for
Note: See TracChangeset for help on using the changeset viewer.