mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
use STL make_unique, remove wrapper header, breaks C++17 compilation
This commit is contained in:
@@ -38,8 +38,6 @@
|
||||
|
||||
#include "chimera/ch_database.h"
|
||||
|
||||
#include "util/make_unique.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
EngineCHContext::EngineCHContext(const ch_database_t *db) {
|
||||
@@ -105,7 +103,7 @@ EngineChimera::~EngineChimera() {
|
||||
}
|
||||
|
||||
unique_ptr<EngineContext> EngineChimera::makeContext() const {
|
||||
return ue2::make_unique<EngineCHContext>(db);
|
||||
return std::make_unique<EngineCHContext>(db);
|
||||
}
|
||||
|
||||
void EngineChimera::scan(const char *data, unsigned int len, unsigned int id,
|
||||
@@ -333,5 +331,5 @@ buildEngineChimera(const ExpressionMap &expressions, const string &name,
|
||||
cs.compileSecs = compileSecs;
|
||||
cs.peakMemorySize = peakMemorySize;
|
||||
|
||||
return ue2::make_unique<EngineChimera>(db, move(cs));
|
||||
return std::make_unique<EngineChimera>(db, move(cs));
|
||||
}
|
||||
|
@@ -42,7 +42,6 @@
|
||||
#include "hs_internal.h"
|
||||
#include "hs_runtime.h"
|
||||
#include "util/database_util.h"
|
||||
#include "util/make_unique.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
@@ -126,7 +125,7 @@ EngineHyperscan::~EngineHyperscan() {
|
||||
}
|
||||
|
||||
unique_ptr<EngineContext> EngineHyperscan::makeContext() const {
|
||||
return ue2::make_unique<EngineHSContext>(db);
|
||||
return std::make_unique<EngineHSContext>(db);
|
||||
}
|
||||
|
||||
void EngineHyperscan::scan(const char *data, unsigned int len, unsigned int id,
|
||||
@@ -166,7 +165,7 @@ void EngineHyperscan::scan_vectored(const char *const *data,
|
||||
unique_ptr<EngineStream> EngineHyperscan::streamOpen(EngineContext &ectx,
|
||||
unsigned streamId) const {
|
||||
EngineHSContext &ctx = static_cast<EngineHSContext &>(ectx);
|
||||
auto stream = ue2::make_unique<EngineHSStream>();
|
||||
auto stream = std::make_unique<EngineHSStream>();
|
||||
stream->ctx = &ctx;
|
||||
|
||||
hs_open_stream(db, 0, &stream->id);
|
||||
@@ -549,5 +548,5 @@ buildEngineHyperscan(const ExpressionMap &expressions, ScanMode scan_mode,
|
||||
cs.compileSecs = compileSecs;
|
||||
cs.peakMemorySize = peakMemorySize;
|
||||
|
||||
return ue2::make_unique<EngineHyperscan>(db, std::move(cs));
|
||||
return std::make_unique<EngineHyperscan>(db, std::move(cs));
|
||||
}
|
||||
|
@@ -38,7 +38,6 @@
|
||||
#include "sqldb.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include "util/make_unique.h"
|
||||
#include "util/unicode_def.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -105,7 +104,7 @@ EnginePCRE::~EnginePCRE() {
|
||||
}
|
||||
|
||||
unique_ptr<EngineContext> EnginePCRE::makeContext() const {
|
||||
return ue2::make_unique<EnginePCREContext>(capture_cnt);
|
||||
return std::make_unique<EnginePCREContext>(capture_cnt);
|
||||
}
|
||||
|
||||
void EnginePCRE::scan(const char *data, unsigned int len, unsigned int id,
|
||||
@@ -322,7 +321,7 @@ buildEnginePcre(const ExpressionMap &expressions, const string &name,
|
||||
for (const auto &m : expressions) {
|
||||
string expr(m.second);
|
||||
unsigned int flags = 0;
|
||||
auto pcreDB = ue2::make_unique<PcreDB>();
|
||||
auto pcreDB = std::make_unique<PcreDB>();
|
||||
if (!decodeExprPCRE(expr, &flags, *pcreDB)) {
|
||||
printf("Error parsing PCRE: %s (id %u)\n", m.second.c_str(),
|
||||
m.first);
|
||||
@@ -406,5 +405,5 @@ buildEnginePcre(const ExpressionMap &expressions, const string &name,
|
||||
cs.compileSecs = compileSecs;
|
||||
cs.peakMemorySize = peakMemorySize;
|
||||
|
||||
return ue2::make_unique<EnginePCRE>(move(dbs), move(cs), capture_cnt);
|
||||
return std::make_unique<EnginePCRE>(move(dbs), move(cs), capture_cnt);
|
||||
}
|
||||
|
@@ -45,7 +45,6 @@
|
||||
#include "grey.h"
|
||||
#include "hs.h"
|
||||
#include "ue2common.h"
|
||||
#include "util/make_unique.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <clocale>
|
||||
@@ -979,7 +978,7 @@ unique_ptr<ThreadContext> makeThreadContext(const Engine &db,
|
||||
}
|
||||
assert(fn);
|
||||
|
||||
return ue2::make_unique<ThreadContext>(id, db, sync_barrier, fn, blocks);
|
||||
return std::make_unique<ThreadContext>(id, db, sync_barrier, fn, blocks);
|
||||
}
|
||||
|
||||
/** Run the given benchmark. */
|
||||
|
@@ -52,7 +52,6 @@
|
||||
#include "expressions.h"
|
||||
#include "string_util.h"
|
||||
#include "util/expression_path.h"
|
||||
#include "util/make_unique.h"
|
||||
|
||||
#include "grey.h"
|
||||
#include "hs_compile.h"
|
||||
@@ -664,7 +663,7 @@ int HS_CDECL main(int argc, char **argv) {
|
||||
num_of_threads = max(1u, std::thread::hardware_concurrency());
|
||||
|
||||
#if !defined(RELEASE_BUILD)
|
||||
g_grey = make_unique<Grey>();
|
||||
g_grey = std::make_unique<Grey>();
|
||||
#endif
|
||||
processArgs(argc, argv, g_grey);
|
||||
|
||||
|
@@ -50,7 +50,6 @@
|
||||
#include "parser/unsupported.h"
|
||||
#include "parser/logical_combination.h"
|
||||
#include "util/compile_context.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/report_manager.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -131,7 +130,7 @@ void CNGInfo::compile() {
|
||||
|
||||
try {
|
||||
if (combination) {
|
||||
auto pl = ue2::make_unique<ParsedLogical>();
|
||||
auto pl = std::make_unique<ParsedLogical>();
|
||||
pl->parseLogicalCombination(id, re.c_str(), ~0U, 0, ~0ULL);
|
||||
pl->logicalKeyRenumber();
|
||||
cng = make_unique<CompiledNG>(move(pl));
|
||||
@@ -148,7 +147,7 @@ void CNGInfo::compile() {
|
||||
// original expression starts with (*UTF8)
|
||||
utf8 |= pe.expr.utf8;
|
||||
|
||||
auto rm = ue2::make_unique<ReportManager>(cc.grey);
|
||||
auto rm = std::make_unique<ReportManager>(cc.grey);
|
||||
|
||||
// Expressions containing zero-width assertions and other extended pcre
|
||||
// types aren't supported yet. This call will throw a ParseError
|
||||
|
@@ -42,7 +42,6 @@
|
||||
#include "parser/control_verbs.h"
|
||||
#include "parser/Parser.h"
|
||||
#include "parser/parse_error.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/string_util.h"
|
||||
#include "util/unicode_def.h"
|
||||
#include "util/unordered.h"
|
||||
@@ -331,7 +330,7 @@ GroundTruth::compile(unsigned id, bool no_callouts) {
|
||||
int errloc = 0;
|
||||
int errcode = 0;
|
||||
|
||||
unique_ptr<CompiledPcre> compiled = make_unique<CompiledPcre>();
|
||||
unique_ptr<CompiledPcre> compiled = std::make_unique<CompiledPcre>();
|
||||
compiled->utf8 = flags & PCRE_UTF8;
|
||||
compiled->highlander = highlander;
|
||||
compiled->prefilter = prefilter;
|
||||
|
@@ -39,7 +39,6 @@
|
||||
#include "crc32.h"
|
||||
#include "hs.h"
|
||||
#include "hs_internal.h"
|
||||
#include "util/make_unique.h"
|
||||
|
||||
#include "scratch.h"
|
||||
#include "nfa/nfa_api_queue.h"
|
||||
@@ -948,7 +947,7 @@ compileHyperscan(vector<const char *> &patterns, vector<unsigned> &flags,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ue2::make_unique<HyperscanDB>(db, idsvec.begin(), idsvec.end());
|
||||
return std::make_unique<HyperscanDB>(db, idsvec.begin(), idsvec.end());
|
||||
}
|
||||
|
||||
#ifdef HS_HYBRID
|
||||
@@ -970,7 +969,7 @@ compileHybrid(vector<const char *> &patterns,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ue2::make_unique<HybridDB>(db, idsvec.begin(), idsvec.end());
|
||||
return std::make_unique<HybridDB>(db, idsvec.begin(), idsvec.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -52,7 +52,6 @@
|
||||
#include "parser/utf8_validate.h"
|
||||
#include "ue2common.h"
|
||||
#include "util/container.h"
|
||||
#include "util/make_unique.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -1077,7 +1076,7 @@ void addCorporaToQueue(ostream &out, BoundedQueue<TestUnit> &testq, unsigned id,
|
||||
|
||||
size_t corpus_id = 0;
|
||||
for (const Corpus &corpus : c) {
|
||||
tests.push_back(ue2::make_unique<TestUnit>(id, corpus_id, corpus, cpcre,
|
||||
tests.push_back(std::make_unique<TestUnit>(id, corpus_id, corpus, cpcre,
|
||||
cngi, ue2, multi, utf8,
|
||||
highlander, prefilter, som));
|
||||
corpus_id++;
|
||||
@@ -1435,7 +1434,7 @@ unique_ptr<CorpusGenUnit> makeCorpusGenUnit(unsigned id, TestSummary &summary,
|
||||
// Caller may already have set the UTF-8 property (in multi cases)
|
||||
utf8 |= cpcre ? cpcre->utf8 : cngi->utf8;
|
||||
|
||||
return ue2::make_unique<CorpusGenUnit>(move(cngi), move(cpcre), ue2, id,
|
||||
return std::make_unique<CorpusGenUnit>(move(cngi), move(cpcre), ue2, id,
|
||||
multi, utf8);
|
||||
}
|
||||
|
||||
@@ -1824,7 +1823,7 @@ static
|
||||
unique_ptr<CorporaSource> buildCorpora(const vector<string> &corporaFiles,
|
||||
const ExpressionMap &exprMap) {
|
||||
if (!corporaFiles.empty()) {
|
||||
auto c = ue2::make_unique<FileCorpora>();
|
||||
auto c = std::make_unique<FileCorpora>();
|
||||
for (const auto &file : corporaFiles) {
|
||||
if (!c->readFile(file)) {
|
||||
cout << "Error reading corpora from file: " << file << endl;
|
||||
@@ -1833,7 +1832,7 @@ unique_ptr<CorporaSource> buildCorpora(const vector<string> &corporaFiles,
|
||||
}
|
||||
return move(c); /* move allows unique_ptr<CorporaSource> conversion */
|
||||
} else {
|
||||
auto c = ue2::make_unique<NfaGeneratedCorpora>(
|
||||
auto c = std::make_unique<NfaGeneratedCorpora>(
|
||||
exprMap, corpus_gen_prop, force_utf8, force_prefilter);
|
||||
return move(c);
|
||||
}
|
||||
@@ -1886,7 +1885,7 @@ bool runTests(CorporaSource &corpora_source, const ExpressionMap &exprMap,
|
||||
// Start scanning threads.
|
||||
vector<unique_ptr<ScanThread>> scanners;
|
||||
for (size_t i = 0; i < numScannerThreads; i++) {
|
||||
auto s = ue2::make_unique<ScanThread>(i, testq, exprMap, plat, grey);
|
||||
auto s = std::make_unique<ScanThread>(i, testq, exprMap, plat, grey);
|
||||
s->start();
|
||||
scanners.push_back(move(s));
|
||||
}
|
||||
@@ -1989,7 +1988,7 @@ int HS_CDECL main(int argc, char *argv[]) {
|
||||
|
||||
// If we're saving corpora out, truncate the output file.
|
||||
if (saveCorpora) {
|
||||
corporaOut = ue2::make_unique<CorpusWriter>(saveCorporaFile);
|
||||
corporaOut = std::make_unique<CorpusWriter>(saveCorporaFile);
|
||||
}
|
||||
|
||||
GroundTruth::global_prep();
|
||||
|
Reference in New Issue
Block a user