Merge pull request #283 from isildur-g/wip-cppcheck271-part2

Wip cppcheck271 useStlAlgorithm part2
This commit is contained in:
Konstantinos Margaritis
2024-05-21 15:52:15 +03:00
committed by GitHub
74 changed files with 251 additions and 24 deletions

View File

@@ -137,6 +137,7 @@ NFAVertex findReformable(const NGHolder &g, const set<NFAVertex> &starts,
static
bool isStartNode(NFAVertex v, NFAVertex start, const NGHolder &g,
bool selfLoopIsAcceptable) {
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (selfLoopIsAcceptable && u == v) {
continue;
@@ -307,6 +308,7 @@ void reformUnanchoredRepeatsComponent(NGHolder &g,
}
for (auto v : otherV) {
// cppcheck-suppress useStlAlgorithm
if (!edge(dotV, v, g).second) {
return;
}
@@ -441,6 +443,7 @@ bool gatherParticipants(const NGHolder &g,
/* All the non chained v connected to start must be in succ as well
* TODO: remember why (and document). */
// cppcheck-suppress useStlAlgorithm
for (auto u : adjacent_vertices_range(start, g)) {
if (is_special(u, g)) {
continue;

View File

@@ -77,17 +77,20 @@ static constexpr u32 MAX_TAIL_SHELL_DEPTH = 3;
* classes.
*/
bool isAlternationOfClasses(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
if (is_special(v, g)) {
continue;
}
// Vertex must have in edges from starts only.
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!is_any_start(u, g)) {
return false;
}
}
// Vertex must have out edges to accepts only.
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (!is_any_accept(w, g)) {
return false;

View File

@@ -157,6 +157,7 @@ vector<bool> findLoopReachable(const Graph &g,
for (auto v : reverse(topoOrder)) {
for (const auto &e : in_edges_range(v, g)) {
// cppcheck-suppress useStlAlgorithm
if (deadNodes[g[source(e, g)].index]) {
deadNodes[g[v].index] = true;
break;

View File

@@ -63,6 +63,7 @@ bool checkVerticesFwd(const NGHolder &g, const set<NFAVertex> &sad,
for (auto u : sad) {
bool ok = false;
for (auto v : adjacent_vertices_range(u, g)) {
// cppcheck-suppress useStlAlgorithm
if (contains(happy, v)) {
ok = true;
break;
@@ -85,6 +86,7 @@ bool checkVerticesRev(const NGHolder &g, const set<NFAVertex> &sad,
for (auto v : sad) {
bool ok = false;
for (auto u : inv_adjacent_vertices_range(v, g)) {
// cppcheck-suppress useStlAlgorithm
if (contains(happy, u)) {
ok = true;
break;

View File

@@ -197,6 +197,7 @@ bool outIsIrreducible(const NFAVertex &v, const NGHolder &g) {
unsigned nonSpecialVertices = 0;
for (auto w : adjacent_vertices_range(v, g)) {
if (!is_special(w, g) && w != v) {
// cppcheck-suppress useStlAlgorithm
nonSpecialVertices++;
}
}
@@ -208,6 +209,7 @@ bool inIsIrreducible(const NFAVertex &v, const NGHolder &g) {
unsigned nonSpecialVertices = 0;
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!is_special(u, g) && u != v) {
// cppcheck-suppress useStlAlgorithm
nonSpecialVertices++;
}
}

View File

@@ -131,6 +131,7 @@ void checkVertex(const ReportManager &rm, const NGHolder &g, NFAVertex v,
static
bool hasOffsetAdjust(const ReportManager &rm, const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (const auto &report_id : all_reports(g)) {
if (rm.getReport(report_id).offsetAdjust) {
return true;

View File

@@ -75,6 +75,7 @@ bool hasSameBounds(const Container &reports, const ReportManager &rm) {
assert(!reports.empty());
const auto &first = rm.getReport(*reports.begin());
// cppcheck-suppress useStlAlgorithm
for (auto id : reports) {
const auto &report = rm.getReport(id);
if (report.minOffset != first.minOffset ||
@@ -225,6 +226,7 @@ void updateReportBounds(ReportManager &rm, NGHolder &g,
static
bool hasVirtualStarts(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(g.start, g)) {
if (g[v].assert_flags & POS_FLAG_VIRTUAL_START) {
return true;
@@ -439,6 +441,7 @@ bool hasOffsetAdjust(const ReportManager &rm, const NGHolder &g,
}
int offsetAdjust = rm.getReport(*reports.begin()).offsetAdjust;
// cppcheck-suppress useStlAlgorithm
for (auto report : reports) {
const Report &ir = rm.getReport(report);
if (ir.offsetAdjust != offsetAdjust) {

View File

@@ -674,6 +674,7 @@ void validate_fuzzy_compile(const NGHolder &g, u32 edit_distance, bool hamming,
}
// graph isn't fuzzable if there are edge assertions anywhere in the graph
for (auto e : edges_range(g)) {
// cppcheck-suppress useStlAlgorithm
if (g[e].assert_flags) {
throw CompileError("Zero-width assertions are disallowed for "
"approximate matching.");

View File

@@ -453,6 +453,7 @@ void haig_do_preds(const NGHolder &g, const stateset &nfa_states,
DEBUG_PRINTF("d vertex %zu\n", g[v].index);
vector<u32> &out_map = preds[slot_id];
for (auto u : inv_adjacent_vertices_range(v, g)) {
// cppcheck-suppress useStlAlgorithm
out_map.emplace_back(g[u].index);
}

View File

@@ -172,9 +172,11 @@ bool is_equal_i(const NGHolder &a, const NGHolder &b,
vector<pair<u32, flat_set<u32>>> top_b;
for (const auto &e : out_edges_range(a.start, a)) {
// cppcheck-suppress useStlAlgorithm
top_a.emplace_back(a[target(e, a)].index, a[e].tops);
}
for (const auto &e : out_edges_range(b.start, b)) {
// cppcheck-suppress useStlAlgorithm
top_b.emplace_back(b[target(e, b)].index, b[e].tops);
}

View File

@@ -46,6 +46,7 @@
#include <algorithm>
#include <fstream>
#include <numeric>
#include <queue>
#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
@@ -359,6 +360,7 @@ u64a litUniqueness(const string &s) {
static
u64a litCountBits(const ue2_literal &lit) {
u64a n = 0;
// cppcheck-suppress useStlAlgorithm
for (const auto &c : lit) {
n += c.nocase ? 7 : 8;
}
@@ -670,10 +672,8 @@ u64a scoreSet(const set<ue2_literal> &s) {
}
u64a score = 1ULL;
for (const auto &lit : s) {
score += calculateScore(lit);
}
auto cscore = [](u64a z, const ue2_literal &lit) { return z + calculateScore(lit); };
score += std::accumulate(s.begin(), s.end(), 0, cscore);
return score;
}

View File

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

View File

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

View File

@@ -154,6 +154,7 @@ static
bool triggerResetsPuff(const NGHolder &g, NFAVertex head) {
const CharReach puff_escapes = ~g[head].char_reach;
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(head, g)) {
if (!g[u].char_reach.isSubsetOf(puff_escapes)) {
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);
}
// cppcheck-suppress useStlAlgorithm
for (auto s : inv_adjacent_vertices_range(head, g)) {
DEBUG_PRINTF("s = %zu\n", g[s].index);
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 */
for (auto u : inv_adjacent_vertices_range(pv, g)) {
// cppcheck-suppress useStlAlgorithm
accept_cr |= g[u].char_reach;
}
@@ -365,6 +368,7 @@ bool doComponent(RoseBuild &rose, ReportManager &rm, NGHolder &g, NFAVertex a,
if (!nodes.empty() && proper_in_degree(nodes.back(), g) != 1) {
for (auto u : inv_adjacent_vertices_range(nodes.back(), g)) {
// cppcheck-suppress useStlAlgorithm
if (is_special(u, g)) {
DEBUG_PRINTF("pop\n");
a = nodes.back();
@@ -451,6 +455,7 @@ bool doComponent(RoseBuild &rose, ReportManager &rm, NGHolder &g, NFAVertex a,
const auto &reports = g[nodes[0]].reports;
assert(!reports.empty());
// cppcheck-suppress useStlAlgorithm
for (auto report : reports) {
const Report &ir = rm.getReport(report);
const bool highlander = ir.ekey != INVALID_EKEY;
@@ -497,6 +502,7 @@ bool splitOffPuffs(RoseBuild &rose, ReportManager &rm, NGHolder &g,
for (auto v : inv_adjacent_vertices_range(g.accept, g)) {
if (doComponent(rose, rm, g, v, dead, cc, prefilter)) {
// cppcheck-suppress useStlAlgorithm
count++;
}
}

View File

@@ -684,6 +684,7 @@ bool forwardPathReachSubset(const NFAEdge &e, const NFAVertex &dom,
static
bool allOutsSpecial(NFAVertex v, const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (!is_special(w, g)) {
return false;
@@ -694,6 +695,7 @@ bool allOutsSpecial(NFAVertex v, const NGHolder &g) {
static
bool allInsSpecial(NFAVertex v, const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!is_special(u, g)) {
return false;
@@ -706,6 +708,7 @@ bool allInsSpecial(NFAVertex v, const NGHolder &g) {
* just a chain of vertices with no other edges. */
static
bool isIrreducible(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
// skip specials
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) {
// cppcheck-suppress useStlAlgorithm
if (it->open != enters) {
return false;
}

View File

@@ -141,12 +141,14 @@ bool isRegionExit(const Graph &g, NFAVertex v,
template <class Graph>
bool isSingletonRegion(const Graph &g, NFAVertex v,
const std::unordered_map<NFAVertex, u32> &region_map) {
// cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(v, g)) {
auto u = source(e, g);
if (u != v && inSameRegion(g, v, u, region_map)) {
return false;
}
// cppcheck-suppress useStlAlgorithm
for (auto w : ue2::adjacent_vertices_range(u, g)) {
if (w != v && inSameRegion(g, v, w, region_map)) {
return false;
@@ -154,11 +156,13 @@ bool isSingletonRegion(const Graph &g, NFAVertex v,
}
}
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (w != v && inSameRegion(g, v, w, region_map)) {
return false;
}
// cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(w, g)) {
auto u = source(e, g);
if (u != v && inSameRegion(g, v, u, region_map)) {
@@ -201,7 +205,7 @@ bool isOptionalRegion(const Graph &g, NFAVertex v,
DEBUG_PRINTF(" searching from u=%zu\n", g[u].index);
assert(inEarlierRegion(g, v, u, region_map));
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(u, g)) {
DEBUG_PRINTF(" searching to w=%zu\n", g[w].index);
if (inLaterRegion(g, v, w, region_map)) {

View File

@@ -62,6 +62,7 @@ bool regionHasUnexpectedAccept(const NGHolder &g, const u32 region,
const flat_set<ReportID> &expected_reports,
const unordered_map<NFAVertex, u32> &region_map) {
/* TODO: only check vertices connected to accept/acceptEOD */
// cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
if (region != region_map.at(v)) {
continue;
@@ -71,7 +72,7 @@ bool regionHasUnexpectedAccept(const NGHolder &g, const u32 region,
return true; /* encountering an actual special in the region is
* possible but definitely unexpected */
}
// cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (is_any_accept(w, g) && g[v].reports != expected_reports) {
return true;
@@ -200,6 +201,7 @@ map<u32, RegionInfo> buildRegionInfoMap(const NGHolder &g,
static
bool hasNoStartAnchoring(const NGHolder &h) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(h.start, h)) {
if (!edge(h.startDs, v, h).second) {
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
// our subgraph. The tail set contains all vertices that are after v in a
// topo ordering.
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (contains(tail, u)) {
DEBUG_PRINTF("back-edge (%zu,%zu) in subgraph found\n",
@@ -343,6 +344,7 @@ static
void findFirstReports(const NGHolder &g, const ReachSubgraph &rsi,
flat_set<ReportID> &reports) {
for (auto v : rsi.vertices) {
// cppcheck-suppress useStlAlgorithm
if (is_match_vertex(v, g)) {
reports = g[v].reports;
return;
@@ -620,6 +622,7 @@ bool processSubgraph(const NGHolder &g, ReachSubgraph &rsi,
static
bool allPredsInSubgraph(NFAVertex v, const NGHolder &g,
const unordered_set<NFAVertex> &involved) {
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!contains(involved, u)) {
return false;
@@ -688,6 +691,7 @@ u32 isCloseToAccept(const NGHolder &g, NFAVertex v) {
}
for (auto w : adjacent_vertices_range(v, g)) {
// cppcheck-suppress useStlAlgorithm
if (is_any_accept(w, g)) {
return 1;
}
@@ -702,6 +706,7 @@ u32 unpeelAmount(const NGHolder &g, const ReachSubgraph &rsi) {
u32 rv = 0;
for (auto v : adjacent_vertices_range(last, g)) {
// cppcheck-suppress useStlAlgorithm
rv = max(rv, isCloseToAccept(g, v));
}
@@ -993,6 +998,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
// no-no.
// cppcheck-suppress useStlAlgorithm
for (auto v : rsi.vertices) {
if (contains(created, v)) {
DEBUG_PRINTF("vertex %zu is in another repeat\n", g[v].index);
@@ -1073,7 +1079,9 @@ bool hasSkipEdges(const NGHolder &g, const ReachSubgraph &rsi) {
const NFAVertex last = rsi.vertices.back();
// 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)) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(last, g)) {
if (!edge(u, v, g).second) {
return false;
@@ -1112,6 +1120,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());
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
const depth &u_max_depth = depths.at(u).fromStart.max;
DEBUG_PRINTF("pred %zu max depth %s from start\n", g[u].index,
@@ -1202,6 +1211,7 @@ static
CharReach predReach(const NGHolder &g, NFAVertex v) {
CharReach cr;
for (auto u : inv_adjacent_vertices_range(v, g)) {
// cppcheck-suppress useStlAlgorithm
cr |= g[u].char_reach;
}
return cr;
@@ -1429,6 +1439,7 @@ struct StrawWalker {
* inf max bound). */
bool isBoundedRepeatCyclic(NFAVertex v) const {
for (const auto &r : repeats) {
// cppcheck-suppress useStlAlgorithm
if (r.repeatMax.is_finite() && r.cyclic == v) {
return true;
}
@@ -1578,6 +1589,7 @@ bool hasCyclicSupersetExitPath(const NGHolder &g, const ReachSubgraph &rsi,
static
bool leadsOnlyToAccept(const NGHolder &g, const ReachSubgraph &rsi) {
const NFAVertex u = rsi.vertices.back();
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(u, g)) {
if (v != g.accept) {
return false;
@@ -1591,6 +1603,7 @@ static
bool allSimpleHighlander(const ReportManager &rm,
const flat_set<ReportID> &reports) {
assert(!reports.empty());
// cppcheck-suppress useStlAlgorithm
for (auto report : reports) {
if (!isSimpleExhaustible(rm.getReport(report))) {
return false;
@@ -1907,6 +1920,7 @@ bool improveLeadingRepeat(NGHolder &g, const BoundedRepeatData &rd,
DEBUG_PRINTF("startDs has other successors\n");
return false;
}
// cppcheck-suppress useStlAlgorithm
for (const auto &v : straw) {
if (proper_out_degree(v, g) != 1) {
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. */
bool can_exhaust(const NGHolder &g, const ReportManager &rm) {
// cppcheck-suppress useStlAlgorithm
for (ReportID report_id : all_reports(g)) {
if (rm.getReport(report_id).ekey == INVALID_EKEY) {
return false;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -280,9 +280,8 @@ void findDerivedSquashers(const NGHolder &g, const vector<NFAVertex> &vByIndex,
const unordered_map<NFAVertex, u32> &region_map,
smgb_cache &cache) {
deque<NFAVertex> remaining;
for (const auto &m : *squash) {
remaining.emplace_back(m.first);
}
auto mfirst = [](const pair<NFAVertex, NFAStateSet> &m) { return m.first; };
std::transform(squash->begin(), squash->end(), std::back_inserter(remaining), mfirst);
while (!remaining.empty()) {
NFAVertex v = remaining.back();

View File

@@ -177,6 +177,7 @@ bool isVacuous(const NGHolder &h) {
}
bool isAnchored(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(g.startDs, g)) {
if (v != g.startDs) {
return false;
@@ -186,6 +187,7 @@ bool isAnchored(const NGHolder &g) {
}
bool isFloating(const NGHolder &g) {
// cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(g.start, g)) {
if (v != g.startDs && !edge(g.startDs, v, g).second) {
return false;
@@ -228,6 +230,7 @@ bool hasBigCycles(const NGHolder &g) {
boost::depth_first_search(g, backEdgeVisitor, make_small_color_map(g),
g.start);
// cppcheck-suppress useStlAlgorithm
for (const auto &e : dead) {
if (source(e, g) != target(e, g)) {
return true;
@@ -259,6 +262,7 @@ bool can_match_at_eod(const NGHolder &h) {
return true;
}
// cppcheck-suppress useStlAlgorithm
for (auto e : in_edges_range(h.accept, h)) {
if (h[e].assert_flags) {
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()) {
max_depth = min(max_depth, depth(grey.maxAnchoredRegion));
// cppcheck-suppress useStlAlgorithm
for (auto v : vv) {
/* avoid issues of self loops blowing out depths:
* look at preds, add 1 */
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u == v) {
continue;
@@ -116,9 +118,11 @@ bool createsTransientLHS(const NGHolder &g, const vector<NFAVertex> &vv,
const Grey &grey) {
const depth max_depth(grey.maxHistoryAvailable);
// cppcheck-suppress useStlAlgorithm
for (auto v : vv) {
/* avoid issues of self loops blowing out depths:
* look at preds, add 1 */
// cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u == v) {
continue;
@@ -162,6 +166,7 @@ u32 min_len(const set<ue2_literal> &s) {
u32 rv = ~0U;
for (const auto &lit : s) {
// cppcheck-suppress useStlAlgorithm
rv = min(rv, (u32)lit.length());
}
@@ -173,6 +178,7 @@ u32 min_period(const set<ue2_literal> &s) {
u32 rv = ~0U;
for (const auto &lit : s) {
// cppcheck-suppress useStlAlgorithm
rv = min(rv, (u32)minStringPeriod(lit));
}
DEBUG_PRINTF("min period %u\n", rv);
@@ -393,6 +399,7 @@ void getSimpleRoseLiterals(const NGHolder &g, bool seeking_anchored,
lits->reserve(lit_info.size());
for (auto &m : lit_info) {
// cppcheck-suppress useStlAlgorithm
lits->emplace_back(std::move(m.second));
}
DEBUG_PRINTF("%zu candidate literal sets\n", lits->size());
@@ -1190,6 +1197,7 @@ bool checkValidNetflowLits(const NGHolder &h, const vector<u64a> &scores,
for (const auto &lit : cut.second) {
if (lit.length() == 2) {
// cppcheck-suppress useStlAlgorithm
len_2_count++;
}
}
@@ -1795,6 +1803,7 @@ void removeRedundantLiterals(RoseInGraph &g, const CompileContext &cc) {
static
RoseInVertex getStart(const RoseInGraph &vg) {
for (RoseInVertex v : vertices_range(vg)) {
// cppcheck-suppress useStlAlgorithm
if (vg[v].type == RIV_START || vg[v].type == RIV_ANCHORED_START) {
return v;
}
@@ -1810,6 +1819,7 @@ RoseInVertex getStart(const RoseInGraph &vg) {
static
RoseInVertex getPrimaryAccept(RoseInGraph &vg) {
for (RoseInVertex v : vertices_range(vg)) {
// cppcheck-suppress useStlAlgorithm
if (vg[v].type == RIV_ACCEPT && vg[v].reports.empty()) {
return v;
}
@@ -2818,6 +2828,7 @@ bool doEarlyDfa(RoseBuild &rose, RoseInGraph &vg, NGHolder &h,
DEBUG_PRINTF("trying for dfa\n");
bool single_trigger;
// cppcheck-suppress useStlAlgorithm
for (const auto &e : edges) {
if (vg[target(e, vg)].type == RIV_ACCEPT_EOD) {
/* TODO: support eod prefixes */