Changeset dffaeac
- Timestamp:
- Jul 13, 2018, 6:34:11 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 6b8b767
- Parents:
- 26ef3b2
- Location:
- src/driver
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/driver/cc1.cc
r26ef3b2 rdffaeac 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 12 16:11:53201813 // Update Count : 9412 // Last Modified On : Fri Jul 13 17:40:10 2018 13 // Update Count : 110 14 14 // 15 15 … … 44 44 } // prefix 45 45 46 enum { NumSuffixes = 2 }; 47 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 48 49 bool suffix( string arg ) { 50 //std::cerr << arg << std::endl; 51 size_t dot = arg.find_last_of( "." ); 52 //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl; 53 if ( dot == string::npos ) return false; 54 string sx = arg.substr( dot + 1 ); 55 for ( int i = 0; i < NumSuffixes; i += 1 ) { 56 if ( sx == suffixes[i] ) return true; 57 } // for 58 return false; 59 } // suffix 60 46 61 47 62 void checkEnv( const char *args[], int &nargs ) { … … 51 66 if ( value != NULL ) { 52 67 compiler_name = value; 53 #ifdef __DEBUG_H__68 #ifdef __DEBUG_H__ 54 69 cerr << "env arg:\"" << compiler_name << "\"" << endl; 55 #endif // __DEBUG_H__70 #endif // __DEBUG_H__ 56 71 } // if 57 72 … … 59 74 if ( value != NULL ) { 60 75 args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along 61 #ifdef __DEBUG_H__76 #ifdef __DEBUG_H__ 62 77 cerr << "env arg:\"" << args[nargs] << "\"" << endl; 63 #endif // __DEBUG_H__78 #endif // __DEBUG_H__ 64 79 nargs += 1; 65 80 } // if … … 68 83 if ( value != NULL ) { 69 84 args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along 70 #ifdef __DEBUG_H__85 #ifdef __DEBUG_H__ 71 86 cerr << "env arg:\"" << args[nargs] << "\"" << endl; 72 #endif // __DEBUG_H__87 #endif // __DEBUG_H__ 73 88 nargs += 1; 74 89 } // if … … 115 130 signal( SIGTERM, sigTermHandler ); 116 131 117 #ifdef __DEBUG_H__132 #ifdef __DEBUG_H__ 118 133 cerr << "Stage1" << endl; 119 #endif // __DEBUG_H__134 #endif // __DEBUG_H__ 120 135 121 136 // process all the arguments … … 124 139 125 140 for ( i = 1; i < argc; i += 1 ) { 126 #ifdef __DEBUG_H__141 #ifdef __DEBUG_H__ 127 142 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 128 #endif // __DEBUG_H__143 #endif // __DEBUG_H__ 129 144 arg = argv[i]; 130 #ifdef __DEBUG_H__145 #ifdef __DEBUG_H__ 131 146 cerr << "arg:\"" << arg << "\"" << endl; 132 #endif // __DEBUG_H__147 #endif // __DEBUG_H__ 133 148 if ( prefix( arg, "-" ) ) { 134 149 // strip g++ flags that are inappropriate or cause duplicates in subsequent passes … … 164 179 ncargs += 1; 165 180 i += 1; // and the argument 166 } else if ( prefix( arg, D__GCC_X__ ) ) {167 args[nargs] = "-x";168 nargs += 1;169 args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along170 nargs += 1;171 } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) {172 args[nargs] = "-x";173 nargs += 1;174 args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along175 nargs += 1;176 i += 1; // and the argument181 // } else if ( prefix( arg, D__GCC_X__ ) ) { 182 // args[nargs] = "-x"; 183 // nargs += 1; 184 // args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along 185 // nargs += 1; 186 // } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) { 187 // args[nargs] = "-x"; 188 // nargs += 1; 189 // args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along 190 // nargs += 1; 191 // i += 1; // and the argument 177 192 } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) { 178 193 bprefix = arg.substr( D__GCC_BPREFIX__.size() ); … … 196 211 args[nargs] = argv[i]; // pass the argument along 197 212 nargs += 1; 198 #ifdef __DEBUG_H__213 #ifdef __DEBUG_H__ 199 214 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 200 #endif // __DEBUG_H__215 #endif // __DEBUG_H__ 201 216 } else if ( arg == "-MD" || arg == "-MMD" ) { 202 217 args[nargs] = "-MF"; // insert before file … … 205 220 args[nargs] = argv[i]; // pass the argument along 206 221 nargs += 1; 207 #ifdef __DEBUG_H__222 #ifdef __DEBUG_H__ 208 223 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 209 #endif // __DEBUG_H__224 #endif // __DEBUG_H__ 210 225 } // if 211 226 } // if … … 213 228 if ( cpp_in == NULL ) { 214 229 cpp_in = argv[i]; 215 #ifdef __DEBUG_H__230 #ifdef __DEBUG_H__ 216 231 cerr << "cpp_in:\"" << cpp_in << "\"" << endl; 217 #endif // __DEBUG_H__232 #endif // __DEBUG_H__ 218 233 } else if ( cpp_out == NULL ) { 219 234 cpp_out = argv[i]; 220 #ifdef __DEBUG_H__235 #ifdef __DEBUG_H__ 221 236 cerr << "cpp_out:\"" << cpp_out << "\""<< endl; 222 #endif // __DEBUG_H__237 #endif // __DEBUG_H__ 223 238 } else { 224 239 cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl; … … 228 243 } // for 229 244 230 #ifdef __DEBUG_H__245 #ifdef __DEBUG_H__ 231 246 cerr << "args:"; 232 247 for ( i = 1; i < nargs; i += 1 ) { … … 236 251 if ( cpp_out != NULL ) cerr << " " << cpp_out; 237 252 cerr << endl; 238 #endif // __DEBUG_H__253 #endif // __DEBUG_H__ 239 254 240 255 if ( cpp_in == NULL ) { … … 258 273 args[nargs] = NULL; // terminate argument list 259 274 260 #ifdef __DEBUG_H__275 #ifdef __DEBUG_H__ 261 276 cerr << "nargs: " << nargs << endl; 262 277 for ( i = 0; args[i] != NULL; i += 1 ) { … … 264 279 } // for 265 280 cerr << endl; 266 #endif // __DEBUG_H__281 #endif // __DEBUG_H__ 267 282 268 283 execvp( args[0], (char *const *)args ); // should not return … … 279 294 } // if 280 295 281 #ifdef __DEBUG_H__296 #ifdef __DEBUG_H__ 282 297 cerr << "tmpname:" << tmpname << " tmpfilefd:" << tmpfilefd << endl; 283 #endif // __DEBUG_H__298 #endif // __DEBUG_H__ 284 299 285 300 // Run the C preprocessor and save the output in tmpfile. … … 295 310 296 311 args[0] = compiler_name.c_str(); 312 if ( suffix( cpp_in ) ) { 313 args[nargs] = "-x"; 314 nargs += 1; 315 args[nargs] = "c"; 316 nargs += 1; 317 } // if 297 318 args[nargs] = cpp_in; // input to cpp 298 319 nargs += 1; 299 320 args[nargs] = NULL; // terminate argument list 300 321 301 #ifdef __DEBUG_H__322 #ifdef __DEBUG_H__ 302 323 cerr << "cpp nargs: " << nargs << endl; 303 324 for ( i = 0; args[i] != NULL; i += 1 ) { … … 305 326 } // for 306 327 cerr << endl; 307 #endif // __DEBUG_H__328 #endif // __DEBUG_H__ 308 329 309 330 execvp( args[0], (char *const *)args ); // should not return … … 314 335 wait( &code ); // wait for child to finish 315 336 316 #ifdef __DEBUG_H__337 #ifdef __DEBUG_H__ 317 338 cerr << "return code from cpp:" << WEXITSTATUS(code) << endl; 318 #endif // __DEBUG_H__339 #endif // __DEBUG_H__ 319 340 320 341 if ( WIFSIGNALED(code) != 0 ) { // child failed ? … … 352 373 cargs[ncargs] = NULL; // terminate argument list 353 374 354 #ifdef __DEBUG_H__375 #ifdef __DEBUG_H__ 355 376 cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl; 356 377 for ( i = 0; cargs[i] != NULL; i += 1 ) { … … 358 379 } // for 359 380 cerr << endl; 360 #endif // __DEBUG_H__381 #endif // __DEBUG_H__ 361 382 362 383 execvp( cargs[0], (char * const *)cargs ); // should not return … … 367 388 wait( &code ); // wait for child to finish 368 389 369 #ifdef __DEBUG_H__390 #ifdef __DEBUG_H__ 370 391 cerr << "return code from cfa-cpp:" << WEXITSTATUS(code) << endl; 371 #endif // __DEBUG_H__392 #endif // __DEBUG_H__ 372 393 373 394 // Must unlink here because file must exist across execvp. … … 393 414 int nargs = 1; // number of arguments in args list; 0 => command name 394 415 395 #ifdef __DEBUG_H__416 #ifdef __DEBUG_H__ 396 417 cerr << "Stage2" << endl; 397 #endif // __DEBUG_H__418 #endif // __DEBUG_H__ 398 419 399 420 // process all the arguments … … 402 423 403 424 for ( i = 1; i < argc; i += 1 ) { 404 #ifdef __DEBUG_H__425 #ifdef __DEBUG_H__ 405 426 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 406 #endif // __DEBUG_H__427 #endif // __DEBUG_H__ 407 428 arg = argv[i]; 408 #ifdef __DEBUG_H__429 #ifdef __DEBUG_H__ 409 430 cerr << "arg:\"" << arg << "\"" << endl; 410 #endif // __DEBUG_H__431 #endif // __DEBUG_H__ 411 432 if ( prefix( arg, "-" ) ) { 412 433 // strip inappropriate flags 413 434 414 435 if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" || 415 416 436 // Currently CFA does not suppose precompiled .h files. 437 prefix( arg, "--output-pch" ) ) { 417 438 418 439 // strip inappropriate flags with an argument … … 420 441 } else if ( arg == "-auxbase" || arg == "-auxbase-strip" || arg == "-dumpbase" ) { 421 442 i += 1; 422 #ifdef __DEBUG_H__443 #ifdef __DEBUG_H__ 423 444 cerr << "arg:\"" << argv[i] << "\"" << endl; 424 #endif // __DEBUG_H__445 #endif // __DEBUG_H__ 425 446 426 447 // all other flags … … 433 454 args[nargs] = argv[i]; // pass the argument along 434 455 nargs += 1; 435 #ifdef __DEBUG_H__456 #ifdef __DEBUG_H__ 436 457 cerr << "arg:\"" << argv[i] << "\"" << endl; 437 #endif // __DEBUG_H__458 #endif // __DEBUG_H__ 438 459 } // if 439 460 } // if … … 441 462 if ( cpp_in == NULL ) { 442 463 cpp_in = argv[i]; 443 #ifdef __DEBUG_H__464 #ifdef __DEBUG_H__ 444 465 cerr << "cpp_in:\"" << cpp_in << "\"" << endl; 445 #endif // __DEBUG_H__466 #endif // __DEBUG_H__ 446 467 } else { 447 468 cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl; … … 451 472 } // for 452 473 453 #ifdef __DEBUG_H__474 #ifdef __DEBUG_H__ 454 475 cerr << "args:"; 455 476 for ( i = 1; i < nargs; i += 1 ) { … … 458 479 cerr << endl; 459 480 if ( cpp_in != NULL ) cerr << " " << cpp_in; 460 #endif // __DEBUG_H__481 #endif // __DEBUG_H__ 461 482 462 483 args[0] = compiler_name.c_str(); … … 467 488 args[nargs] = NULL; // terminate argument list 468 489 469 #ifdef __DEBUG_H__490 #ifdef __DEBUG_H__ 470 491 cerr << "stage2 nargs: " << nargs << endl; 471 492 for ( i = 0; args[i] != NULL; i += 1 ) { … … 473 494 } // for 474 495 cerr << endl; 475 #endif // __DEBUG_H__496 #endif // __DEBUG_H__ 476 497 477 498 execvp( args[0], (char * const *)args ); // should not return … … 482 503 483 504 int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) { 484 #ifdef __DEBUG_H__505 #ifdef __DEBUG_H__ 485 506 for ( int i = 0; env[i] != NULL; i += 1 ) { 486 507 cerr << env[i] << endl; 487 508 } // for 488 #endif // __DEBUG_H__509 #endif // __DEBUG_H__ 489 510 490 511 string arg = argv[1]; -
src/driver/cfa.cc
r26ef3b2 rdffaeac 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 14 14:16:33201813 // Update Count : 2 4412 // Last Modified On : Fri Jul 13 17:40:12 2018 13 // Update Count : 258 14 14 // 15 15 … … 37 37 } // prefix 38 38 39 enum { NumSuffixes = 2 }; 40 const string suffixes[NumSuffixes] = { "cfa", "hfa", }; 41 42 bool suffix( string arg ) { 43 //std::cerr << arg << std::endl; 44 size_t dot = arg.find_last_of( "." ); 45 //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl; 46 if ( dot == string::npos ) return false; 47 string sx = arg.substr( dot + 1 ); 48 for ( int i = 0; i < NumSuffixes; i += 1 ) { 49 if ( sx == suffixes[i] ) return true; 50 } // for 51 return false; 52 } // suffix 53 39 54 40 55 void shuffle( const char *args[], int S, int E, int N ) { 41 56 // S & E index 1 passed the end so adjust with -1 42 #ifdef __DEBUG_H__57 #ifdef __DEBUG_H__ 43 58 cerr << "shuffle:" << S << " " << E << " " << N << endl; 44 #endif // __DEBUG_H__59 #endif // __DEBUG_H__ 45 60 for ( int j = E-1 + N; j > S-1 + N; j -=1 ) { 46 #ifdef __DEBUG_H__61 #ifdef __DEBUG_H__ 47 62 cerr << "\t" << j << " " << j-N << endl; 48 #endif // __DEBUG_H__63 #endif // __DEBUG_H__ 49 64 args[j] = args[j-N]; 50 65 } // for … … 79 94 bool std_flag = false; // -std= flag 80 95 bool noincstd_flag = false; // -no-include-stdhdr= flag 96 bool xflag = false; // user supplied -x flag 81 97 bool debugging __attribute(( unused )) = false; // -g flag 82 98 … … 88 104 int nlibs = 0; 89 105 90 #ifdef __DEBUG_H__106 #ifdef __DEBUG_H__ 91 107 cerr << "CFA:" << endl; 92 #endif // __DEBUG_H__108 #endif // __DEBUG_H__ 93 109 94 110 // process command-line arguments 95 111 96 112 for ( int i = 1; i < argc; i += 1 ) { 97 #ifdef __DEBUG_H__113 #ifdef __DEBUG_H__ 98 114 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; 99 #endif // __DEBUG_H__115 #endif // __DEBUG_H__ 100 116 arg = argv[i]; // convert to string value 101 #ifdef __DEBUG_H__117 #ifdef __DEBUG_H__ 102 118 cerr << "arg:\"" << arg << "\"" << endl; 103 #endif // __DEBUG_H__119 #endif // __DEBUG_H__ 104 120 if ( prefix( arg, "-" ) ) { 105 121 // pass through arguments … … 162 178 args[nargs] = argv[i]; // pass the argument along 163 179 nargs += 1; 164 } else if ( arg == "-x" ) { // lost so force along 180 } else if ( arg == "-x" ) { 181 xflag = true; 165 182 args[nargs] = argv[i]; // pass the argument along 166 183 nargs += 1; … … 168 185 args[nargs] = argv[i]; // pass the argument along 169 186 nargs += 1; 170 args[nargs] = ( *new string( string("-D__GCC_X__=") + argv[i] ) ).c_str(); // add the argument for -x 171 nargs += 1; 172 } else if ( prefix( arg, "-x" ) ) { // lost so force along 173 args[nargs] = argv[i]; // pass the argument along 174 nargs += 1; 175 args[nargs] = ( *new string( string("-D__GCC_X__=") + arg.substr(2) ) ).c_str(); // add the argument for -x 176 nargs += 1; 187 // args[nargs] = ( *new string( string("-D__GCC_X__=") + argv[i] ) ).c_str(); // add the argument for -x 188 // nargs += 1; 189 } else if ( prefix( arg, "-x" ) ) { 190 xflag = true; 191 args[nargs] = argv[i]; // pass the argument along 192 nargs += 1; 193 // args[nargs] = ( *new string( string("-D__GCC_X__=") + arg.substr(2) ) ).c_str(); // add the argument for -x 194 // nargs += 1; 177 195 } else if ( arg == "-w" ) { 178 196 args[nargs] = argv[i]; // pass the argument along … … 246 264 } // if 247 265 } else { 266 bool opt = false; 267 if ( ! xflag && suffix( arg ) ) { 268 args[nargs] = "-x"; 269 nargs += 1; 270 args[nargs] = "c"; 271 nargs += 1; 272 // args[nargs] = ( *new string( string("-D__GCC_X__=c") ) ).c_str(); // add the argument for -x 273 // nargs += 1; 274 opt = true; 275 } // if 248 276 // concatenate other arguments 249 277 args[nargs] = argv[i]; 250 278 nargs += 1; 279 if ( opt ) { 280 args[nargs] = "-x"; 281 nargs += 1; 282 args[nargs] = "none"; 283 nargs += 1; 284 // args[nargs] = ( *new string( string("-D__GCC_X__=none") ) ).c_str(); // add the argument for -x 285 // nargs += 1; 286 } // if 251 287 nonoptarg = true; 288 xflag = false; 252 289 } // if 253 290 } // for 254 291 255 #ifdef __x86_64__292 #ifdef __x86_64__ 256 293 args[nargs] = "-mcx16"; // allow double-wide CAA 257 294 nargs += 1; 258 #endif // __x86_64__259 260 #ifdef __DEBUG_H__295 #endif // __x86_64__ 296 297 #ifdef __DEBUG_H__ 261 298 cerr << "args:"; 262 299 for ( int i = 1; i < nargs; i += 1 ) { … … 264 301 } // for 265 302 cerr << endl; 266 #endif // __DEBUG_H__303 #endif // __DEBUG_H__ 267 304 268 305 if ( cpp_flag && CFA_flag ) { … … 283 320 nargs += 1; 284 321 285 #ifdef HAVE_LIBCFA322 #ifdef HAVE_LIBCFA 286 323 if ( link ) { 287 324 #if ! defined(HAVE_LIBCFA_RELEASE) 288 289 290 291 325 if ( ! debug ) { 326 cerr << "error: Option -nodebug is unavailable, libcfa was not installed." << endl; 327 exit( EXIT_FAILURE ); 328 } // if 292 329 #endif 293 330 #if ! defined(HAVE_LIBCFA_DEBUG) 294 295 296 297 331 if ( debug ) { 332 cerr << "error: Option -debug is unavailable, libcfa-d was not installed." << endl; 333 exit( EXIT_FAILURE ); 334 } // if 298 335 #endif 299 336 … … 323 360 nargs += 1; 324 361 } // if 325 #endif // HAVE_LIBCFA362 #endif // HAVE_LIBCFA 326 363 327 364 // Add exception flags (unconditionally) … … 419 456 args[nargs] = NULL; // terminate with NULL 420 457 421 #ifdef __DEBUG_H__458 #ifdef __DEBUG_H__ 422 459 cerr << "nargs: " << nargs << endl; 423 460 cerr << "args:" << endl; … … 425 462 cerr << " \"" << args[i] << "\"" << endl; 426 463 } // for 427 #endif // __DEBUG_H__464 #endif // __DEBUG_H__ 428 465 429 466 if ( ! quiet ) {
Note: See TracChangeset
for help on using the changeset viewer.