Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r6a625de r0689cd9  
    77// main.cc --
    88//
    9 // Author           : Peter Buhr and Rob Schluntz
     9// Author           : Richard C. Bilson
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May  3 16:10:52 2019
    13 // Update Count     : 599
     12// Last Modified On : Wed Dec 26 08:11:19 2018
     13// Update Count     : 499
    1414//
    1515
     
    2424#include <fstream>                          // for ofstream
    2525#include <iostream>                         // for operator<<, basic_ostream
    26 #include <iomanip>
    2726#include <iterator>                         // for back_inserter
    2827#include <list>                             // for list
     
    3837#include "CodeTools/TrackLoc.h"             // for fillLocations
    3938#include "Common/CompilerError.h"           // for CompilerError
    40 #include "Common/Stats.h"
     39#include "Common/Heap.h"
    4140#include "Common/PassVisitor.h"
    42 // #include "AST/Pass.hpp"
    4341#include "Common/SemanticError.h"           // for SemanticError
    4442#include "Common/UnimplementedError.h"      // for UnimplementedError
     
    6765using namespace std;
    6866
    69 static void NewPass( const char * const name ) {
    70         Stats::Heap::newPass( name );
    71         using namespace Stats::Counters;
    72         {
    73                 static auto group = build<CounterGroup>( "Pass Visitor" );
    74                 auto pass = build<CounterGroup>( name, group );
    75                 pass_visitor_stats.depth = 0;
    76                 pass_visitor_stats.avg = build<AverageCounter<double>>( "Average Depth", pass );
    77                 pass_visitor_stats.max = build<MaxCounter<double>>( "Max Depth", pass );
    78         }
    79         {
    80                 static auto group = build<CounterGroup>( "Syntax Node" );
    81                 auto pass = build<CounterGroup>( name, group );
    82                 BaseSyntaxNode::new_nodes = build<SimpleCounter>( "Allocs", pass );
    83         }
    84 }
    85 
    86 #define PASS( name, pass )                  \
     67#define PASS(name, pass)                   \
    8768        if ( errorp ) { cerr << name << endl; } \
    88         NewPass(name);                          \
    89         Stats::Time::StartBlock(name);          \
    90         pass;                                   \
    91         Stats::Time::StopBlock();
     69        HeapStats::newPass(name);               \
     70        pass;
    9271
    9372LinkageSpec::Spec linkage = LinkageSpec::Cforall;
     
    9574DeclarationNode * parseTree = nullptr;                                  // program parse tree
    9675
    97 static std::string PreludeDirector = "";
     76std::string PreludeDirector = "";
    9877
    9978static void parse_cmdline( int argc, char *argv[], const char *& filename );
     
    151130} // backtrace
    152131
    153 static void sigSegvBusHandler( int sig_num ) {
     132void sigSegvBusHandler( int sig_num ) {
    154133        cerr << "*CFA runtime error* program cfa-cpp terminated with "
    155134                 <<     (sig_num == SIGSEGV ? "segment fault" : "bus error")
     
    157136        backtrace( 2 );                                                                         // skip first 2 stack frames
    158137        //_exit( EXIT_FAILURE );
    159         abort();                                                                                        // cause core dump for debugging
     138        abort();
    160139} // sigSegvBusHandler
    161140
    162 static void sigAbortHandler( __attribute__((unused)) int sig_num ) {
     141void sigAbortHandler( __attribute__((unused)) int sig_num ) {
    163142        backtrace( 6 );                                                                         // skip first 6 stack frames
    164143        signal( SIGABRT, SIG_DFL);                                                      // reset default signal handler
    165                 raise( SIGABRT );                                                                       // reraise SIGABRT
     144    raise( SIGABRT );                                                                   // reraise SIGABRT
    166145} // sigAbortHandler
    167146
     
    169148int main( int argc, char * argv[] ) {
    170149        FILE * input;                                                                           // use FILE rather than istream because yyin is FILE
    171         ostream * output = & cout;
    172         const char * filename = nullptr;
     150        ostream *output = & cout;
     151        const char *filename = nullptr;
    173152        list< Declaration * > translationUnit;
    174153
     
    202181                } // if
    203182
    204                 Stats::Time::StartGlobal();
    205                 NewPass("Parse");
    206                 Stats::Time::StartBlock("Parse");
    207 
    208183                // read in the builtins, extras, and the prelude
    209184                if ( ! nopreludep ) {                                                   // include gcc builtins
     
    240215                        parseTree->printList( cout );
    241216                        delete parseTree;
    242                         return EXIT_SUCCESS;
     217                        return 0;
    243218                } // if
    244219
     
    249224                if ( astp ) {
    250225                        dump( translationUnit );
    251                         return EXIT_SUCCESS;
     226                        return 0;
    252227                } // if
    253228
     
    256231                // works okay for now.
    257232                CodeTools::fillLocations( translationUnit );
    258                 Stats::Time::StopBlock();
    259233
    260234                // add the assignment statement after the initialization of a type parameter
    261                 PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
     235                PASS( "validate", SymTab::validate( translationUnit, symtabp ) );
    262236                if ( symtabp ) {
    263237                        deleteAll( translationUnit );
    264                         return EXIT_SUCCESS;
     238                        return 0;
    265239                } // if
    266240
     
    268242                        PassVisitor<ResolvExpr::AlternativePrinter> printer( cout );
    269243                        acceptAll( translationUnit, printer );
    270                         return EXIT_SUCCESS;
     244                        return 0;
    271245                } // if
    272246
    273247                if ( validp ) {
    274248                        dump( translationUnit );
    275                         return EXIT_SUCCESS;
    276                 } // if
    277 
    278                 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
    279                 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    280                 PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
    281                 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
     249                        return 0;
     250                } // if
     251
     252                PASS( "fixLabels", ControlStruct::fixLabels( translationUnit ) );
     253                PASS( "fixNames", CodeGen::fixNames( translationUnit ) );
     254                PASS( "genInit", InitTweak::genInit( translationUnit ) );
     255                PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) );
    282256                if ( libcfap ) {
    283257                        // generate the bodies of cfa library functions
     
    288262                        CodeTools::printDeclStats( translationUnit );
    289263                        deleteAll( translationUnit );
    290                         return EXIT_SUCCESS;
    291                 } // if
     264                        return 0;
     265                }
    292266
    293267                if ( bresolvep ) {
    294268                        dump( translationUnit );
    295                         return EXIT_SUCCESS;
     269                        return 0;
    296270                } // if
    297271
     
    300274                if ( resolvprotop ) {
    301275                        CodeTools::dumpAsResolvProto( translationUnit );
    302                         return EXIT_SUCCESS;
    303                 } // if
    304 
    305                 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
     276                        return 0;
     277                }
     278
     279                PASS( "resolve", ResolvExpr::resolve( translationUnit ) );
    306280                if ( exprp ) {
    307281                        dump( translationUnit );
    308                         return EXIT_SUCCESS;
     282                        return 0;
    309283                } // if
    310284
    311285                // fix ObjectDecl - replaces ConstructorInit nodes
    312                 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
     286                PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );
    313287                if ( ctorinitp ) {
    314288                        dump ( translationUnit );
    315                         return EXIT_SUCCESS;
    316                 } // if
    317 
    318                 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
    319 
    320                 PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
    321 
    322                 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
    323 
    324                 PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
    325 
    326                 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
     289                        return 0;
     290                } // if
     291
     292                PASS( "expandUniqueExpr", 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
     293
     294                PASS( "translateEHM" , ControlStruct::translateEHM( translationUnit ) );
     295
     296                PASS( "generateWaitfor" , Concurrency::generateWaitFor( translationUnit ) );
     297
     298                PASS( "convertSpecializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
     299
     300                PASS( "expandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
    327301
    328302                if ( tuplep ) {
    329303                        dump( translationUnit );
    330                         return EXIT_SUCCESS;
    331                 } // if
    332 
    333                 PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
    334 
    335                 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
     304                        return 0;
     305                }
     306
     307                PASS( "virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
     308
     309                PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) );
    336310                if ( genericsp ) {
    337311                        dump( translationUnit );
    338                         return EXIT_SUCCESS;
    339                 } // if
    340                 PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
     312                        return 0;
     313                }
     314                PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) );
    341315
    342316
    343317                if ( bboxp ) {
    344318                        dump( translationUnit );
    345                         return EXIT_SUCCESS;
    346                 } // if
    347                 PASS( "Box", GenPoly::box( translationUnit ) );
     319                        return 0;
     320                } // if
     321                PASS( "box", GenPoly::box( translationUnit ) );
    348322
    349323                if ( bcodegenp ) {
    350324                        dump( translationUnit );
    351                         return EXIT_SUCCESS;
    352                 } // if
     325                        return 0;
     326                }
    353327
    354328                if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
     
    357331
    358332                CodeTools::fillLocations( translationUnit );
    359                 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
     333                PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
    360334
    361335                CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
     
    373347                        delete output;
    374348                } // if
    375                 return EXIT_FAILURE;
     349                return 1;
    376350        } catch ( UnimplementedError &e ) {
    377351                cout << "Sorry, " << e.get_what() << " is not currently implemented" << endl;
     
    379353                        delete output;
    380354                } // if
    381                 return EXIT_FAILURE;
     355                return 1;
    382356        } catch ( CompilerError &e ) {
    383357                cerr << "Compiler Error: " << e.get_what() << endl;
     
    386360                        delete output;
    387361                } // if
    388                 return EXIT_FAILURE;
    389         } catch ( ... ) {
     362                return 1;
     363        } catch(...) {
    390364                std::exception_ptr eptr = std::current_exception();
    391365                try {
    392366                        if (eptr) {
    393367                                std::rethrow_exception(eptr);
    394                         } else {
    395                                 std::cerr << "Exception Uncaught and Unknown" << std::endl;
    396                         } // if
     368                        }
     369                        else {
     370                                std::cerr << "Exception Uncaught and Unkown" << std::endl;
     371                        }
    397372                } catch(const std::exception& e) {
    398373                        std::cerr << "Uncaught Exception \"" << e.what() << "\"\n";
    399                 } // try
    400                 return EXIT_FAILURE;
    401         } // try
     374                }
     375                return 1;
     376        }// try
    402377
    403378        deleteAll( translationUnit );
    404         Stats::print();
    405         return EXIT_SUCCESS;
     379        if(!libcfap && !treep) HeapStats::printStats();
     380        return 0;
    406381} // main
    407382
    408 
    409 static const char optstring[] = ":hlLmNn:pP:S:twW:D:F:";
    410 
    411 enum { PreludeDir = 128 };
    412 static struct option long_opts[] = {
    413         { "help", no_argument, nullptr, 'h' },
    414         { "libcfa", no_argument, nullptr, 'l' },
    415         { "linemarks", no_argument, nullptr, 'L' },
    416         { "no-main", no_argument, 0, 'm' },
    417         { "no-linemarks", no_argument, nullptr, 'N' },
    418         { "no-prelude", no_argument, nullptr, 'n' },
    419         { "prototypes", no_argument, nullptr, 'p' },
    420         { "print", required_argument, nullptr, 'P' },
    421         { "prelude-dir", required_argument, nullptr, PreludeDir },
    422         { "statistics", required_argument, nullptr, 'S' },
    423         { "tree", no_argument, nullptr, 't' },
    424         { "", no_argument, nullptr, 0 },                                        // -w
    425         { "", no_argument, nullptr, 0 },                                        // -W
    426         { "", no_argument, nullptr, 0 },                                        // -D
    427         { "", no_argument, nullptr, 0 },                                        // -F
    428         { nullptr, 0, nullptr, 0 }
    429 }; // long_opts
    430 
    431 static const char * description[] = {
    432         "print help message",                                                           // -h
    433         "generate libcfa.c",                                                            // -l
    434         "generate line marks",                                                          // -L
    435         "do not replace main",                                                          // -m
    436         "do not generate line marks",                                           // -N
    437         "do not read prelude",                                                          // -n
    438         "generate prototypes for prelude functions",            // -p
    439         "print",                                                                                        // -P
    440         "<directory> prelude directory for debug/nodebug",      // no flag
    441         "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
    442         "build in tree",                                                                        // -t
    443         "",                                                                                                     // -w
    444         "",                                                                                                     // -W
    445         "",                                                                                                     // -D
    446         "",                                                                                                     // -F
    447 }; // description
    448 
    449 static_assert( sizeof( long_opts ) / sizeof( long_opts[0] ) - 1 == sizeof( description ) / sizeof( description[0] ), "Long opts and description must match" );
    450 
    451 static struct Printopts {
    452         const char * name;
    453         int & flag;
    454         int val;
    455         const char * descript;
    456 } printopts[] = {
    457         { "altexpr", expraltp, true, "alternatives for expressions" },
    458         { "ascodegen", codegenp, true, "as codegen rather than AST" },
    459         { "ast", astp, true, "AST after parsing" },
    460         { "astdecl", validp, true, "AST after declaration validation pass" },
    461         { "asterr", errorp, true, "AST on error" },
    462         { "astexpr", exprp, true, "AST after expression analysis" },
    463         { "astgen", genericsp, true, "AST after instantiate generics" },
    464         { "box", bboxp, true, "before box step" },
    465         { "ctordtor", ctorinitp, true, "after ctor/dtor are replaced" },
    466         { "codegen", bcodegenp, true, "before code generation" },
    467         { "declstats", declstatsp, true, "code property statistics" },
    468         { "parse", yydebug, true, "yacc (parsing) debug information" },
    469         { "pretty", prettycodegenp, true, "prettyprint for ascodegen flag" },
    470         { "resolver", bresolvep, true, "before resolver step" },
    471         { "rproto", resolvprotop, true, "resolver-proto instance" },
    472         { "rsteps", resolvep, true, "resolver steps" },
    473         { "symevt", symtabp, true, "symbol table events" },
    474         { "tree", parsep, true, "parse tree" },
    475         { "tuple", tuplep, true, "after tuple expansion" },
    476 };
    477 enum { printoptsSize = sizeof( printopts ) / sizeof( printopts[0] ) };
    478 
    479 static void usage( char *argv[] ) {
    480     cout << "Usage: " << argv[0] << " options are:" << endl;
    481         int i = 0, j = 1;                                                                       // j skips starting colon
    482         for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) {
    483                 if ( long_opts[i].name[0] != '\0' ) {                   // hidden option, internal usage only
    484                         if ( strcmp( long_opts[i].name, "prelude-dir" ) != 0 ) { // flag
    485                                 cout << "  -" << optstring[j] << ",";
    486                         } else {                                                                        // no flag
    487                                 j -= 1;                                                                 // compensate
    488                                 cout << "     ";
    489                         } // if
    490                         cout << " --" << left << setw(12) << long_opts[i].name << "  ";
    491                         if ( strcmp( long_opts[i].name, "print" ) == 0 ) {
    492                                 cout << "one of: " << endl;
    493                                 for ( int i = 0; i < printoptsSize; i += 1 ) {
    494                                         cout << setw(10) << " " << left << setw(10) << printopts[i].name << "  " << printopts[i].descript << endl;
    495                                 } // for
    496                         } else {
    497                                 cout << description[i] << endl;
    498                         } // if
    499                 } // if
    500                 if ( optstring[j + 1] == ':' ) j += 1;
    501         } // for
    502         if ( long_opts[i].name != 0 || optstring[j] != '\0' ) assertf( false, "internal error, mismatch of option flags and names\n" );
    503     exit( EXIT_FAILURE );
    504 } // usage
    505 
    506 static void parse_cmdline( int argc, char * argv[], const char *& filename ) {
     383void parse_cmdline( int argc, char * argv[], const char *& filename ) {
     384        enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, Symbol, Tree, TupleExpansion, Validate, };
     385
     386        static struct option long_opts[] = {
     387                { "ast", no_argument, 0, Ast },
     388                { "before-box", no_argument, 0, Bbox },
     389                { "before-resolver", no_argument, 0, Bresolver },
     390                { "ctorinitfix", no_argument, 0, CtorInitFix },
     391                { "decl-stats", no_argument, 0, DeclStats },
     392                { "expr", no_argument, 0, Expr },
     393                { "expralt", no_argument, 0, ExprAlt },
     394                { "grammar", no_argument, 0, Grammar },
     395                { "libcfa", no_argument, 0, LibCFA },
     396                { "line-marks", no_argument, 0, Linemarks },
     397                { "no-line-marks", no_argument, 0, Nolinemarks },
     398                { "no-preamble", no_argument, 0, Nopreamble },
     399                { "parse", no_argument, 0, Parse },
     400                { "prelude-dir", required_argument, 0, PreludeDir },
     401                { "no-prototypes", no_argument, 0, Prototypes },
     402                { "resolver", no_argument, 0, Resolver },
     403                { "resolv-proto", no_argument, 0, ResolvProto },
     404                { "symbol", no_argument, 0, Symbol },
     405                { "tree", no_argument, 0, Tree },
     406                { "tuple-expansion", no_argument, 0, TupleExpansion },
     407                { "validate", no_argument, 0, Validate },
     408                { 0, 0, 0, 0 }
     409        }; // long_opts
     410        int long_index;
     411
    507412        opterr = 0;                                                                                     // (global) prevent getopt from printing error messages
    508413
    509414        bool Wsuppress = false, Werror = false;
    510415        int c;
    511         while ( (c = getopt_long( argc, argv, optstring, long_opts, nullptr )) != -1 ) {
     416        while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
    512417                switch ( c ) {
    513                   case 'h':                                                                             // help message
    514                         usage( argv );                                                          // no return
    515                         break;
     418                  case Ast:
     419                  case 'a':                                                                             // dump AST
     420                        astp = true;
     421                        break;
     422                  case Bresolver:
     423                  case 'b':                                                                             // print before resolver steps
     424                        bresolvep = true;
     425                        break;
     426                  case 'B':                                                                             // print before box steps
     427                        bboxp = true;
     428                        break;
     429                  case CtorInitFix:
     430                  case 'c':                                                                             // print after constructors and destructors are replaced
     431                        ctorinitp = true;
     432                        break;
     433                  case 'C':                                                                             // print before code generation
     434                        bcodegenp = true;
     435                        break;
     436                  case DeclStats:
     437                  case 'd':
     438                    declstatsp = true;
     439                        break;
     440                  case Expr:
     441                  case 'e':                                                                             // dump AST after expression analysis
     442                        exprp = true;
     443                        break;
     444                  case ExprAlt:
     445                  case 'f':                                                                             // print alternatives for expressions
     446                        expraltp = true;
     447                        break;
     448                  case Grammar:
     449                  case 'g':                                                                             // bison debugging info (grammar rules)
     450                        yydebug = true;
     451                        break;
     452                  case 'G':                                                                             // dump AST after instantiate generics
     453                        genericsp = true;
     454                        break;
     455                  case LibCFA:
    516456                  case 'l':                                                                             // generate libcfa.c
    517457                        libcfap = true;
    518458                        break;
    519                   case 'L':                                                                             // generate line marks
     459                  case Linemarks:
     460                  case 'L':                                                                             // print lines marks
    520461                        linemarks = true;
    521462                        break;
    522                   case 'm':                                                                             // do not replace main
    523                         nomainp = true;
    524                         break;
    525                   case 'N':                                                                             // do not generate line marks
     463                  case Nopreamble:
     464                  case 'n':                                                                             // do not read preamble
     465                        nopreludep = true;
     466                        break;
     467                  case Nolinemarks:
     468                  case 'N':                                                                             // suppress line marks
    526469                        linemarks = false;
    527470                        break;
    528                   case 'n':                                                                             // do not read prelude
    529                         nopreludep = true;
    530                         break;
    531                   case 'p':                                                                             // generate prototypes for prelude functions
    532                         genproto = true;
    533                         break;
    534                   case 'P':                                                                             // print options
    535                         for ( int i = 0;; i += 1 ) {
    536                                 if ( i == printoptsSize ) {
    537                                         cout << "Unknown --print option " << optarg << endl;
    538                                         goto Default;
    539                                 } // if
    540                                 if ( strcmp( optarg, printopts[i].name ) == 0 ) {
    541                                         printopts[i].flag = printopts[i].val;
    542                                         break;
    543                                 } // if
    544                         } // for
    545                         break;
    546                   case PreludeDir:                                                              // prelude directory for debug/nodebug, hidden
    547                         PreludeDirector = optarg;
    548                         break;
    549                   case 'S':                                                                             // enable profiling information, argument comma separated list of names
    550                         Stats::parse_params( optarg );
    551                         break;
     471                  case Prototypes:
     472                  case 'p':                                                                             // generate prototypes for preamble functions
     473                        noprotop = true;
     474                        break;
     475                  case PreludeDir:
     476                        PreludeDirector = optarg;
     477                        break;
     478                  case 'm':                                                                             // don't replace the main
     479                        nomainp = true;
     480                        break;
     481                  case Parse:
     482                  case 'q':                                                                             // dump parse tree
     483                        parsep = true;
     484                        break;
     485                  case Resolver:
     486                  case 'r':                                                                             // print resolver steps
     487                        resolvep = true;
     488                        break;
     489                        case 'R':                                                                               // dump resolv-proto instance
     490                        resolvprotop = true;
     491                        break;
     492                  case Symbol:
     493                  case 's':                                                                             // print symbol table events
     494                        symtabp = true;
     495                        break;
     496                  case Tree:
    552497                  case 't':                                                                             // build in tree
    553498                        treep = true;
    554499                        break;
    555                   case 'w':                                                                             // suppress all warnings, hidden
     500                  case TupleExpansion:
     501                  case 'T':                                                                             // print after tuple expansion
     502                        tuplep = true;
     503                        break;
     504                  case 'v':                                                                             // dump AST after decl validation pass
     505                        validp = true;
     506                        break;
     507                  case 'w':
    556508                        Wsuppress = true;
    557509                        break;
    558                   case 'W':                                                                             // coordinate gcc -W with CFA, hidden
     510                  case 'W':
    559511                        if ( strcmp( optarg, "all" ) == 0 ) {
    560512                                SemanticWarning_EnableAll();
     
    573525                        } // if
    574526                        break;
    575                   case 'D':                                                                             // ignore -Dxxx, forwarded by cpp, hidden
    576                         break;
    577                   case 'F':                                                                             // source file-name without suffix, hidden
     527                  case 'y':                                                                             // dump AST on error
     528                        errorp = true;
     529                        break;
     530                  case 'z':                                                                             // dump as codegen rather than AST
     531                        codegenp = true;
     532                        break;
     533                        case 'Z':                                                                       // prettyprint during codegen (i.e. print unmangled names, etc.)
     534                        prettycodegenp = true;
     535                        break;
     536                  case 'D':                                                                             // ignore -Dxxx
     537                        break;
     538                  case 'F':                                                                             // source file-name without suffix
    578539                        filename = optarg;
    579540                        break;
    580                   case '?':                                                                             // unknown option
     541                  case '?':
    581542                        if ( optopt ) {                                                         // short option ?
    582                                 cout << "Unknown option -" << (char)optopt << endl;
     543                                assertf( false, "Unknown option: -%c\n", (char)optopt );
    583544                        } else {
    584                                 cout << "Unknown option " << argv[optind - 1] << endl;
     545                                assertf( false, "Unknown option: %s\n", argv[optind - 1] );
    585546                        } // if
    586                         goto Default;
    587                   case ':':                                                                             // missing option
    588                         if ( optopt ) {                                                         // short option ?
    589                                 cout << "Missing option for -" << (char)optopt << endl;
    590                         } else {
    591                                 cout << "Missing option for " << argv[optind - 1] << endl;
    592                         } // if
    593                         goto Default;
    594                   Default:
     547                        #if defined(__GNUC__) && __GNUC__ >= 7
     548                                __attribute__((fallthrough));
     549                        #endif
    595550                  default:
    596                         usage( argv );                                                          // no return
     551                        abort();
    597552                } // switch
    598553        } // while
     
    632587        list< Declaration * > decls;
    633588
    634         if ( genproto ) {
     589        if ( noprotop ) {
    635590                filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), notPrelude );
    636591        } else {
     
    640595        // depending on commandline options, either generate code or dump the AST
    641596        if ( codegenp ) {
    642                 CodeGen::generate( decls, out, ! genproto, prettycodegenp );
     597                CodeGen::generate( decls, out, ! noprotop, prettycodegenp );
    643598        } else {
    644599                printAll( decls, out );
    645         } // if
     600        }
    646601        deleteAll( translationUnit );
    647602} // dump
Note: See TracChangeset for help on using the changeset viewer.