- Timestamp:
- Aug 12, 2019, 12:34:27 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:
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/cfa.cc
r14347ac ref46abb 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Feb 10 08:28:09201913 // Update Count : 28112 // Last Modified On : Sat Aug 10 08:44:15 2019 13 // Update Count : 311 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) … … 92 84 #define str(s) #s 93 85 94 int main( int argc, char * argv[] ) {86 int main( int argc, char * argv[] ) { 95 87 string Version( CFA_VERSION_LONG ); // current version number from CONFIG 96 88 string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) ); … … 108 100 string compiler_name; // name of C compiler 109 101 102 bool x_flag = false; // -x flag 110 103 bool nonoptarg = false; // indicates non-option argument specified 111 104 bool link = true; // linking as well as compiling 112 105 bool verbose = false; // -v flag 113 bool quiet = false; // -quiet flag114 bool debug = true; // -debug flag115 bool nolib = false; // -nolib flag116 bool help = false; // -help flag106 bool quiet = false; // -quiet flag 107 bool debug = true; // -debug flag 108 bool nolib = false; // -nolib flag 109 bool help = false; // -help flag 117 110 bool CFA_flag = false; // -CFA flag 118 111 bool cpp_flag = false; // -E or -M flag, preprocessor only … … 120 113 bool noincstd_flag = false; // -no-include-stdhdr= flag 121 114 bool debugging __attribute(( unused )) = false; // -g flag 122 bool m32 = false; 123 bool m64 = false; 115 bool m32 = false; // -m32 flag 116 bool m64 = false; // -m64 flag 124 117 bool intree = false; 125 118 bool disttree = false; … … 210 203 args[nargs] = argv[i]; // pass the argument along 211 204 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"; 212 219 } else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) { 213 220 std_flag = true; // -std=XX provided … … 295 302 } // if 296 303 } 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 298 311 args[nargs] = argv[i]; // concatenate file 299 312 nargs += 1; 300 if ( cfa ) {313 if ( ! x_flag && cfa ) { // no explicit suffix and cfa suffix ? 301 314 args[nargs] = "-x"; 302 315 nargs += 1;
Note: See TracChangeset
for help on using the changeset viewer.