Changeset 0bf5340


Ignore:
Timestamp:
Sep 10, 2019, 9:01:32 AM (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:
216597d
Parents:
7c8246d
Message:

updates after code review, use suffix .ifa for cc1 stage1 temp-file

Location:
driver
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • driver/cc1.cc

    r7c8246d r0bf5340  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 30 15:36:42 2019
    13 // Update Count     : 377
     12// Last Modified On : Mon Sep  9 17:50:53 2019
     13// Update Count     : 384
    1414//
    1515
     
    5858
    5959
    60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );
     60static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "N__=" suffix
    6161
    6262static void checkEnv1( const char * args[], int & nargs ) { // stage 1
     
    7070
    7171                if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    72                         string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
     72                        string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    7373                        if ( prefix( val, "-compiler=" ) ) {
    7474                                compiler_path = val.substr( 10 );
     
    8989
    9090                if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    91                         string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
     91                        string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    9292                        if ( prefix( val, "-compiler=" ) ) {
    9393                                compiler_path = val.substr( 10 );
     
    101101                                bprefix = val.substr( 3 );
    102102                        } else {                                                                        // normal flag for cfa-cpp
    103                                 args[nargs++] = ( *new string( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ) ).c_str();
     103                                args[nargs++] = ( *new string( arg.substr( arg.find_first_of( "=" ) + 1 ) ) ).c_str();
    104104                        } // if
    105105                } // if
     
    108108
    109109
    110 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i";
     110static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa";
    111111static int tmpfilefd = -1;
    112112static bool startrm = false;
     
    414414                        } // if
    415415                } else {
    416                         tmpfilefd = mkstemps( tmpname, 2 );
     416                        tmpfilefd = mkstemps( tmpname, 4 );
    417417                        if ( tmpfilefd == -1 ) {
    418418                                perror( "CC1 Translator error: stage 2, mkstemp" );
     
    487487                args[0] = compiler_path.c_str();
    488488                args[nargs++] = "-S";                                                   // only compile and put assembler output in specified file
    489                 if ( save_temps ) {                                                             // make gcc accept .ifa suffix
    490                         args[nargs++] = "-x";
    491                         args[nargs++] = "cpp-output";
    492                 } // if
     489                args[nargs++] = "-x";
     490                args[nargs++] = "cpp-output";
     491
    493492                args[nargs++] = cfa_cpp_out.c_str();
    494493                args[nargs] = nullptr;                                                  // terminate argument list
     
    509508
    510509        wait( &code );                                                                          // wait for child to finish
     510        rmtmpfile();                                                                            // remove tmpname
    511511
    512512        if ( WIFSIGNALED(code) ) {                                                      // child failed ?
    513                 rmtmpfile();                                                                    // remove tmpname
    514513                cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;
    515514                exit( EXIT_FAILURE );
     
    520519        #endif // __DEBUG_H__
    521520
    522         rmtmpfile();                                                                            // remove tmpname
    523521        exit( WEXITSTATUS( code ) );                                            // stop regardless of success or failure
    524522} // Stage2
  • driver/cfa.cc

    r7c8246d r0bf5340  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 27 06:11:24 2019
    13 // Update Count     : 416
     12// Last Modified On : Mon Sep  9 17:57:40 2019
     13// Update Count     : 417
    1414//
    1515
     
    3636
    3737
     38static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "N__=" suffix
     39
    3840void Putenv( char * argv[], string arg ) {
    3941        static int flags = 0;                                                           // environment variables must have unique names
    4042
    41         if ( putenv( (char *)( *new string( string( "__CFA_FLAG" + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) {
     43        if ( putenv( (char *)( *new string( string( __CFA_FLAGPREFIX__ + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) {
    4244                cerr << argv[0] << " error, cannot set environment variable." << endl;
    4345                exit( EXIT_FAILURE );
Note: See TracChangeset for help on using the changeset viewer.