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;
}
add.setall();
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u != v) {
+ // cppcheck-suppress useStlAlgorithm
add &= g[u].char_reach;
}
}
add.setall();
for (auto u : adjacent_vertices_range(v, g)) {
if (u != v) {
+ // cppcheck-suppress useStlAlgorithm
add &= g[u].char_reach;
}
}
CharReach sus_cr;
for (auto v : adjacent_vertices_range(u, g)) {
if (contains(cand, v)) {
+ // cppcheck-suppress useStlAlgorithm
sus_cr |= g[v].char_reach;
}
}
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;
}
}
CharReach sustain_cr;
for (auto pv : adjacent_vertices_range(pp, g)) {
if (contains(sustain, pv)) {
+ // cppcheck-suppress useStlAlgorithm
sustain_cr |= g[pv].char_reach;
}
}
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;
}
}
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;
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,
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)) {
/* 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;
}
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();
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;
for (auto v : inv_adjacent_vertices_range(g.accept, g)) {
if (doComponent(rose, rm, g, v, dead, cc, prefilter)) {
+ // cppcheck-suppress useStlAlgorithm
count++;
}
}
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;
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;
* 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)) {
}
for (auto it = begin(exits) + 1; it != end(exits); ++it) {
+ // cppcheck-suppress useStlAlgorithm
if (it->open != enters) {
return false;
}
const flat_set<ReportID> &expected_reports,
const unordered_map<NFAVertex, u32> ®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;
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;
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;
// 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",
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;
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;
}
for (auto w : adjacent_vertices_range(v, g)) {
+ // cppcheck-suppress useStlAlgorithm
if (is_any_accept(w, g)) {
return 1;
}
u32 rv = 0;
for (auto v : adjacent_vertices_range(last, g)) {
+ // cppcheck-suppress useStlAlgorithm
rv = max(rv, isCloseToAccept(g, v));
}
// 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);
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;
}
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,
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;
* 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;
}
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;
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;
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",
/** 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;
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);
}
}
static
bool checkFromVertex(const NGHolder &g, NFAVertex start) {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(start, g)) {
if (v == g.startDs) {
continue;
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;
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);
const unordered_map<NFAVertex, u32> ®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;
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;
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) {
/* 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. */
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. */
smgb_cache &cache) {
deque<NFAVertex> remaining;
for (const auto &m : *squash) {
+ // cppcheck-suppress useStlAlgorithm
remaining.emplace_back(m.first);
}
}
bool isAnchored(const NGHolder &g) {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(g.startDs, g)) {
if (v != g.startDs) {
return false;
}
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;
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;
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",
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;
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;
u32 rv = ~0U;
for (const auto &lit : s) {
+ // cppcheck-suppress useStlAlgorithm
rv = min(rv, (u32)lit.length());
}
u32 rv = ~0U;
for (const auto &lit : s) {
+ // cppcheck-suppress useStlAlgorithm
rv = min(rv, (u32)minStringPeriod(lit));
}
DEBUG_PRINTF("min period %u\n", rv);
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());
for (const auto &lit : cut.second) {
if (lit.length() == 2) {
+ // cppcheck-suppress useStlAlgorithm
len_2_count++;
}
}
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;
}
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;
}
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 */
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;
}
bool ComponentAlternation::vacuous_everywhere(void) const {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &c : children) {
if (c->vacuous_everywhere()) {
return true;
void checkPositions(vector<PositionInfo> &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.");
}
static
bool hasPositionFlags(const Component &c) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : c.first()) {
if (e.flags) {
return true;
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;
}
bool ComponentSequence::vacuous_everywhere() const {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &c : children) {
if (!c->vacuous_everywhere()) {
return false;
}
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.");
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;
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");
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");
graphs.emplace_back(ig[e].graph.get());
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &g : graphs) {
if (!canImplementGraph(*g, prefilter, rm, cc)) {
return false;
flat_set<u32> 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)) {
vector<const raw_dfa *> dfa_ptrs;
dfa_ptrs.reserve(dfas.size());
for (auto &d : dfas) {
+ // cppcheck-suppress useStlAlgorithm
dfa_ptrs.emplace_back(d.get());
}
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;
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;
}