Ignore:
Timestamp:
May 25, 2017, 11:08:15 AM (2 years ago)
Author:
cameron
Message:

Command line interface - systematic support for legacy flags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r5474 r5476  
    1818#include <re/re_utility.h>
    1919#include <grep_engine.h>
     20#include <grep_interface.h>
    2021#include <fstream>
    2122#include <string>
     
    5455static cl::opt<int> REsPerGroup("re-num", cl::desc("Number of regular expressions processed by each kernel."), cl::init(1));
    5556static std::vector<std::string> allFiles;
    56 //
    57 // Handler for errors reported through llvm::report_fatal_error.  Report
    58 // and signal error code 2 (grep convention).
    59 //
    60 static void icgrep_error_handler(void *UserData, const std::string &Message, bool GenCrashDiag) {
    61     #ifndef NDEBUG
    62     throw std::runtime_error(Message);
    63     #else
    64     // Modified from LLVM's internal report_fatal_error logic.
    65     SmallVector<char, 64> Buffer;
    66     raw_svector_ostream OS(Buffer);
    67     OS << "icgrep ERROR: " << Message << "\n";
    68     StringRef MessageStr = OS.str();
    69     ssize_t written = ::write(2, MessageStr.data(), MessageStr.size());
    70     (void)written; // If something went wrong, we deliberately just give up.
    71     // Run the interrupt handlers to make sure any special cleanups get done, in
    72     // particular that we remove files registered with RemoveFileOnSignal.
    73     llvm::sys::RunInterruptHandlers();
    74     exit(2);
    75     #endif
    76 }
    7757
    7858static re::ModeFlagSet globalFlags = 0;
     
    214194
    215195int main(int argc, char *argv[]) {
    216    
    217     llvm::install_fatal_error_handler(&icgrep_error_handler);
    218     AddParabixVersionPrinter();
    219 #ifndef USE_LLVM_3_6
    220     cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *>{&LegacyGrepOptions, &EnhancedGrepOptions, grep::grep_regexp_flags(), grep::grep_output_flags(), re::re_toolchain_flags(), pablo::pablo_toolchain_flags(), codegen::codegen_flags()});
    221 #endif
    222     cl::ParseCommandLineOptions(argc, argv);
    223     if (grep::RegexpSyntax == re::RE_Syntax::FixedStrings) {
    224         llvm::report_fatal_error("Sorry, FixedStrings syntax is not fully supported\n.");
    225     }
    226 
     196
     197    grep::InitializeCommandLineInterface(argc, argv);
     198   
    227199    const auto REs = readExpressions();
    228200
Note: See TracChangeset for help on using the changeset viewer.