Changeset 8c63bb4
- Timestamp:
- Aug 9, 2019, 11:09:38 PM (5 years ago)
- 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:
- 98399b2
- Parents:
- 4615ac8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/cfa.cc
r4615ac8 r8c63bb4 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 10 08:28:09201913 // Update Count : 28112 // Last Modified On : Fri Aug 9 18:51:44 2019 13 // Update Count : 309 14 14 // 15 15 … … 20 20 #include <string> // STL version 21 21 #include <string.h> // strcmp 22 #include <algorithm> // find 22 23 23 24 #include <sys/types.h> … … 26 27 #include "Common/SemanticError.h" 27 28 #include "config.h" // configure info 29 28 30 29 31 using std::cerr; … … 40 42 } // prefix 41 43 42 enum { NumSuffixes = 2 }; 43 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 44 45 bool suffix( string arg, const char * args[], int & nargs ) { 44 bool suffix( string arg ) { 45 enum { NumSuffixes = 3 }; 46 static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" }; 46 47 //std::cerr << arg << std::endl; 47 48 size_t dot = arg.find_last_of( "." ); 48 49 //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl; 49 50 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; 61 53 } // suffix 62 54 63 55 64 void shuffle( const char * args[], int S, int E, int N ) {56 void shuffle( const char * args[], int S, int E, int N ) { 65 57 // S & E index 1 passed the end so adjust with -1 66 58 #ifdef __DEBUG_H__ … … 75 67 } // shuffle 76 68 77 static inline bool dirExists( const string & path) {69 static inline bool dirExists( const string & path ) { 78 70 struct stat info; 79 71 if(stat( path.c_str(), &info ) != 0) … … 88 80 #define str(s) #s 89 81 90 int main( int argc, char * argv[] ) {82 int main( int argc, char * argv[] ) { 91 83 string Version( CFA_VERSION_LONG ); // current version number from CONFIG 92 84 string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) ); … … 104 96 string compiler_name; // name of C compiler 105 97 98 bool suffixp = false; // -x flag 106 99 bool nonoptarg = false; // indicates non-option argument specified 107 100 bool link = true; // linking as well as compiling 108 101 bool verbose = false; // -v flag 109 bool quiet = false; // -quiet flag110 bool debug = true; // -debug flag111 bool nolib = false; // -nolib flag112 bool help = false; // -help flag102 bool quiet = false; // -quiet flag 103 bool debug = true; // -debug flag 104 bool nolib = false; // -nolib flag 105 bool help = false; // -help flag 113 106 bool CFA_flag = false; // -CFA flag 114 107 bool cpp_flag = false; // -E or -M flag, preprocessor only … … 116 109 bool noincstd_flag = false; // -no-include-stdhdr= flag 117 110 bool debugging __attribute(( unused )) = false; // -g flag 118 bool m32 = false; 119 bool m64 = false; 111 bool m32 = false; // -m32 flag 112 bool m64 = false; // -m64 flag 120 113 bool intree = false; 121 114 … … 207 200 args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp 208 201 nargs += 1; 202 } else if ( prefix( arg, "-x" ) ) { // file suffix ? 203 string lang; 204 args[nargs] = argv[i]; // pass the argument along 205 nargs += 1; 206 if ( arg.length() == 2 ) { // separate argument ? 207 i += 1; 208 if ( i == argc ) continue; // next argument available ? 209 lang = argv[i]; 210 args[nargs] = argv[i]; // pass the argument along 211 nargs += 1; 212 } else { 213 lang = arg.substr( 2 ); 214 } // if 215 suffixp = lang != "none"; 209 216 } else if ( prefix( arg, "-W" ) ) { // check before next tests 210 217 if ( arg == "-Werror" || arg == "-Wall" ) { … … 283 290 } // if 284 291 } else { 285 bool cfa = suffix( arg, args, nargs ); // check suffix 292 bool cfa = suffix( arg ); // check suffix 293 if ( ! suffixp && cfa ) { // no explicit suffix and cfa suffix ? 294 args[nargs] = "-x"; 295 nargs += 1; 296 args[nargs] = "c"; 297 nargs += 1; 298 } // if 286 299 args[nargs] = argv[i]; // concatenate file 287 300 nargs += 1; 288 if ( cfa ) {301 if ( ! suffixp && cfa ) { // no explicit suffix and cfa suffix ? 289 302 args[nargs] = "-x"; 290 303 nargs += 1; … … 295 308 } // if 296 309 } // for 297 298 args[nargs] = "-x"; // turn off language299 nargs += 1;300 args[nargs] = "none";301 nargs += 1;302 310 303 311 #ifdef __x86_64__
Note: See TracChangeset
for help on using the changeset viewer.