From c482c05fa83b4bc93d40edacaf23645c9c5849b9 Mon Sep 17 00:00:00 2001 From: "G.E" Date: Fri, 17 May 2024 00:08:37 +0300 Subject: [PATCH] next batch --- src/nfagraph/ng_literal_analysis.cpp | 3 --- src/nfagraph/ng_misc_opt.cpp | 6 ++++++ src/nfagraph/ng_prune.cpp | 2 ++ src/nfagraph/ng_puff.cpp | 6 ++++++ src/nfagraph/ng_redundancy.cpp | 3 +++ src/nfagraph/ng_region.cpp | 1 + src/nfagraph/ng_region_redundancy.cpp | 4 +++- src/nfagraph/ng_repeat.cpp | 14 ++++++++++++++ src/nfagraph/ng_reports.cpp | 1 + src/nfagraph/ng_restructuring.cpp | 1 + src/nfagraph/ng_sep.cpp | 1 + src/nfagraph/ng_small_literal_set.cpp | 2 ++ src/nfagraph/ng_som.cpp | 2 ++ src/nfagraph/ng_som_add_redundancy.cpp | 1 + src/nfagraph/ng_som_util.cpp | 2 ++ src/nfagraph/ng_squash.cpp | 1 + src/nfagraph/ng_util.cpp | 4 ++++ src/nfagraph/ng_violet.cpp | 11 +++++++++++ src/parser/ComponentAlternation.cpp | 2 ++ src/parser/ComponentRepeat.cpp | 2 ++ src/parser/ComponentSequence.cpp | 2 ++ src/parser/buildstate.cpp | 1 + src/rose/rose_build_add.cpp | 5 +++++ src/smallwrite/smallwrite_build.cpp | 3 +++ 24 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/nfagraph/ng_literal_analysis.cpp b/src/nfagraph/ng_literal_analysis.cpp index ee3870dd..9fdd8e65 100644 --- a/src/nfagraph/ng_literal_analysis.cpp +++ b/src/nfagraph/ng_literal_analysis.cpp @@ -674,9 +674,6 @@ u64a scoreSet(const set &s) { u64a score = 1ULL; auto cscore = [](u64a z, const ue2_literal &lit) { return z + calculateScore(lit); }; score += std::accumulate(s.begin(), s.end(), 0, cscore); - // for (const auto &lit : s) { - // score += calculateScore(lit); - // } return score; } diff --git a/src/nfagraph/ng_misc_opt.cpp b/src/nfagraph/ng_misc_opt.cpp index 2b898cf7..99c98a81 100644 --- a/src/nfagraph/ng_misc_opt.cpp +++ b/src/nfagraph/ng_misc_opt.cpp @@ -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 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 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; } } diff --git a/src/nfagraph/ng_prune.cpp b/src/nfagraph/ng_prune.cpp index 73d7e64b..042807fa 100644 --- a/src/nfagraph/ng_prune.cpp +++ b/src/nfagraph/ng_prune.cpp @@ -251,12 +251,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; diff --git a/src/nfagraph/ng_puff.cpp b/src/nfagraph/ng_puff.cpp index 9b03f4c0..33bb2a9e 100644 --- a/src/nfagraph/ng_puff.cpp +++ b/src/nfagraph/ng_puff.cpp @@ -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; } @@ -367,6 +370,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(); @@ -453,6 +457,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; @@ -499,6 +504,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++; } } diff --git a/src/nfagraph/ng_redundancy.cpp b/src/nfagraph/ng_redundancy.cpp index a499a40d..6e89c5c8 100644 --- a/src/nfagraph/ng_redundancy.cpp +++ b/src/nfagraph/ng_redundancy.cpp @@ -682,6 +682,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; @@ -692,6 +693,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; @@ -704,6 +706,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)) { diff --git a/src/nfagraph/ng_region.cpp b/src/nfagraph/ng_region.cpp index 1d5bc164..b53e6849 100644 --- a/src/nfagraph/ng_region.cpp +++ b/src/nfagraph/ng_region.cpp @@ -153,6 +153,7 @@ bool exitValid(UNUSED const AcyclicGraph &g, const vector &exits, } for (auto it = begin(exits) + 1; it != end(exits); ++it) { + // cppcheck-suppress useStlAlgorithm if (it->open != enters) { return false; } diff --git a/src/nfagraph/ng_region_redundancy.cpp b/src/nfagraph/ng_region_redundancy.cpp index a3ea558f..e876a1bd 100644 --- a/src/nfagraph/ng_region_redundancy.cpp +++ b/src/nfagraph/ng_region_redundancy.cpp @@ -62,6 +62,7 @@ bool regionHasUnexpectedAccept(const NGHolder &g, const u32 region, const flat_set &expected_reports, const unordered_map ®ion_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 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; diff --git a/src/nfagraph/ng_repeat.cpp b/src/nfagraph/ng_repeat.cpp index 2aa31808..a0c2735f 100644 --- a/src/nfagraph/ng_repeat.cpp +++ b/src/nfagraph/ng_repeat.cpp @@ -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 &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 &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)); } @@ -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 // 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); @@ -1075,7 +1081,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; @@ -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()); + // 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, @@ -1204,6 +1213,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; @@ -1431,6 +1441,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; } @@ -1580,6 +1591,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; @@ -1593,6 +1605,7 @@ static bool allSimpleHighlander(const ReportManager &rm, const flat_set &reports) { assert(!reports.empty()); + // cppcheck-suppress useStlAlgorithm for (auto report : reports) { if (!isSimpleExhaustible(rm.getReport(report))) { return false; @@ -1909,6 +1922,7 @@ bool improveLeadingRepeat(NGHolder &g, 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", diff --git a/src/nfagraph/ng_reports.cpp b/src/nfagraph/ng_reports.cpp index 4e9b498d..c990a57a 100644 --- a/src/nfagraph/ng_reports.cpp +++ b/src/nfagraph/ng_reports.cpp @@ -56,6 +56,7 @@ set 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; diff --git a/src/nfagraph/ng_restructuring.cpp b/src/nfagraph/ng_restructuring.cpp index 73b4d23e..50c4d64d 100644 --- a/src/nfagraph/ng_restructuring.cpp +++ b/src/nfagraph/ng_restructuring.cpp @@ -210,6 +210,7 @@ u32 countStates(const unordered_map &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); } } diff --git a/src/nfagraph/ng_sep.cpp b/src/nfagraph/ng_sep.cpp index 86528b4a..a328679a 100644 --- a/src/nfagraph/ng_sep.cpp +++ b/src/nfagraph/ng_sep.cpp @@ -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; diff --git a/src/nfagraph/ng_small_literal_set.cpp b/src/nfagraph/ng_small_literal_set.cpp index 9c2d9ba3..d2efbc89 100644 --- a/src/nfagraph/ng_small_literal_set.cpp +++ b/src/nfagraph/ng_small_literal_set.cpp @@ -103,6 +103,7 @@ bool checkLongMixedSensitivityLiterals( const map> &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> &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); diff --git a/src/nfagraph/ng_som.cpp b/src/nfagraph/ng_som.cpp index 359fa17b..d40bbdef 100644 --- a/src/nfagraph/ng_som.cpp +++ b/src/nfagraph/ng_som.cpp @@ -545,6 +545,7 @@ bool finalRegion(const NGHolder &g, const unordered_map ®ions, 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 *lit_out, assert(!terms.empty()); set 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 temp; diff --git a/src/nfagraph/ng_som_add_redundancy.cpp b/src/nfagraph/ng_som_add_redundancy.cpp index 871679d9..50b49abd 100644 --- a/src/nfagraph/ng_som_add_redundancy.cpp +++ b/src/nfagraph/ng_som_add_redundancy.cpp @@ -86,6 +86,7 @@ const DepthMinMax &getDepth(NFAVertex v, const NGHolder &g, static bool hasFloatingPred(NFAVertex v, const NGHolder &g, const vector &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) { diff --git a/src/nfagraph/ng_som_util.cpp b/src/nfagraph/ng_som_util.cpp index 82277c06..f2501c76 100644 --- a/src/nfagraph/ng_som_util.cpp +++ b/src/nfagraph/ng_som_util.cpp @@ -151,6 +151,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. */ @@ -252,6 +253,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. */ diff --git a/src/nfagraph/ng_squash.cpp b/src/nfagraph/ng_squash.cpp index 0b51792b..eba642dc 100644 --- a/src/nfagraph/ng_squash.cpp +++ b/src/nfagraph/ng_squash.cpp @@ -281,6 +281,7 @@ void findDerivedSquashers(const NGHolder &g, const vector &vByIndex, smgb_cache &cache) { deque remaining; for (const auto &m : *squash) { + // cppcheck-suppress useStlAlgorithm remaining.emplace_back(m.first); } diff --git a/src/nfagraph/ng_util.cpp b/src/nfagraph/ng_util.cpp index b1d39d2e..d6a90146 100644 --- a/src/nfagraph/ng_util.cpp +++ b/src/nfagraph/ng_util.cpp @@ -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", diff --git a/src/nfagraph/ng_violet.cpp b/src/nfagraph/ng_violet.cpp index 02461e98..635f9400 100644 --- a/src/nfagraph/ng_violet.cpp +++ b/src/nfagraph/ng_violet.cpp @@ -89,9 +89,11 @@ bool createsAnchoredLHS(const NGHolder &g, const vector &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 &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 &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 &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); @@ -394,6 +400,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()); @@ -1196,6 +1203,7 @@ bool checkValidNetflowLits(NGHolder &h, const vector &scores, for (const auto &lit : cut.second) { if (lit.length() == 2) { + // cppcheck-suppress useStlAlgorithm len_2_count++; } } @@ -1807,6 +1815,7 @@ void removeRedundantLiterals(RoseInGraph &g, const CompileContext &cc) { static RoseInVertex getStart(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; } @@ -1822,6 +1831,7 @@ RoseInVertex getStart(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; } @@ -2833,6 +2843,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 */ diff --git a/src/parser/ComponentAlternation.cpp b/src/parser/ComponentAlternation.cpp index e38c9ce7..2eee705a 100644 --- a/src/parser/ComponentAlternation.cpp +++ b/src/parser/ComponentAlternation.cpp @@ -130,6 +130,7 @@ vector ComponentAlternation::last() const { bool ComponentAlternation::empty(void) const { // an alternation can be empty if any of its components are empty + // cppcheck-suppress useStlAlgorithm for (const auto &c : children) { if (c->empty()) { return true; @@ -173,6 +174,7 @@ bool ComponentAlternation::checkEmbeddedEndAnchor(bool at_end) const { } bool ComponentAlternation::vacuous_everywhere(void) const { + // cppcheck-suppress useStlAlgorithm for (const auto &c : children) { if (c->vacuous_everywhere()) { return true; diff --git a/src/parser/ComponentRepeat.cpp b/src/parser/ComponentRepeat.cpp index 7090459f..f4c7e370 100644 --- a/src/parser/ComponentRepeat.cpp +++ b/src/parser/ComponentRepeat.cpp @@ -113,6 +113,7 @@ static void checkPositions(vector &v, const GlushkovBuildState &bs) { const NFABuilder& builder = bs.getBuilder(); for (const auto &e : v) { + // cppcheck-suppress useStlAlgorithm if (builder.isSpecialState(e.pos)) { throw ParseError("Embedded anchors not supported."); } @@ -341,6 +342,7 @@ inf_check: static bool hasPositionFlags(const Component &c) { + // cppcheck-suppress useStlAlgorithm for (const auto &e : c.first()) { if (e.flags) { return true; diff --git a/src/parser/ComponentSequence.cpp b/src/parser/ComponentSequence.cpp index 2b78177b..40f41225 100644 --- a/src/parser/ComponentSequence.cpp +++ b/src/parser/ComponentSequence.cpp @@ -253,6 +253,7 @@ vector ComponentSequence::last() const { bool ComponentSequence::empty(void) const { // a sequence can be empty if all its subcomponents can be empty + // cppcheck-suppress useStlAlgorithm for (const auto &c : children) { if (!c->empty()) { return false; @@ -342,6 +343,7 @@ bool ComponentSequence::checkEmbeddedEndAnchor(bool at_end) const { } bool ComponentSequence::vacuous_everywhere() const { + // cppcheck-suppress useStlAlgorithm for (const auto &c : children) { if (!c->vacuous_everywhere()) { return false; diff --git a/src/parser/buildstate.cpp b/src/parser/buildstate.cpp index 96f91cb6..5bdd0f14 100644 --- a/src/parser/buildstate.cpp +++ b/src/parser/buildstate.cpp @@ -175,6 +175,7 @@ void checkEmbeddedEndAnchor(const PositionInfo &from, } for (const auto &first : firsts) { + // cppcheck-suppress useStlAlgorithm if (first.pos != GlushkovBuildStateImpl::POS_EPSILON) { /* can make it through the parse tree */ throw ParseError("Embedded end anchors not supported."); diff --git a/src/rose/rose_build_add.cpp b/src/rose/rose_build_add.cpp index 5aed21f5..3f27dba1 100644 --- a/src/rose/rose_build_add.cpp +++ b/src/rose/rose_build_add.cpp @@ -241,6 +241,7 @@ RoseRoleHistory selectHistory(const RoseBuildImpl &tbi, const RoseBuildData &bd, static bool hasSuccessorLiterals(RoseInVertex iv, const RoseInGraph &ig) { + // cppcheck-suppress useStlAlgorithm for (auto v : adjacent_vertices_range(iv, ig)) { if (ig[v].type != RIV_ACCEPT) { return true; @@ -833,6 +834,7 @@ bool suitableForEod(const RoseInGraph &ig, vector topo, if (ig[v].type == RIV_ACCEPT) { DEBUG_PRINTF("[ACCEPT]\n"); + // cppcheck-suppress useStlAlgorithm for (const auto &e : in_edges_range(v, ig)) { if (!ig[e].graph || !can_only_match_at_eod(*ig[e].graph)) { DEBUG_PRINTF("floating accept\n"); @@ -1057,6 +1059,7 @@ static bool predsAreDelaySensitive(const RoseInGraph &ig, RoseInVertex v) { assert(in_degree(v, ig)); + // cppcheck-suppress useStlAlgorithm for (const auto &e : in_edges_range(v, ig)) { if (ig[e].graph || ig[e].haig) { DEBUG_PRINTF("edge graph\n"); @@ -1626,6 +1629,7 @@ bool roseCheckRose(const RoseInGraph &ig, bool prefilter, graphs.emplace_back(ig[e].graph.get()); } + // cppcheck-suppress useStlAlgorithm for (const auto &g : graphs) { if (!canImplementGraph(*g, prefilter, rm, cc)) { return false; @@ -1930,6 +1934,7 @@ bool RoseBuildImpl::addAnchoredAcyclic(const NGHolder &h) { flat_set added_lit_ids; /* literal ids added for this NFA */ for (auto v : inv_adjacent_vertices_range(h.accept, h)) { + // cppcheck-suppress useStlAlgorithm if (!prepAcceptForAddAnchoredNFA(*this, h, v, vertexDepths, depthMap, reportMap, allocated_reports, added_lit_ids)) { diff --git a/src/smallwrite/smallwrite_build.cpp b/src/smallwrite/smallwrite_build.cpp index e1d2f1f3..df8b73f2 100644 --- a/src/smallwrite/smallwrite_build.cpp +++ b/src/smallwrite/smallwrite_build.cpp @@ -241,6 +241,7 @@ bool mergeDfas(vector> &dfas, const ReportManager &rm, vector dfa_ptrs; dfa_ptrs.reserve(dfas.size()); for (auto &d : dfas) { + // cppcheck-suppress useStlAlgorithm 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) { auto next = LitTrie::null_vertex(); for (auto v : adjacent_vertices_range(u, trie)) { + // cppcheck-suppress useStlAlgorithm if (trie[v].c == (u8)c.c) { next = v; break; @@ -409,6 +411,7 @@ struct ACVisitor : public boost::default_bfs_visitor { while (u != trie.root) { auto f = failure_map.at(u); for (auto w : adjacent_vertices_range(f, trie)) { + // cppcheck-suppress useStlAlgorithm if (trie[w].c == c) { return w; }