Changeset eef8dfb for src/main.cc
- Timestamp:
- Jan 7, 2021, 2:55:57 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 58fe85a
- Parents:
- bdfc032 (diff), 44e37ef (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
-
src/main.cc
rbdfc032 reef8dfb 9 9 // Author : Peter Buhr and Rob Schluntz 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Dec 16 17:55:53 201913 // Update Count : 6 2711 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Dec 7 15:29:00 2020 13 // Update Count : 639 14 14 // 15 15 … … 31 31 using namespace std; 32 32 33 33 #include "AST/Convert.hpp" 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 forceFillCodeLocations 42 43 #include "Common/CompilerError.h" // for CompilerError 43 44 #include "Common/Stats.h" … … 105 106 106 107 static void backtrace( int start ) { // skip first N stack frames 107 enum { Frames = 50 };108 enum { Frames = 50, }; // maximum number of stack frames 108 109 void * array[Frames]; 109 int size = ::backtrace( array, Frames );110 size_t size = ::backtrace( array, Frames ); 110 111 char ** messages = ::backtrace_symbols( array, size ); // does not demangle names 111 112 … … 114 115 115 116 // skip last 2 stack frames after main 116 for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {117 for ( unsigned int i = start; i < size - 2 && messages != nullptr; i += 1 ) { 117 118 char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr; 118 119 … … 180 181 } // sigSegvBusHandler 181 182 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 } // choose 194 cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl 195 << "Possible cause is constant-expression evaluation invalid." << endl; 196 backtrace( 2 ); // skip first 2 stack frames 197 abort(); // cause core dump for debugging 198 } // sigFpeHandler 199 182 200 static void sigAbortHandler( SIGPARMS ) { 183 201 backtrace( 6 ); // skip first 6 stack frames … … 193 211 Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO ); 194 212 Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO ); 213 Signal( SIGFPE, sigFpeHandler, SA_SIGINFO ); 195 214 Signal( SIGABRT, sigAbortHandler, SA_SIGINFO ); 196 215 … … 294 313 } // if 295 314 315 PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) ); 296 316 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 297 317 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); … … 321 341 } // if 322 342 323 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 324 if ( exprp ) { 325 dump( translationUnit ); 326 return EXIT_SUCCESS; 327 } // if 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 } 328 369 329 370 // fix ObjectDecl - replaces ConstructorInit nodes 330 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );331 371 if ( ctorinitp ) { 332 372 dump ( translationUnit ); … … 336 376 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 337 377 338 PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );378 PASS( "Translate Tries" , ControlStruct::translateTries( translationUnit ) ); 339 379 340 380 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) ); … … 425 465 426 466 427 static const char optstring[] = ":c:ghlLmNnp P:S:twW:D:";467 static const char optstring[] = ":c:ghlLmNnpdOAP:S:twW:D:"; 428 468 429 469 enum { PreludeDir = 128 }; … … 438 478 { "no-prelude", no_argument, nullptr, 'n' }, 439 479 { "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'}, 440 483 { "print", required_argument, nullptr, 'P' }, 441 484 { "prelude-dir", required_argument, nullptr, PreludeDir }, … … 449 492 450 493 static const char * description[] = { 451 "diagnostic color: never, always, or auto.", 452 "wait for gdb to attach", 453 "print help message", 454 "generate libcfa.c", 455 "generate line marks", 456 "do not replace main", 457 "do not generate line marks", 458 "do not read prelude", 494 "diagnostic color: never, always, or auto.", // -c 495 "wait for gdb to attach", // -g 496 "print help message", // -h 497 "generate libcfa.c", // -l 498 "generate line marks", // -L 499 "do not replace main", // -m 500 "do not generate line marks", // -N 501 "do not read prelude", // -n 459 502 "generate prototypes for prelude functions", // -p 460 "print", // -P 503 "only print deterministic output", // -d 504 "Use the old-ast", // -O 505 "Use the new-ast", // -A 506 "print", // -P 461 507 "<directory> prelude directory for debug/nodebug", // no flag 462 508 "<option-list> enable profiling information:\n counters,heap,time,all,none", // -S 463 "building cfa standard lib", 464 "", 465 "", 466 "", 509 "building cfa standard lib", // -t 510 "", // -w 511 "", // -W 512 "", // -D 467 513 }; // description 468 514 … … 562 608 genproto = true; 563 609 break; 610 case 'd': // don't print non-deterministic output 611 deterministic_output = true; 612 break; 613 case 'O': // don't print non-deterministic output 614 useNewAST = false; 615 break; 616 case 'A': // don't print non-deterministic output 617 useNewAST = true; 618 break; 564 619 case 'P': // print options 565 620 for ( int i = 0;; i += 1 ) {
Note:
See TracChangeset
for help on using the changeset viewer.