Ignore:
Timestamp:
Apr 26, 2018, 9:29:20 AM (17 months ago)
Author:
cameron
Message:

Setting BinaryFilesMode? to Text (temporary); conversion to unique_ptr progress

File:
1 edited

Legend:

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

    r5990 r5992  
    3030#include <sys/stat.h>
    3131#include <fcntl.h>
     32#include <llvm/ADT/STLExtras.h> // for make_unique
    3233
    3334using namespace llvm;
     
    111112
    112113int main(int argc, char *argv[]) {
    113     sys::PrintStackTraceOnErrorSignal(argv[0]);
    114     llvm::PrettyStackTraceProgram X(argc, argv);
    115     llvm_shutdown_obj shutdown;
    116114
    117115    argv::InitializeCommandLineInterface(argc, argv);
     
    127125    }
    128126
    129     grep::GrepEngine * grepEngine = nullptr;
     127    std::unique_ptr<grep::GrepEngine> grepEngine;
    130128   
    131129    switch (argv::Mode) {
    132130        case argv::NormalMode:
    133             grepEngine = new grep::EmitMatchesEngine();
     131            grepEngine = make_unique<grep::EmitMatchesEngine>();
    134132            if (argv::MaxCountFlag) grepEngine->setMaxCount(argv::MaxCountFlag);
    135133            if (argv::WithFilenameFlag) grepEngine->showFileNames();
     
    138136           break;
    139137        case argv::CountOnly:
    140             grepEngine = new grep::CountOnlyEngine();
     138            grepEngine = make_unique<grep::CountOnlyEngine>();
    141139            if (argv::WithFilenameFlag) grepEngine->showFileNames();
    142140            if (argv::MaxCountFlag) grepEngine->setMaxCount(argv::MaxCountFlag);
     
    144142        case argv::FilesWithMatch:
    145143        case argv::FilesWithoutMatch:
    146             grepEngine = new grep::MatchOnlyEngine(argv::Mode == argv::FilesWithMatch, argv::NullFlag);
     144            grepEngine = make_unique<grep::MatchOnlyEngine>(argv::Mode == argv::FilesWithMatch, argv::NullFlag);
    147145            break;
    148146        case argv::QuietMode:
    149             grepEngine = new grep::QuietModeEngine(); break;
     147            grepEngine = make_unique<grep::QuietModeEngine>();
     148            break;
    150149        default: llvm_unreachable("Invalid grep mode!");
    151150    }
     
    163162    if (argv::NoMessagesFlag) grepEngine->suppressFileMessages();
    164163    if (argv::MmapFlag) grepEngine->setPreferMMap();
     164    grepEngine->setBinaryFilesOption(argv::BinaryFilesFlag);
    165165    grepEngine->initREs(REs);
    166166    grepEngine->grepCodeGen();
    167167    grepEngine->initFileResult(allFiles);
    168168    bool matchFound = grepEngine->searchAllFiles();
    169     delete(grepEngine);
    170169   
    171170    return matchFound ? argv::MatchFoundExitCode : argv::MatchNotFoundExitCode;
Note: See TracChangeset for help on using the changeset viewer.