Changeset ef46abb for driver


Ignore:
Timestamp:
Aug 12, 2019, 12:34:27 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
1ee048fd
Parents:
14347ac (diff), 4f5a8a2 (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 distcc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    r14347ac ref46abb  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Feb 10 08:28:09 2019
    13 // Update Count     : 281
     12// Last Modified On : Sat Aug 10 08:44:15 2019
     13// Update Count     : 311
    1414//
    1515
     
    2020#include <string>                                                                               // STL version
    2121#include <string.h>                                                                             // strcmp
     22#include <algorithm>                                                                    // find
    2223
    2324#include <sys/types.h>
     
    2627#include "Common/SemanticError.h"
    2728#include "config.h"                                                                             // configure info
     29
    2830
    2931using std::cerr;
     
    4042} // prefix
    4143
    42 enum { NumSuffixes = 2 };
    43 const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    44 
    45 bool suffix( string arg, const char * args[], int & nargs ) {
     44bool suffix( string arg ) {
     45        enum { NumSuffixes = 3 };
     46        static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
    4647        //std::cerr << arg << std::endl;
    4748        size_t dot = arg.find_last_of( "." );
    4849        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    4950        if ( dot == string::npos ) return false;
    50         string sx = arg.substr( dot + 1 );
    51         for ( int i = 0; i < NumSuffixes; i += 1 ) {
    52                 if ( sx == suffixes[i] ) {
    53                         args[nargs] = "-x";
    54                         nargs += 1;
    55                         args[nargs] = "c";
    56                         nargs += 1;
    57                         return true;
    58                 } // if
    59         } // for
    60         return false;
     51        const string * end = suffixes + NumSuffixes;
     52        return std::find( suffixes, end, arg.substr( dot + 1 ) ) != end;
    6153} // suffix
    6254
    6355
    64 void shuffle( const char *args[], int S, int E, int N ) {
     56void shuffle( const char * args[], int S, int E, int N ) {
    6557        // S & E index 1 passed the end so adjust with -1
    6658        #ifdef __DEBUG_H__
     
    7567} // shuffle
    7668
    77 static inline bool dirExists(const string & path) {
     69static inline bool dirExists( const string & path ) {
    7870    struct stat info;
    7971    if(stat( path.c_str(), &info ) != 0)
     
    9284#define str(s) #s
    9385
    94 int main( int argc, char *argv[] ) {
     86int main( int argc, char * argv[] ) {
    9587        string Version( CFA_VERSION_LONG );                                     // current version number from CONFIG
    9688        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
     
    108100        string compiler_name;                                                           // name of C compiler
    109101
     102        bool x_flag = false;                                                            // -x flag
    110103        bool nonoptarg = false;                                                         // indicates non-option argument specified
    111104        bool link = true;                                                                       // linking as well as compiling
    112105        bool verbose = false;                                                           // -v flag
    113         bool quiet = false;                                                             // -quiet flag
    114         bool debug = true;                                                              // -debug flag
    115         bool nolib = false;                                                             // -nolib flag
    116         bool help = false;                                                              // -help flag
     106        bool quiet = false;                                                                     // -quiet flag
     107        bool debug = true;                                                                      // -debug flag
     108        bool nolib = false;                                                                     // -nolib flag
     109        bool help = false;                                                                      // -help flag
    117110        bool CFA_flag = false;                                                          // -CFA flag
    118111        bool cpp_flag = false;                                                          // -E or -M flag, preprocessor only
     
    120113        bool noincstd_flag = false;                                                     // -no-include-stdhdr= flag
    121114        bool debugging __attribute(( unused )) = false;         // -g flag
    122         bool m32 = false;                                    // -m32 flag
    123         bool m64 = false;                                    // -m64 flag
     115        bool m32 = false;                                                                       // -m32 flag
     116        bool m64 = false;                                                                       // -m64 flag
    124117        bool intree = false;
    125118        bool disttree = false;
     
    210203                                args[nargs] = argv[i];                                  // pass the argument along
    211204                                nargs += 1;
     205                        } else if ( prefix( arg, "-x" ) ) {                     // file suffix ?
     206                                string lang;
     207                                args[nargs] = argv[i];                                  // pass the argument along
     208                                nargs += 1;
     209                                if ( arg.length() == 2 ) {                              // separate argument ?
     210                                        i += 1;
     211                                        if ( i == argc ) continue;                      // next argument available ?
     212                                        lang = argv[i];
     213                                        args[nargs] = argv[i];                          // pass the argument along
     214                                        nargs += 1;
     215                                } else {
     216                                        lang = arg.substr( 2 );
     217                                } // if
     218                                x_flag = lang != "none";
    212219                        } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
    213220                                std_flag = true;                                                // -std=XX provided
     
    295302                        } // if
    296303                } else {
    297                         bool cfa = suffix( arg, args, nargs );          // check suffix
     304                        bool cfa = suffix( arg );                                       // check suffix
     305                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
     306                                args[nargs] = "-x";
     307                                nargs += 1;
     308                                args[nargs] = "c";
     309                                nargs += 1;
     310                        } // if
    298311                        args[nargs] = argv[i];                                          // concatenate file
    299312                        nargs += 1;
    300                         if ( cfa ) {
     313                        if ( ! x_flag && cfa ) {                                        // no explicit suffix and cfa suffix ?
    301314                                args[nargs] = "-x";
    302315                                nargs += 1;
Note: See TracChangeset for help on using the changeset viewer.