Changes in src/main.cc [f57faf6f:7006ba5]
- File:
-
- 1 edited
-
src/main.cc (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rf57faf6f r7006ba5 9 9 // Author : Peter Buhr and Rob Schluntz 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Dec 7 15:29:00 202013 // Update Count : 6 3911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 17:55:53 2019 13 // Update Count : 627 14 14 // 15 15 … … 31 31 using namespace std; 32 32 33 #include "AST/Convert.hpp" 33 34 34 #include "CompilationState.h" 35 35 #include "../config.h" // for CFA_LIBDIR … … 40 40 #include "CodeTools/ResolvProtoDump.h" // for dumpAsResolvProto 41 41 #include "CodeTools/TrackLoc.h" // for fillLocations 42 #include "Common/CodeLocationTools.hpp" // for forceFillCodeLocations43 42 #include "Common/CompilerError.h" // for CompilerError 44 43 #include "Common/Stats.h" … … 106 105 107 106 static void backtrace( int start ) { // skip first N stack frames 108 enum { Frames = 50 , }; // maximum number of stack frames107 enum { Frames = 50 }; 109 108 void * array[Frames]; 110 size_t size = ::backtrace( array, Frames );109 int size = ::backtrace( array, Frames ); 111 110 char ** messages = ::backtrace_symbols( array, size ); // does not demangle names 112 111 … … 115 114 116 115 // skip last 2 stack frames after main 117 for ( unsignedint i = start; i < size - 2 && messages != nullptr; i += 1 ) {116 for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) { 118 117 char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr; 119 118 … … 181 180 } // sigSegvBusHandler 182 181 183 static void sigFpeHandler( SIGPARMS ) {184 const char * msg;185 186 switch ( sfp->si_code ) {187 case FPE_INTDIV: case FPE_FLTDIV: msg = "divide by zero"; break;188 case FPE_FLTOVF: msg = "overflow"; break;189 case FPE_FLTUND: msg = "underflow"; break;190 case FPE_FLTRES: msg = "inexact result"; break;191 case FPE_FLTINV: msg = "invalid operation"; break;192 default: msg = "unknown";193 } // choose194 cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl195 << "Possible cause is constant-expression evaluation invalid." << endl;196 backtrace( 2 ); // skip first 2 stack frames197 abort(); // cause core dump for debugging198 } // sigFpeHandler199 200 182 static void sigAbortHandler( SIGPARMS ) { 201 183 backtrace( 6 ); // skip first 6 stack frames … … 211 193 Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO ); 212 194 Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO ); 213 Signal( SIGFPE, sigFpeHandler, SA_SIGINFO );214 195 Signal( SIGABRT, sigAbortHandler, SA_SIGINFO ); 215 196 … … 313 294 } // if 314 295 315 PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) );316 296 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 317 297 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); … … 341 321 } // if 342 322 343 if( useNewAST ) { 344 if (Stats::Counters::enabled) { 345 ast::pass_visitor_stats.avg = Stats::Counters::build<Stats::Counters::AverageCounter<double>>("Average Depth - New"); 346 ast::pass_visitor_stats.max = Stats::Counters::build<Stats::Counters::MaxCounter<double>>("Max depth - New"); 347 } 348 auto transUnit = convert( move( translationUnit ) ); 349 PASS( "Resolve", ResolvExpr::resolve( transUnit ) ); 350 if ( exprp ) { 351 translationUnit = convert( move( transUnit ) ); 352 dump( translationUnit ); 353 return EXIT_SUCCESS; 354 } // if 355 356 forceFillCodeLocations( transUnit ); 357 358 PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary())); 359 translationUnit = convert( move( transUnit ) ); 360 } else { 361 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 362 if ( exprp ) { 363 dump( translationUnit ); 364 return EXIT_SUCCESS; 365 } 366 367 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 368 } 323 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 324 if ( exprp ) { 325 dump( translationUnit ); 326 return EXIT_SUCCESS; 327 } // if 369 328 370 329 // fix ObjectDecl - replaces ConstructorInit nodes 330 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 371 331 if ( ctorinitp ) { 372 332 dump ( translationUnit ); … … 376 336 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 377 337 378 PASS( "Translate Tries" , ControlStruct::translateTries( translationUnit ) );338 PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) ); 379 339 380 340 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) ); … … 465 425 466 426 467 static const char optstring[] = ":c:ghlLmNnp dOAP:S:twW:D:";427 static const char optstring[] = ":c:ghlLmNnpP:S:twW:D:"; 468 428 469 429 enum { PreludeDir = 128 }; … … 478 438 { "no-prelude", no_argument, nullptr, 'n' }, 479 439 { "prototypes", no_argument, nullptr, 'p' }, 480 { "deterministic-out", no_argument, nullptr, 'd' },481 { "old-ast", no_argument, nullptr, 'O'},482 { "new-ast", no_argument, nullptr, 'A'},483 440 { "print", required_argument, nullptr, 'P' }, 484 441 { "prelude-dir", required_argument, nullptr, PreludeDir }, … … 492 449 493 450 static const char * description[] = { 494 "diagnostic color: never, always, or auto.", // -c495 "wait for gdb to attach", // -g496 "print help message", // -h497 "generate libcfa.c", // -l498 "generate line marks", // -L499 "do not replace main", // -m500 "do not generate line marks", // -N501 "do not read prelude", // -n451 "diagnostic color: never, always, or auto.", // -c 452 "wait for gdb to attach", // -g 453 "print help message", // -h 454 "generate libcfa.c", // -l 455 "generate line marks", // -L 456 "do not replace main", // -m 457 "do not generate line marks", // -N 458 "do not read prelude", // -n 502 459 "generate prototypes for prelude functions", // -p 503 "only print deterministic output", // -d 504 "Use the old-ast", // -O 505 "Use the new-ast", // -A 506 "print", // -P 460 "print", // -P 507 461 "<directory> prelude directory for debug/nodebug", // no flag 508 462 "<option-list> enable profiling information:\n counters,heap,time,all,none", // -S 509 "building cfa standard lib", // -t510 "", // -w511 "", // -W512 "", // -D463 "building cfa standard lib", // -t 464 "", // -w 465 "", // -W 466 "", // -D 513 467 }; // description 514 468 … … 608 562 genproto = true; 609 563 break; 610 case 'd': // don't print non-deterministic output611 deterministic_output = true;612 break;613 case 'O': // don't print non-deterministic output614 useNewAST = false;615 break;616 case 'A': // don't print non-deterministic output617 useNewAST = true;618 break;619 564 case 'P': // print options 620 565 for ( int i = 0;; i += 1 ) {
Note:
See TracChangeset
for help on using the changeset viewer.