next batch

This commit is contained in:
G.E 2024-05-17 00:08:37 +03:00
parent da4f563a24
commit c482c05fa8
24 changed files with 76 additions and 4 deletions

View File

@ -674,9 +674,6 @@ u64a scoreSet(const set<ue2_literal> &s) {
u64a score = 1ULL; u64a score = 1ULL;
auto cscore = [](u64a z, const ue2_literal &lit) { return z + calculateScore(lit); }; auto cscore = [](u64a z, const ue2_literal &lit) { return z + calculateScore(lit); };
score += std::accumulate(s.begin(), s.end(), 0, cscore); score += std::accumulate(s.begin(), s.end(), 0, cscore);
// for (const auto &lit : s) {
// score += calculateScore(lit);
// }
return score; return score;
} }

View File

@ -154,6 +154,7 @@ void predCRIntersection(const NGHolder &g, NFAVertex v, CharReach &add) {
add.setall(); add.setall();
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u != v) { if (u != v) {
// cppcheck-suppress useStlAlgorithm
add &= g[u].char_reach; add &= g[u].char_reach;
} }
} }
@ -165,6 +166,7 @@ void succCRIntersection(const NGHolder &g, NFAVertex v, CharReach &add) {
add.setall(); add.setall();
for (auto u : adjacent_vertices_range(v, g)) { for (auto u : adjacent_vertices_range(v, g)) {
if (u != v) { if (u != v) {
// cppcheck-suppress useStlAlgorithm
add &= g[u].char_reach; add &= g[u].char_reach;
} }
} }
@ -195,6 +197,7 @@ set<NFAVertex> findSustainSet(const NGHolder &g, NFAVertex p,
CharReach sus_cr; CharReach sus_cr;
for (auto v : adjacent_vertices_range(u, g)) { for (auto v : adjacent_vertices_range(u, g)) {
if (contains(cand, v)) { if (contains(cand, v)) {
// cppcheck-suppress useStlAlgorithm
sus_cr |= g[v].char_reach; sus_cr |= g[v].char_reach;
} }
} }
@ -227,6 +230,7 @@ set<NFAVertex> findSustainSet_rev(const NGHolder &g, NFAVertex p,
CharReach sus_cr; CharReach sus_cr;
for (auto v : inv_adjacent_vertices_range(u, g)) { for (auto v : inv_adjacent_vertices_range(u, g)) {
if (contains(cand, v)) { if (contains(cand, v)) {
// cppcheck-suppress useStlAlgorithm
sus_cr |= g[v].char_reach; sus_cr |= g[v].char_reach;
} }
} }
@ -282,6 +286,7 @@ bool enlargeCyclicVertex(NGHolder &g, som_type som, NFAVertex v) {
CharReach sustain_cr; CharReach sustain_cr;
for (auto pv : adjacent_vertices_range(pp, g)) { for (auto pv : adjacent_vertices_range(pp, g)) {
if (contains(sustain, pv)) { if (contains(sustain, pv)) {
// cppcheck-suppress useStlAlgorithm
sustain_cr |= g[pv].char_reach; sustain_cr |= g[pv].char_reach;
} }
} }
@ -332,6 +337,7 @@ bool enlargeCyclicVertex_rev(NGHolder &g, NFAVertex v) {
CharReach sustain_cr; CharReach sustain_cr;
for (auto pv : inv_adjacent_vertices_range(pp, g)) { for (auto pv : inv_adjacent_vertices_range(pp, g)) {
if (contains(sustain, pv)) { if (contains(sustain, pv)) {
// cppcheck-suppress useStlAlgorithm
sustain_cr |= g[pv].char_reach; sustain_cr |= g[pv].char_reach;
} }
} }

View File

@ -251,12 +251,14 @@ bool hasOnlySelfLoopAndExhaustibleAccepts(const NGHolder &g,
return false; return false;
} }
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) { for (auto w : adjacent_vertices_range(v, g)) {
if (w != v && w != g.accept) { if (w != v && w != g.accept) {
return false; return false;
} }
} }
// cppcheck-suppress useStlAlgorithm
for (const auto &report_id : g[v].reports) { for (const auto &report_id : g[v].reports) {
if (!isSimpleExhaustible(rm.getReport(report_id))) { if (!isSimpleExhaustible(rm.getReport(report_id))) {
return false; return false;

View File

@ -154,6 +154,7 @@ static
bool triggerResetsPuff(const NGHolder &g, NFAVertex head) { bool triggerResetsPuff(const NGHolder &g, NFAVertex head) {
const CharReach puff_escapes = ~g[head].char_reach; const CharReach puff_escapes = ~g[head].char_reach;
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(head, g)) { for (auto u : inv_adjacent_vertices_range(head, g)) {
if (!g[u].char_reach.isSubsetOf(puff_escapes)) { if (!g[u].char_reach.isSubsetOf(puff_escapes)) {
DEBUG_PRINTF("no reset on trigger %zu %zu\n", g[u].index, DEBUG_PRINTF("no reset on trigger %zu %zu\n", g[u].index,
@ -187,6 +188,7 @@ bool triggerFloodsPuff(const NGHolder &g, NFAVertex head) {
DEBUG_PRINTF("temp new head = %zu\n", g[head].index); DEBUG_PRINTF("temp new head = %zu\n", g[head].index);
} }
// cppcheck-suppress useStlAlgorithm
for (auto s : inv_adjacent_vertices_range(head, g)) { for (auto s : inv_adjacent_vertices_range(head, g)) {
DEBUG_PRINTF("s = %zu\n", g[s].index); DEBUG_PRINTF("s = %zu\n", g[s].index);
if (!puff_cr.isSubsetOf(g[s].char_reach)) { if (!puff_cr.isSubsetOf(g[s].char_reach)) {
@ -224,6 +226,7 @@ u32 allowedSquashDistance(const CharReach &cr, u32 min_width, const NGHolder &g,
/* TODO: inspect further back in the pattern */ /* TODO: inspect further back in the pattern */
for (auto u : inv_adjacent_vertices_range(pv, g)) { for (auto u : inv_adjacent_vertices_range(pv, g)) {
// cppcheck-suppress useStlAlgorithm
accept_cr |= g[u].char_reach; accept_cr |= g[u].char_reach;
} }
@ -367,6 +370,7 @@ bool doComponent(RoseBuild &rose, ReportManager &rm, NGHolder &g, NFAVertex a,
if (!nodes.empty() && proper_in_degree(nodes.back(), g) != 1) { if (!nodes.empty() && proper_in_degree(nodes.back(), g) != 1) {
for (auto u : inv_adjacent_vertices_range(nodes.back(), g)) { for (auto u : inv_adjacent_vertices_range(nodes.back(), g)) {
// cppcheck-suppress useStlAlgorithm
if (is_special(u, g)) { if (is_special(u, g)) {
DEBUG_PRINTF("pop\n"); DEBUG_PRINTF("pop\n");
a = nodes.back(); a = nodes.back();
@ -453,6 +457,7 @@ bool doComponent(RoseBuild &rose, ReportManager &rm, NGHolder &g, NFAVertex a,
const auto &reports = g[nodes[0]].reports; const auto &reports = g[nodes[0]].reports;
assert(!reports.empty()); assert(!reports.empty());
// cppcheck-suppress useStlAlgorithm
for (auto report : reports) { for (auto report : reports) {
const Report &ir = rm.getReport(report); const Report &ir = rm.getReport(report);
const bool highlander = ir.ekey != INVALID_EKEY; const bool highlander = ir.ekey != INVALID_EKEY;
@ -499,6 +504,7 @@ bool splitOffPuffs(RoseBuild &rose, ReportManager &rm, NGHolder &g,
for (auto v : inv_adjacent_vertices_range(g.accept, g)) { for (auto v : inv_adjacent_vertices_range(g.accept, g)) {
if (doComponent(rose, rm, g, v, dead, cc, prefilter)) { if (doComponent(rose, rm, g, v, dead, cc, prefilter)) {
// cppcheck-suppress useStlAlgorithm
count++; count++;
} }
} }

View File

@ -682,6 +682,7 @@ bool forwardPathReachSubset(const NFAEdge &e, const NFAVertex &dom,
static static
bool allOutsSpecial(NFAVertex v, const NGHolder &g) { bool allOutsSpecial(NFAVertex v, const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) { for (auto w : adjacent_vertices_range(v, g)) {
if (!is_special(w, g)) { if (!is_special(w, g)) {
return false; return false;
@ -692,6 +693,7 @@ bool allOutsSpecial(NFAVertex v, const NGHolder &g) {
static static
bool allInsSpecial(NFAVertex v, const NGHolder &g) { bool allInsSpecial(NFAVertex v, const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!is_special(u, g)) { if (!is_special(u, g)) {
return false; return false;
@ -704,6 +706,7 @@ bool allInsSpecial(NFAVertex v, const NGHolder &g) {
* just a chain of vertices with no other edges. */ * just a chain of vertices with no other edges. */
static static
bool isIrreducible(const NGHolder &g) { bool isIrreducible(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) { for (auto v : vertices_range(g)) {
// skip specials // skip specials
if (is_special(v, g)) { if (is_special(v, g)) {

View File

@ -153,6 +153,7 @@ bool exitValid(UNUSED const AcyclicGraph &g, const vector<exit_info> &exits,
} }
for (auto it = begin(exits) + 1; it != end(exits); ++it) { for (auto it = begin(exits) + 1; it != end(exits); ++it) {
// cppcheck-suppress useStlAlgorithm
if (it->open != enters) { if (it->open != enters) {
return false; return false;
} }

View File

@ -62,6 +62,7 @@ bool regionHasUnexpectedAccept(const NGHolder &g, const u32 region,
const flat_set<ReportID> &expected_reports, const flat_set<ReportID> &expected_reports,
const unordered_map<NFAVertex, u32> &region_map) { const unordered_map<NFAVertex, u32> &region_map) {
/* TODO: only check vertices connected to accept/acceptEOD */ /* TODO: only check vertices connected to accept/acceptEOD */
// cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) { for (auto v : vertices_range(g)) {
if (region != region_map.at(v)) { if (region != region_map.at(v)) {
continue; continue;
@ -71,7 +72,7 @@ bool regionHasUnexpectedAccept(const NGHolder &g, const u32 region,
return true; /* encountering an actual special in the region is return true; /* encountering an actual special in the region is
* possible but definitely unexpected */ * possible but definitely unexpected */
} }
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) { for (auto w : adjacent_vertices_range(v, g)) {
if (is_any_accept(w, g) && g[v].reports != expected_reports) { if (is_any_accept(w, g) && g[v].reports != expected_reports) {
return true; return true;
@ -200,6 +201,7 @@ map<u32, RegionInfo> buildRegionInfoMap(const NGHolder &g,
static static
bool hasNoStartAnchoring(const NGHolder &h) { bool hasNoStartAnchoring(const NGHolder &h) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(h.start, h)) { for (auto v : adjacent_vertices_range(h.start, h)) {
if (!edge(h.startDs, v, h).second) { if (!edge(h.startDs, v, h).second) {
return false; return false;

View File

@ -260,6 +260,7 @@ bool vertexIsBad(const NGHolder &g, NFAVertex v,
// We must drop any vertex that is the target of a back-edge within // We must drop any vertex that is the target of a back-edge within
// our subgraph. The tail set contains all vertices that are after v in a // our subgraph. The tail set contains all vertices that are after v in a
// topo ordering. // topo ordering.
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
if (contains(tail, u)) { if (contains(tail, u)) {
DEBUG_PRINTF("back-edge (%zu,%zu) in subgraph found\n", DEBUG_PRINTF("back-edge (%zu,%zu) in subgraph found\n",
@ -343,6 +344,7 @@ static
void findFirstReports(const NGHolder &g, const ReachSubgraph &rsi, void findFirstReports(const NGHolder &g, const ReachSubgraph &rsi,
flat_set<ReportID> &reports) { flat_set<ReportID> &reports) {
for (auto v : rsi.vertices) { for (auto v : rsi.vertices) {
// cppcheck-suppress useStlAlgorithm
if (is_match_vertex(v, g)) { if (is_match_vertex(v, g)) {
reports = g[v].reports; reports = g[v].reports;
return; return;
@ -620,6 +622,7 @@ bool processSubgraph(const NGHolder &g, ReachSubgraph &rsi,
static static
bool allPredsInSubgraph(NFAVertex v, const NGHolder &g, bool allPredsInSubgraph(NFAVertex v, const NGHolder &g,
const unordered_set<NFAVertex> &involved) { const unordered_set<NFAVertex> &involved) {
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!contains(involved, u)) { if (!contains(involved, u)) {
return false; return false;
@ -688,6 +691,7 @@ u32 isCloseToAccept(const NGHolder &g, NFAVertex v) {
} }
for (auto w : adjacent_vertices_range(v, g)) { for (auto w : adjacent_vertices_range(v, g)) {
// cppcheck-suppress useStlAlgorithm
if (is_any_accept(w, g)) { if (is_any_accept(w, g)) {
return 1; return 1;
} }
@ -702,6 +706,7 @@ u32 unpeelAmount(const NGHolder &g, const ReachSubgraph &rsi) {
u32 rv = 0; u32 rv = 0;
for (auto v : adjacent_vertices_range(last, g)) { for (auto v : adjacent_vertices_range(last, g)) {
// cppcheck-suppress useStlAlgorithm
rv = max(rv, isCloseToAccept(g, v)); rv = max(rv, isCloseToAccept(g, v));
} }
@ -995,6 +1000,7 @@ bool peelSubgraph(const NGHolder &g, const Grey &grey, ReachSubgraph &rsi,
// If vertices in the middle are involved in other repeats, it's a definite // If vertices in the middle are involved in other repeats, it's a definite
// no-no. // no-no.
// cppcheck-suppress useStlAlgorithm
for (auto v : rsi.vertices) { for (auto v : rsi.vertices) {
if (contains(created, v)) { if (contains(created, v)) {
DEBUG_PRINTF("vertex %zu is in another repeat\n", g[v].index); DEBUG_PRINTF("vertex %zu is in another repeat\n", g[v].index);
@ -1075,7 +1081,9 @@ bool hasSkipEdges(const NGHolder &g, const ReachSubgraph &rsi) {
const NFAVertex last = rsi.vertices.back(); const NFAVertex last = rsi.vertices.back();
// All of the preds of first must have edges to all the successors of last. // All of the preds of first must have edges to all the successors of last.
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(first, g)) { for (auto u : inv_adjacent_vertices_range(first, g)) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(last, g)) { for (auto v : adjacent_vertices_range(last, g)) {
if (!edge(u, v, g).second) { if (!edge(u, v, g).second) {
return false; return false;
@ -1114,6 +1122,7 @@ bool entered_at_fixed_offset(NFAVertex v, const NGHolder &g,
} }
DEBUG_PRINTF("first is at least %s from start\n", first.str().c_str()); DEBUG_PRINTF("first is at least %s from start\n", first.str().c_str());
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
const depth &u_max_depth = depths.at(u).fromStart.max; const depth &u_max_depth = depths.at(u).fromStart.max;
DEBUG_PRINTF("pred %zu max depth %s from start\n", g[u].index, DEBUG_PRINTF("pred %zu max depth %s from start\n", g[u].index,
@ -1204,6 +1213,7 @@ static
CharReach predReach(const NGHolder &g, NFAVertex v) { CharReach predReach(const NGHolder &g, NFAVertex v) {
CharReach cr; CharReach cr;
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
// cppcheck-suppress useStlAlgorithm
cr |= g[u].char_reach; cr |= g[u].char_reach;
} }
return cr; return cr;
@ -1431,6 +1441,7 @@ struct StrawWalker {
* inf max bound). */ * inf max bound). */
bool isBoundedRepeatCyclic(NFAVertex v) const { bool isBoundedRepeatCyclic(NFAVertex v) const {
for (const auto &r : repeats) { for (const auto &r : repeats) {
// cppcheck-suppress useStlAlgorithm
if (r.repeatMax.is_finite() && r.cyclic == v) { if (r.repeatMax.is_finite() && r.cyclic == v) {
return true; return true;
} }
@ -1580,6 +1591,7 @@ bool hasCyclicSupersetExitPath(const NGHolder &g, const ReachSubgraph &rsi,
static static
bool leadsOnlyToAccept(const NGHolder &g, const ReachSubgraph &rsi) { bool leadsOnlyToAccept(const NGHolder &g, const ReachSubgraph &rsi) {
const NFAVertex u = rsi.vertices.back(); const NFAVertex u = rsi.vertices.back();
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(u, g)) { for (auto v : adjacent_vertices_range(u, g)) {
if (v != g.accept) { if (v != g.accept) {
return false; return false;
@ -1593,6 +1605,7 @@ static
bool allSimpleHighlander(const ReportManager &rm, bool allSimpleHighlander(const ReportManager &rm,
const flat_set<ReportID> &reports) { const flat_set<ReportID> &reports) {
assert(!reports.empty()); assert(!reports.empty());
// cppcheck-suppress useStlAlgorithm
for (auto report : reports) { for (auto report : reports) {
if (!isSimpleExhaustible(rm.getReport(report))) { if (!isSimpleExhaustible(rm.getReport(report))) {
return false; return false;
@ -1909,6 +1922,7 @@ bool improveLeadingRepeat(NGHolder &g, BoundedRepeatData &rd,
DEBUG_PRINTF("startDs has other successors\n"); DEBUG_PRINTF("startDs has other successors\n");
return false; return false;
} }
// cppcheck-suppress useStlAlgorithm
for (const auto &v : straw) { for (const auto &v : straw) {
if (proper_out_degree(v, g) != 1) { if (proper_out_degree(v, g) != 1) {
DEBUG_PRINTF("branch between startDs and repeat, from vertex %zu\n", DEBUG_PRINTF("branch between startDs and repeat, from vertex %zu\n",

View File

@ -56,6 +56,7 @@ set<ReportID> all_reports(const NGHolder &g) {
/** True if *all* reports in the graph are exhaustible. */ /** True if *all* reports in the graph are exhaustible. */
bool can_exhaust(const NGHolder &g, const ReportManager &rm) { bool can_exhaust(const NGHolder &g, const ReportManager &rm) {
// cppcheck-suppress useStlAlgorithm
for (ReportID report_id : all_reports(g)) { for (ReportID report_id : all_reports(g)) {
if (rm.getReport(report_id).ekey == INVALID_EKEY) { if (rm.getReport(report_id).ekey == INVALID_EKEY) {
return false; return false;

View File

@ -210,6 +210,7 @@ u32 countStates(const unordered_map<NFAVertex, u32> &state_ids) {
u32 max_state = 0; u32 max_state = 0;
for (const auto &m : state_ids) { for (const auto &m : state_ids) {
if (m.second != NO_STATE) { if (m.second != NO_STATE) {
// cppcheck-suppress useStlAlgorithm
max_state = max(m.second, max_state); max_state = max(m.second, max_state);
} }
} }

View File

@ -56,6 +56,7 @@ namespace ue2 {
static static
bool checkFromVertex(const NGHolder &g, NFAVertex start) { bool checkFromVertex(const NGHolder &g, NFAVertex start) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(start, g)) { for (auto v : adjacent_vertices_range(start, g)) {
if (v == g.startDs) { if (v == g.startDs) {
continue; continue;

View File

@ -103,6 +103,7 @@ bool checkLongMixedSensitivityLiterals(
const map<sls_literal, flat_set<ReportID>> &literals) { const map<sls_literal, flat_set<ReportID>> &literals) {
const size_t len = MAX_MASK2_WIDTH; const size_t len = MAX_MASK2_WIDTH;
// cppcheck-suppress useStlAlgorithm
for (const sls_literal &lit : literals | map_keys) { for (const sls_literal &lit : literals | map_keys) {
if (mixed_sensitivity(lit.s) && lit.s.length() > len) { if (mixed_sensitivity(lit.s) && lit.s.length() > len) {
return false; return false;
@ -202,6 +203,7 @@ size_t min_period(const map<sls_literal, flat_set<ReportID>> &literals) {
size_t rv = SIZE_MAX; size_t rv = SIZE_MAX;
for (const sls_literal &lit : literals | map_keys) { for (const sls_literal &lit : literals | map_keys) {
// cppcheck-suppress useStlAlgorithm
rv = min(rv, minStringPeriod(lit.s)); rv = min(rv, minStringPeriod(lit.s));
} }
DEBUG_PRINTF("min period %zu\n", rv); DEBUG_PRINTF("min period %zu\n", rv);

View File

@ -545,6 +545,7 @@ bool finalRegion(const NGHolder &g,
const unordered_map<NFAVertex, u32> &regions, const unordered_map<NFAVertex, u32> &regions,
NFAVertex v) { NFAVertex v) {
u32 region = regions.at(v); u32 region = regions.at(v);
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) { for (auto w : adjacent_vertices_range(v, g)) {
if (w != g.accept && w != g.acceptEod && regions.at(w) != region) { if (w != g.accept && w != g.acceptEod && regions.at(w) != region) {
return false; return false;
@ -2331,6 +2332,7 @@ bool splitOffLeadingLiterals(const NGHolder &g, set<ue2_literal> *lit_out,
assert(!terms.empty()); assert(!terms.empty());
set<NFAVertex> adj_term1; set<NFAVertex> adj_term1;
insert(&adj_term1, adjacent_vertices(*terms.begin(), g)); insert(&adj_term1, adjacent_vertices(*terms.begin(), g));
// cppcheck-suppress useStlAlgorithm
for (auto v : terms) { for (auto v : terms) {
DEBUG_PRINTF("term %zu\n", g[v].index); DEBUG_PRINTF("term %zu\n", g[v].index);
set<NFAVertex> temp; set<NFAVertex> temp;

View File

@ -86,6 +86,7 @@ const DepthMinMax &getDepth(NFAVertex v, const NGHolder &g,
static static
bool hasFloatingPred(NFAVertex v, const NGHolder &g, bool hasFloatingPred(NFAVertex v, const NGHolder &g,
const vector<DepthMinMax> &depths) { const vector<DepthMinMax> &depths) {
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
const DepthMinMax &d = getDepth(u, g, depths); const DepthMinMax &d = getDepth(u, g, depths);
if (d.min != d.max) { if (d.min != d.max) {

View File

@ -151,6 +151,7 @@ bool firstMatchIsFirst(const NGHolder &p) {
/* run the prefix the main graph */ /* run the prefix the main graph */
states = execute_graph(p, p, states); states = execute_graph(p, p, states);
// cppcheck-suppress useStlAlgorithm
for (auto v : states) { for (auto v : states) {
/* need to check if this vertex may represent an infix match - ie /* need to check if this vertex may represent an infix match - ie
* it does not have an edge to accept. */ * it does not have an edge to accept. */
@ -252,6 +253,7 @@ bool somMayGoBackwards(NFAVertex u, const NGHolder &g,
continue; continue;
} }
for (auto v : adjacent_vertices_range(t, g)) { for (auto v : adjacent_vertices_range(t, g)) {
// cppcheck-suppress useStlAlgorithm
if (contains(u_succ, v)) { if (contains(u_succ, v)) {
/* due to virtual starts being aliased with normal starts in the /* due to virtual starts being aliased with normal starts in the
* copy of the graph, we may have already added the edges. */ * copy of the graph, we may have already added the edges. */

View File

@ -281,6 +281,7 @@ void findDerivedSquashers(const NGHolder &g, const vector<NFAVertex> &vByIndex,
smgb_cache &cache) { smgb_cache &cache) {
deque<NFAVertex> remaining; deque<NFAVertex> remaining;
for (const auto &m : *squash) { for (const auto &m : *squash) {
// cppcheck-suppress useStlAlgorithm
remaining.emplace_back(m.first); remaining.emplace_back(m.first);
} }

View File

@ -177,6 +177,7 @@ bool isVacuous(const NGHolder &h) {
} }
bool isAnchored(const NGHolder &g) { bool isAnchored(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(g.startDs, g)) { for (auto v : adjacent_vertices_range(g.startDs, g)) {
if (v != g.startDs) { if (v != g.startDs) {
return false; return false;
@ -186,6 +187,7 @@ bool isAnchored(const NGHolder &g) {
} }
bool isFloating(const NGHolder &g) { bool isFloating(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(g.start, g)) { for (auto v : adjacent_vertices_range(g.start, g)) {
if (v != g.startDs && !edge(g.startDs, v, g).second) { if (v != g.startDs && !edge(g.startDs, v, g).second) {
return false; return false;
@ -228,6 +230,7 @@ bool hasBigCycles(const NGHolder &g) {
boost::depth_first_search(g, backEdgeVisitor, make_small_color_map(g), boost::depth_first_search(g, backEdgeVisitor, make_small_color_map(g),
g.start); g.start);
// cppcheck-suppress useStlAlgorithm
for (const auto &e : dead) { for (const auto &e : dead) {
if (source(e, g) != target(e, g)) { if (source(e, g) != target(e, g)) {
return true; return true;
@ -259,6 +262,7 @@ bool can_match_at_eod(const NGHolder &h) {
return true; return true;
} }
// cppcheck-suppress useStlAlgorithm
for (auto e : in_edges_range(h.accept, h)) { for (auto e : in_edges_range(h.accept, h)) {
if (h[e].assert_flags) { if (h[e].assert_flags) {
DEBUG_PRINTF("edge to accept has assert flags %d\n", DEBUG_PRINTF("edge to accept has assert flags %d\n",

View File

@ -89,9 +89,11 @@ bool createsAnchoredLHS(const NGHolder &g, const vector<NFAVertex> &vv,
const Grey &grey, depth max_depth = depth::infinity()) { const Grey &grey, depth max_depth = depth::infinity()) {
max_depth = min(max_depth, depth(grey.maxAnchoredRegion)); max_depth = min(max_depth, depth(grey.maxAnchoredRegion));
// cppcheck-suppress useStlAlgorithm
for (auto v : vv) { for (auto v : vv) {
/* avoid issues of self loops blowing out depths: /* avoid issues of self loops blowing out depths:
* look at preds, add 1 */ * look at preds, add 1 */
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u == v) { if (u == v) {
continue; continue;
@ -116,9 +118,11 @@ bool createsTransientLHS(const NGHolder &g, const vector<NFAVertex> &vv,
const Grey &grey) { const Grey &grey) {
const depth max_depth(grey.maxHistoryAvailable); const depth max_depth(grey.maxHistoryAvailable);
// cppcheck-suppress useStlAlgorithm
for (auto v : vv) { for (auto v : vv) {
/* avoid issues of self loops blowing out depths: /* avoid issues of self loops blowing out depths:
* look at preds, add 1 */ * look at preds, add 1 */
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) { for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u == v) { if (u == v) {
continue; continue;
@ -162,6 +166,7 @@ u32 min_len(const set<ue2_literal> &s) {
u32 rv = ~0U; u32 rv = ~0U;
for (const auto &lit : s) { for (const auto &lit : s) {
// cppcheck-suppress useStlAlgorithm
rv = min(rv, (u32)lit.length()); rv = min(rv, (u32)lit.length());
} }
@ -173,6 +178,7 @@ u32 min_period(const set<ue2_literal> &s) {
u32 rv = ~0U; u32 rv = ~0U;
for (const auto &lit : s) { for (const auto &lit : s) {
// cppcheck-suppress useStlAlgorithm
rv = min(rv, (u32)minStringPeriod(lit)); rv = min(rv, (u32)minStringPeriod(lit));
} }
DEBUG_PRINTF("min period %u\n", rv); DEBUG_PRINTF("min period %u\n", rv);
@ -394,6 +400,7 @@ void getSimpleRoseLiterals(const NGHolder &g, bool seeking_anchored,
lits->reserve(lit_info.size()); lits->reserve(lit_info.size());
for (auto &m : lit_info) { for (auto &m : lit_info) {
// cppcheck-suppress useStlAlgorithm
lits->emplace_back(std::move(m.second)); lits->emplace_back(std::move(m.second));
} }
DEBUG_PRINTF("%zu candidate literal sets\n", lits->size()); DEBUG_PRINTF("%zu candidate literal sets\n", lits->size());
@ -1196,6 +1203,7 @@ bool checkValidNetflowLits(NGHolder &h, const vector<u64a> &scores,
for (const auto &lit : cut.second) { for (const auto &lit : cut.second) {
if (lit.length() == 2) { if (lit.length() == 2) {
// cppcheck-suppress useStlAlgorithm
len_2_count++; len_2_count++;
} }
} }
@ -1807,6 +1815,7 @@ void removeRedundantLiterals(RoseInGraph &g, const CompileContext &cc) {
static static
RoseInVertex getStart(RoseInGraph &vg) { RoseInVertex getStart(RoseInGraph &vg) {
for (RoseInVertex v : vertices_range(vg)) { for (RoseInVertex v : vertices_range(vg)) {
// cppcheck-suppress useStlAlgorithm
if (vg[v].type == RIV_START || vg[v].type == RIV_ANCHORED_START) { if (vg[v].type == RIV_START || vg[v].type == RIV_ANCHORED_START) {
return v; return v;
} }
@ -1822,6 +1831,7 @@ RoseInVertex getStart(RoseInGraph &vg) {
static static
RoseInVertex getPrimaryAccept(RoseInGraph &vg) { RoseInVertex getPrimaryAccept(RoseInGraph &vg) {
for (RoseInVertex v : vertices_range(vg)) { for (RoseInVertex v : vertices_range(vg)) {
// cppcheck-suppress useStlAlgorithm
if (vg[v].type == RIV_ACCEPT && vg[v].reports.empty()) { if (vg[v].type == RIV_ACCEPT && vg[v].reports.empty()) {
return v; return v;
} }
@ -2833,6 +2843,7 @@ bool doEarlyDfa(RoseBuild &rose, RoseInGraph &vg, NGHolder &h,
DEBUG_PRINTF("trying for dfa\n"); DEBUG_PRINTF("trying for dfa\n");
bool single_trigger; bool single_trigger;
// cppcheck-suppress useStlAlgorithm
for (const auto &e : edges) { for (const auto &e : edges) {
if (vg[target(e, vg)].type == RIV_ACCEPT_EOD) { if (vg[target(e, vg)].type == RIV_ACCEPT_EOD) {
/* TODO: support eod prefixes */ /* TODO: support eod prefixes */

View File

@ -130,6 +130,7 @@ vector<PositionInfo> ComponentAlternation::last() const {
bool ComponentAlternation::empty(void) const { bool ComponentAlternation::empty(void) const {
// an alternation can be empty if any of its components are empty // an alternation can be empty if any of its components are empty
// cppcheck-suppress useStlAlgorithm
for (const auto &c : children) { for (const auto &c : children) {
if (c->empty()) { if (c->empty()) {
return true; return true;
@ -173,6 +174,7 @@ bool ComponentAlternation::checkEmbeddedEndAnchor(bool at_end) const {
} }
bool ComponentAlternation::vacuous_everywhere(void) const { bool ComponentAlternation::vacuous_everywhere(void) const {
// cppcheck-suppress useStlAlgorithm
for (const auto &c : children) { for (const auto &c : children) {
if (c->vacuous_everywhere()) { if (c->vacuous_everywhere()) {
return true; return true;

View File

@ -113,6 +113,7 @@ static
void checkPositions(vector<PositionInfo> &v, const GlushkovBuildState &bs) { void checkPositions(vector<PositionInfo> &v, const GlushkovBuildState &bs) {
const NFABuilder& builder = bs.getBuilder(); const NFABuilder& builder = bs.getBuilder();
for (const auto &e : v) { for (const auto &e : v) {
// cppcheck-suppress useStlAlgorithm
if (builder.isSpecialState(e.pos)) { if (builder.isSpecialState(e.pos)) {
throw ParseError("Embedded anchors not supported."); throw ParseError("Embedded anchors not supported.");
} }
@ -341,6 +342,7 @@ inf_check:
static static
bool hasPositionFlags(const Component &c) { bool hasPositionFlags(const Component &c) {
// cppcheck-suppress useStlAlgorithm
for (const auto &e : c.first()) { for (const auto &e : c.first()) {
if (e.flags) { if (e.flags) {
return true; return true;

View File

@ -253,6 +253,7 @@ vector<PositionInfo> ComponentSequence::last() const {
bool ComponentSequence::empty(void) const { bool ComponentSequence::empty(void) const {
// a sequence can be empty if all its subcomponents can be empty // a sequence can be empty if all its subcomponents can be empty
// cppcheck-suppress useStlAlgorithm
for (const auto &c : children) { for (const auto &c : children) {
if (!c->empty()) { if (!c->empty()) {
return false; return false;
@ -342,6 +343,7 @@ bool ComponentSequence::checkEmbeddedEndAnchor(bool at_end) const {
} }
bool ComponentSequence::vacuous_everywhere() const { bool ComponentSequence::vacuous_everywhere() const {
// cppcheck-suppress useStlAlgorithm
for (const auto &c : children) { for (const auto &c : children) {
if (!c->vacuous_everywhere()) { if (!c->vacuous_everywhere()) {
return false; return false;

View File

@ -175,6 +175,7 @@ void checkEmbeddedEndAnchor(const PositionInfo &from,
} }
for (const auto &first : firsts) { for (const auto &first : firsts) {
// cppcheck-suppress useStlAlgorithm
if (first.pos != GlushkovBuildStateImpl::POS_EPSILON) { if (first.pos != GlushkovBuildStateImpl::POS_EPSILON) {
/* can make it through the parse tree */ /* can make it through the parse tree */
throw ParseError("Embedded end anchors not supported."); throw ParseError("Embedded end anchors not supported.");

View File

@ -241,6 +241,7 @@ RoseRoleHistory selectHistory(const RoseBuildImpl &tbi, const RoseBuildData &bd,
static static
bool hasSuccessorLiterals(RoseInVertex iv, const RoseInGraph &ig) { bool hasSuccessorLiterals(RoseInVertex iv, const RoseInGraph &ig) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(iv, ig)) { for (auto v : adjacent_vertices_range(iv, ig)) {
if (ig[v].type != RIV_ACCEPT) { if (ig[v].type != RIV_ACCEPT) {
return true; return true;
@ -833,6 +834,7 @@ bool suitableForEod(const RoseInGraph &ig, vector<RoseInVertex> topo,
if (ig[v].type == RIV_ACCEPT) { if (ig[v].type == RIV_ACCEPT) {
DEBUG_PRINTF("[ACCEPT]\n"); DEBUG_PRINTF("[ACCEPT]\n");
// cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(v, ig)) { for (const auto &e : in_edges_range(v, ig)) {
if (!ig[e].graph || !can_only_match_at_eod(*ig[e].graph)) { if (!ig[e].graph || !can_only_match_at_eod(*ig[e].graph)) {
DEBUG_PRINTF("floating accept\n"); DEBUG_PRINTF("floating accept\n");
@ -1057,6 +1059,7 @@ static
bool predsAreDelaySensitive(const RoseInGraph &ig, RoseInVertex v) { bool predsAreDelaySensitive(const RoseInGraph &ig, RoseInVertex v) {
assert(in_degree(v, ig)); assert(in_degree(v, ig));
// cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(v, ig)) { for (const auto &e : in_edges_range(v, ig)) {
if (ig[e].graph || ig[e].haig) { if (ig[e].graph || ig[e].haig) {
DEBUG_PRINTF("edge graph\n"); DEBUG_PRINTF("edge graph\n");
@ -1626,6 +1629,7 @@ bool roseCheckRose(const RoseInGraph &ig, bool prefilter,
graphs.emplace_back(ig[e].graph.get()); graphs.emplace_back(ig[e].graph.get());
} }
// cppcheck-suppress useStlAlgorithm
for (const auto &g : graphs) { for (const auto &g : graphs) {
if (!canImplementGraph(*g, prefilter, rm, cc)) { if (!canImplementGraph(*g, prefilter, rm, cc)) {
return false; return false;
@ -1930,6 +1934,7 @@ bool RoseBuildImpl::addAnchoredAcyclic(const NGHolder &h) {
flat_set<u32> added_lit_ids; /* literal ids added for this NFA */ flat_set<u32> added_lit_ids; /* literal ids added for this NFA */
for (auto v : inv_adjacent_vertices_range(h.accept, h)) { for (auto v : inv_adjacent_vertices_range(h.accept, h)) {
// cppcheck-suppress useStlAlgorithm
if (!prepAcceptForAddAnchoredNFA(*this, h, v, vertexDepths, depthMap, if (!prepAcceptForAddAnchoredNFA(*this, h, v, vertexDepths, depthMap,
reportMap, allocated_reports, reportMap, allocated_reports,
added_lit_ids)) { added_lit_ids)) {

View File

@ -241,6 +241,7 @@ bool mergeDfas(vector<unique_ptr<raw_dfa>> &dfas, const ReportManager &rm,
vector<const raw_dfa *> dfa_ptrs; vector<const raw_dfa *> dfa_ptrs;
dfa_ptrs.reserve(dfas.size()); dfa_ptrs.reserve(dfas.size());
for (auto &d : dfas) { for (auto &d : dfas) {
// cppcheck-suppress useStlAlgorithm
dfa_ptrs.emplace_back(d.get()); dfa_ptrs.emplace_back(d.get());
} }
@ -331,6 +332,7 @@ bool add_to_trie(const ue2_literal &literal, ReportID report, LitTrie &trie) {
for (const auto &c : literal) { for (const auto &c : literal) {
auto next = LitTrie::null_vertex(); auto next = LitTrie::null_vertex();
for (auto v : adjacent_vertices_range(u, trie)) { for (auto v : adjacent_vertices_range(u, trie)) {
// cppcheck-suppress useStlAlgorithm
if (trie[v].c == (u8)c.c) { if (trie[v].c == (u8)c.c) {
next = v; next = v;
break; break;
@ -409,6 +411,7 @@ struct ACVisitor : public boost::default_bfs_visitor {
while (u != trie.root) { while (u != trie.root) {
auto f = failure_map.at(u); auto f = failure_map.at(u);
for (auto w : adjacent_vertices_range(f, trie)) { for (auto w : adjacent_vertices_range(f, trie)) {
// cppcheck-suppress useStlAlgorithm
if (trie[w].c == c) { if (trie[w].c == c) {
return w; return w;
} }