Merge pull request #274 from gtsoul-tech/bugFix/cppcheckError-noexplicitConstructor

Bug fix/cppcheck error noexplicitconstructor
This commit is contained in:
Konstantinos Margaritis
2024-05-13 21:52:55 +03:00
committed by GitHub
59 changed files with 287 additions and 246 deletions

View File

@@ -920,7 +920,7 @@ void addToHolder(NGHolder &g, u32 top, const PureRepeat &pr) {
u32 min_bound = pr.bounds.min; // always finite
if (min_bound == 0) { // Vacuous case, we can only do this once.
assert(!edge(g.start, g.accept, g).second);
NFAEdge e = add_edge(g.start, g.accept, g);
NFAEdge e = add_edge(g.start, g.accept, g).first;
g[e].tops.insert(top);
g[u].reports.insert(pr.reports.begin(), pr.reports.end());
min_bound = 1;
@@ -929,7 +929,7 @@ void addToHolder(NGHolder &g, u32 top, const PureRepeat &pr) {
for (u32 i = 0; i < min_bound; i++) {
NFAVertex v = add_vertex(g);
g[v].char_reach = pr.reach;
NFAEdge e = add_edge(u, v, g);
NFAEdge e = add_edge(u, v, g).first;
if (u == g.start) {
g[e].tops.insert(top);
}
@@ -948,7 +948,7 @@ void addToHolder(NGHolder &g, u32 top, const PureRepeat &pr) {
if (head != u) {
add_edge(head, v, g);
}
NFAEdge e = add_edge(u, v, g);
NFAEdge e = add_edge(u, v, g).first;
if (u == g.start) {
g[e].tops.insert(top);
}

View File

@@ -1042,7 +1042,7 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
|| !cc.streaming);
if (!cc.grey.allowGough) {
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
DEBUG_PRINTF("hello world\n");
@@ -1073,7 +1073,7 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
auto basic_dfa = mcclellanCompile_i(raw, gbs, cc);
assert(basic_dfa);
if (!basic_dfa) {
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
u8 alphaShift

View File

@@ -555,7 +555,8 @@ void filterAccelStates(NGHolder &g, const map<u32, set<NFAVertex>> &tops,
// Similarly, connect (start, startDs) if necessary.
if (!edge(g.start, g.startDs, g).second) {
NFAEdge e = add_edge(g.start, g.startDs, g);
NFAEdge e;
std::tie(e, std::ignore) = add_edge(g.start, g.startDs, g);
tempEdges.emplace_back(e); // Remove edge later.
}
@@ -2219,7 +2220,7 @@ struct Factory {
static
bytecode_ptr<NFA> generateNfa(const build_info &args) {
if (args.num_states > NFATraits<dtype>::maxStates) {
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
// Build bounded repeat structures.
@@ -2578,7 +2579,7 @@ bytecode_ptr<NFA> generate(NGHolder &h,
if (!cc.grey.allowLimExNFA) {
DEBUG_PRINTF("limex not allowed\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
// If you ask for a particular type, it had better be an NFA.
@@ -2613,7 +2614,7 @@ bytecode_ptr<NFA> generate(NGHolder &h,
if (scores.empty()) {
DEBUG_PRINTF("No NFA returned a valid score for this case.\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
// Sort acceptable models in priority order, lowest score first.
@@ -2632,7 +2633,7 @@ bytecode_ptr<NFA> generate(NGHolder &h,
}
DEBUG_PRINTF("NFA build failed.\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
u32 countAccelStates(NGHolder &h,

View File

@@ -625,7 +625,7 @@ bytecode_ptr<NFA> mcclellanCompile16(dfa_info &info, const CompileContext &cc,
if (!allocateFSN16(info, &count_real_states, &wide_limit)) {
DEBUG_PRINTF("failed to allocate state numbers, %zu states total\n",
info.size());
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
DEBUG_PRINTF("count_real_states: %d\n", count_real_states);

View File

@@ -1035,7 +1035,7 @@ bytecode_ptr<NFA> mcshengCompile16(dfa_info &info, dstate_id_t sheng_end,
if (!allocateImplId16(info, sheng_end, &sherman_limit)) {
DEBUG_PRINTF("failed to allocate state numbers, %zu states total\n",
info.size());
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
u16 count_real_states = sherman_limit - sheng_end;
@@ -1189,7 +1189,7 @@ bytecode_ptr<NFA> mcsheng64Compile16(dfa_info&info, dstate_id_t sheng_end,
if (!allocateImplId16(info, sheng_end, &sherman_limit)) {
DEBUG_PRINTF("failed to allocate state numbers, %zu states total\n",
info.size());
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
u16 count_real_states = sherman_limit - sheng_end;
@@ -1414,7 +1414,7 @@ bytecode_ptr<NFA> mcsheng64Compile8(dfa_info &info, dstate_id_t sheng_end,
bytecode_ptr<NFA> mcshengCompile(raw_dfa &raw, const CompileContext &cc,
const ReportManager &rm) {
if (!cc.grey.allowMcSheng) {
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
mcclellan_build_strat mbs(raw, rm, false);
@@ -1435,7 +1435,7 @@ bytecode_ptr<NFA> mcshengCompile(raw_dfa &raw, const CompileContext &cc,
if (sheng_end <= DEAD_STATE + 1) {
info.states = old_states;
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
bytecode_ptr<NFA> nfa;
@@ -1462,12 +1462,12 @@ bytecode_ptr<NFA> mcshengCompile(raw_dfa &raw, const CompileContext &cc,
bytecode_ptr<NFA> mcshengCompile64(raw_dfa &raw, const CompileContext &cc,
const ReportManager &rm) {
if (!cc.grey.allowMcSheng) {
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
if (!cc.target_info.has_avx512vbmi()) {
DEBUG_PRINTF("McSheng64 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
mcclellan_build_strat mbs(raw, rm, false);
@@ -1488,7 +1488,7 @@ bytecode_ptr<NFA> mcshengCompile64(raw_dfa &raw, const CompileContext &cc,
sheng_end64 = find_sheng_states(info, accel_escape_info, MAX_SHENG64_STATES);
if (sheng_end64 <= DEAD_STATE + 1) {
return nullptr;
return bytecode_ptr<NFA>(nullptr);
} else {
using64state = true;
}

View File

@@ -45,7 +45,7 @@ struct RdfaEdgeProps {
};
struct RdfaGraph : public ue2_graph<RdfaGraph, RdfaVertexProps, RdfaEdgeProps> {
RdfaGraph(const raw_dfa &rdfa);
explicit RdfaGraph(const raw_dfa &rdfa);
};

View File

@@ -690,7 +690,7 @@ bytecode_ptr<NFA> shengCompile_int(raw_dfa &raw, const CompileContext &cc,
}
if (!createShuffleMasks<T>((T *)getMutableImplNfa(nfa.get()), info, accelInfo)) {
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
return nfa;
@@ -701,7 +701,7 @@ bytecode_ptr<NFA> shengCompile(raw_dfa &raw, const CompileContext &cc,
set<dstate_id_t> *accel_states) {
if (!cc.grey.allowSheng) {
DEBUG_PRINTF("Sheng is not allowed!\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
sheng_build_strat strat(raw, rm, only_accel_init);
@@ -716,7 +716,7 @@ bytecode_ptr<NFA> shengCompile(raw_dfa &raw, const CompileContext &cc,
info.can_die ? "can" : "cannot", info.size());
if (info.size() > 16) {
DEBUG_PRINTF("Too many states\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
return shengCompile_int<sheng>(raw, cc, accel_states, strat, info);
@@ -727,18 +727,18 @@ bytecode_ptr<NFA> sheng32Compile(raw_dfa &raw, const CompileContext &cc,
set<dstate_id_t> *accel_states) {
if (!cc.grey.allowSheng) {
DEBUG_PRINTF("Sheng is not allowed!\n");
return nullptr;
bytecode_ptr<NFA>(nullptr);
}
#ifdef HAVE_SVE
if (svcntb()<32) {
DEBUG_PRINTF("Sheng32 failed, SVE width is too small!\n");
return nullptr;
bytecode_ptr<NFA>(nullptr);
}
#else
if (!cc.target_info.has_avx512vbmi()) {
DEBUG_PRINTF("Sheng32 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
return nullptr;
bytecode_ptr<NFA>(nullptr);
}
#endif
@@ -755,7 +755,7 @@ bytecode_ptr<NFA> sheng32Compile(raw_dfa &raw, const CompileContext &cc,
assert(info.size() > 16);
if (info.size() > 32) {
DEBUG_PRINTF("Too many states\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
return shengCompile_int<sheng32>(raw, cc, accel_states, strat, info);
@@ -766,18 +766,18 @@ bytecode_ptr<NFA> sheng64Compile(raw_dfa &raw, const CompileContext &cc,
set<dstate_id_t> *accel_states) {
if (!cc.grey.allowSheng) {
DEBUG_PRINTF("Sheng is not allowed!\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
#ifdef HAVE_SVE
if (svcntb()<64) {
DEBUG_PRINTF("Sheng64 failed, SVE width is too small!\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
#else
if (!cc.target_info.has_avx512vbmi()) {
DEBUG_PRINTF("Sheng64 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
#endif
@@ -794,7 +794,7 @@ bytecode_ptr<NFA> sheng64Compile(raw_dfa &raw, const CompileContext &cc,
assert(info.size() > 32);
if (info.size() > 64) {
DEBUG_PRINTF("Too many states\n");
return nullptr;
return bytecode_ptr<NFA>(nullptr);
}
vector<dstate> old_states;
old_states = info.states;