Changeset 5407cdc for src/main.cc


Ignore:
Timestamp:
Apr 28, 2021, 4:56:50 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8d66610
Parents:
feacef9 (diff), b7fd2db6 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rfeacef9 r5407cdc  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb  8 21:10:16 2021
    13 // Update Count     : 642
     12// Last Modified On : Sat Mar  6 15:49:00 2021
     13// Update Count     : 656
    1414//
    1515
     
    101101static string PreludeDirector = "";
    102102
    103 static void parse_cmdline( int argc, char *argv[] );
     103static void parse_cmdline( int argc, char * argv[] );
    104104static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
    105105static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
     106static void dump( ast::TranslationUnit && transUnit, ostream & out = cout );
    106107
    107108static void backtrace( int start ) {                                    // skip first N stack frames
     
    158159#define SIGPARMS int sig __attribute__(( unused )), siginfo_t * sfp __attribute__(( unused )), ucontext_t * cxt __attribute__(( unused ))
    159160
    160 static void Signal( int sig, void (*handler)(SIGPARMS), int flags ) {
     161static void Signal( int sig, void (* handler)(SIGPARMS), int flags ) {
    161162        struct sigaction act;
    162163
     
    165166
    166167        if ( sigaction( sig, &act, nullptr ) == -1 ) {
    167             cerr << "*CFA runtime error* problem installing signal handler, error(" << errno << ") " << strerror( errno ) << endl;
     168            cerr << "*cfa-cpp compilation error* problem installing signal handler, error(" << errno << ") " << strerror( errno ) << endl;
    168169            _exit( EXIT_FAILURE );
    169170        } // if
     
    349350                        PASS( "Resolve", ResolvExpr::resolve( transUnit ) );
    350351                        if ( exprp ) {
    351                                 translationUnit = convert( move( transUnit ) );
    352                                 dump( translationUnit );
     352                                dump( move( transUnit ) );
    353353                                return EXIT_SUCCESS;
    354354                        } // if
     
    421421                        delete output;
    422422                } // if
    423         } catch ( SemanticErrorException &e ) {
     423        } catch ( SemanticErrorException & e ) {
    424424                if ( errorp ) {
    425425                        cerr << "---AST at error:---" << endl;
     
    432432                } // if
    433433                return EXIT_FAILURE;
    434         } catch ( UnimplementedError &e ) {
     434        } catch ( UnimplementedError & e ) {
    435435                cout << "Sorry, " << e.get_what() << " is not currently implemented" << endl;
    436436                if ( output != &cout ) {
     
    438438                } // if
    439439                return EXIT_FAILURE;
    440         } catch ( CompilerError &e ) {
     440        } catch ( CompilerError & e ) {
    441441                cerr << "Compiler Error: " << e.get_what() << endl;
    442442                cerr << "(please report bugs to [REDACTED])" << endl;
     
    445445                } // if
    446446                return EXIT_FAILURE;
     447        } catch ( std::bad_alloc & ) {
     448                cerr << "*cfa-cpp compilation error* std::bad_alloc" << endl;
     449                backtrace( 1 );
     450                abort();
    447451        } catch ( ... ) {
    448452                exception_ptr eptr = current_exception();
     
    451455                                rethrow_exception(eptr);
    452456                        } else {
    453                                 cerr << "Exception Uncaught and Unknown" << endl;
    454                         } // if
    455                 } catch(const exception& e) {
    456                         cerr << "Uncaught Exception \"" << e.what() << "\"\n";
     457                                cerr << "*cfa-cpp compilation error* exception uncaught and unknown" << endl;
     458                        } // if
     459                } catch( const exception & e ) {
     460                        cerr << "*cfa-cpp compilation error* uncaught exception \"" << e.what() << "\"\n";
    457461                } // try
    458462                return EXIT_FAILURE;
     
    544548enum { printoptsSize = sizeof( printopts ) / sizeof( printopts[0] ) };
    545549
    546 static void usage( char *argv[] ) {
     550static void usage( char * argv[] ) {
    547551    cout << "Usage: " << argv[0] << " [options] [input-file (default stdin)] [output-file (default stdout)], where options are:" << endl;
    548552        int i = 0, j = 1;                                                                       // j skips starting colon
     
    732736} // dump
    733737
     738static void dump( ast::TranslationUnit && transUnit, ostream & out ) {
     739        std::list< Declaration * > translationUnit = convert( move( transUnit ) );
     740        dump( translationUnit, out );
     741}
     742
    734743// Local Variables: //
    735744// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.