// Candidates have been expanded in reverse order.
for (auto &cand : candidates) {
+ // cppcheck-suppress useStlAlgorithm
cand = reverse_literal(cand);
}
curr.swap(next);
}
+ // cppcheck-suppress useStlAlgorithm
for (auto v : curr) {
+ // cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (u == g.start || u == g.startDs) {
DEBUG_PRINTF("literal spans graph from start to accept\n");
// Rehome our groups into one vector.
for (auto &rdfa : small_starts) {
+ // cppcheck-suppress useStlAlgorithm
dfas.emplace_back(std::move(rdfa));
}
for (auto &rdfa : big_starts) {
+ // cppcheck-suppress useStlAlgorithm
dfas.emplace_back(std::move(rdfa));
}
// DFAs that already exist as raw_dfas.
for (auto &anch_dfas : build.anchored_nfas) {
for (auto &rdfa : anch_dfas.second) {
+ // cppcheck-suppress useStlAlgorithm
dfas.emplace_back(std::move(rdfa));
}
}
u32 num = 0;
for (const auto &r : roses) {
if (!r.infix) {
+ // cppcheck-suppress useStlAlgorithm
num++;
}
}
const RoseGraph &g = build.g;
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
if (g[v].suffix) {
/* TODO: check that they have non-eod reports */
static
bool isSingleOutfix(const RoseBuildImpl &tbi) {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(tbi.g)) {
if (tbi.isAnyStart(v)) {
continue;
return false;
}
+ // cppcheck-suppress useStlAlgorithm
for (RoseVertex s : succs) {
if (build.isInETable(s)
|| contains(rg[s].literals, build.eod_event_literal_id)) {
static
bool hasNonSmallBlockOutfix(const vector<OutfixInfo> &outfixes) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &out : outfixes) {
if (!out.in_sbmatcher) {
return true;
// order.
vector<pair<u32, suffix_id>> ordered;
for (const auto &e : bc.suffixes) {
+ // cppcheck-suppress useStlAlgorithm
ordered.emplace_back(e.second, e.first);
}
sort(begin(ordered), end(ordered));
static
bool hasMpvTrigger(const set<u32> &reports, const ReportManager &rm) {
+ // cppcheck-suppress useStlAlgorithm
for (u32 r : reports) {
if (rm.getReport(r).type == INTERNAL_ROSE_CHAIN) {
return true;
}
/* outfixes */
+ // cppcheck-suppress useStlAlgorithm
for (const auto &out : build.outfixes) {
if (hasMpvTrigger(all_reports(out), build.rm)) {
return true;
// eagerly-reported EOD vertices.
bool needs_state_index = false;
for (const auto &e : out_edges_range(v, g)) {
+ // cppcheck-suppress useStlAlgorithm
if (!canEagerlyReportAtEod(build, e)) {
needs_state_index = true;
break;
return true;
}
+ // cppcheck-suppress useStlAlgorithm
for (const u32 &delayed_id : info.delayed_ids) {
assert(delayed_id < build.literal_info.size());
const rose_literal_info &delayed_info = build.literal_info[delayed_id];
static
bool hasEodAnchoredSuffix(const RoseBuildImpl &build) {
const RoseGraph &g = build.g;
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
if (g[v].suffix && build.isInETable(v)) {
DEBUG_PRINTF("vertex %zu is in eod table and has a suffix\n",
static
bool hasEodMatcher(const RoseBuildImpl &build) {
const RoseGraph &g = build.g;
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
if (build.isInETable(v)) {
DEBUG_PRINTF("vertex %zu is in eod table\n", g[v].index);
vector<rose_literal_id> rv;
for (const u32 id : tbi.g[v].literals) {
+ // cppcheck-suppress useStlAlgorithm
rv.emplace_back(tbi.literals.at(id));
}
for (const auto &e : s) {
if (e.nocase) {
+ // cppcheck-suppress useStlAlgorithm
nc_count++;
}
}
}
bool RoseBuildImpl::hasOnlyPseudoStarInEdges(RoseVertex v) const {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(v, g)) {
if (!isPseudoStar(e)) {
return false;
}
// Use the program to handle cases that aren't external reports.
+ // cppcheck-suppress useStlAlgorithm
for (const ReportID &rid : g[v].reports) {
if (!isExternalReport(rm.getReport(rid))) {
return false;
* larger than avoiding running an eod table over the last N bytes. */
static
bool checkFloatingKillableByPrefixes(const RoseBuildImpl &tbi) {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(tbi.g)) {
if (!tbi.isRootSuccessor(v)) {
continue;
return false;
}
+ // cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (!g[w].eod_accept) {
DEBUG_PRINTF("non eod accept literal\n");
}
bool RoseBuildImpl::hasDelayedLiteral(RoseVertex v) const {
+ // cppcheck-suppress useStlAlgorithm
for (u32 lit_id : g[v].literals) {
if (literals.at(lit_id).delay) {
return true;
}
bool RoseBuildImpl::hasDelayPred(RoseVertex v) const {
+ // cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (hasDelayedLiteral(u)) {
return true;
}
bool RoseBuildImpl::hasAnchoredTablePred(RoseVertex v) const {
+ // cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (isAnchored(u)) {
return true;
u32 new_top = ~0U;
/* check if there is already a top with the right the successor set */
for (const auto &elem : h_top_info) {
+ // cppcheck-suppress useStlAlgorithm
if (elem.second == edges_to_trigger) {
new_top = elem.first;
break;
CharReach cr;
for (const auto &sym : symbols) {
+ // cppcheck-suppress useStlAlgorithm
cr |= reach[sym];
}
return false;
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &report_id : all_reports(outfix)) {
const auto &report = rm.getReport(report_id);
if (!isSimpleExhaustible(report)) {
// literals are direct reports (i.e. leaf nodes in the Rose graph).
for (const set<u32> &lits : tbi.anchored_simple | map_values) {
for (u32 lit_id : lits) {
+ // cppcheck-suppress useStlAlgorithm
if (!tbi.isDirectReport(lit_id)) {
DEBUG_PRINTF("not all anchored lits are direct reports\n");
return;
/* literals */
+ // cppcheck-suppress useStlAlgorithm
for (const auto &m : lits) {
if (m.second > 1) {
DEBUG_PRINTF("lit %u used by >1 reporting roles\n", m.first);
CharReach cr;
for (const auto &v : vertices_range(h)) {
if (!is_special(v, h)) {
+ // cppcheck-suppress useStlAlgorithm
cr |= h[v].char_reach;
}
}
const vector<vector<CharReach>> &triggers2) {
// literal suffix test
for (const auto &lit1 : triggers1) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &lit2 : triggers2) {
const size_t len = min(lit1.size(), lit2.size());
if (equal(lit1.rbegin(), lit1.rbegin() + len,
// Check if only literal states are on
for (const auto &s : activeStates) {
if ((!is_any_start(s, h) && h[s].index <= num) ||
+ // cppcheck-suppress useStlAlgorithm
contains(tailId, h[s].index)) {
skipList[id2].insert(id1);
return false;
return true;
}
+ // cppcheck-suppress useStlAlgorithm
for (u32 delayed_id : build.literal_info[id].delayed_ids) {
if (any_of_in(build.literal_info[delayed_id].vertices, eligble)) {
return true;
for (auto w : adjacent_vertices_range(u, g)) {
if (!small_literal_count || g[v].left == g[w].left) {
for (u32 lit_id : g[w].literals) {
+ // cppcheck-suppress useStlAlgorithm
local_group |= literal_info[lit_id].group_mask;
}
} else {
rose_group initialGroups = 0;
for (auto v : adjacent_vertices_range(start, g)) {
+ // cppcheck-suppress useStlAlgorithm
initialGroups |= getGroups(v);
}
rose_group groups = lit_info.group_mask;
while (groups) {
u32 group_id = findAndClearLSB_64(&groups);
+ // cppcheck-suppress useStlAlgorithm
for (u32 id : build.group_to_literal.at(group_id)) {
DEBUG_PRINTF(" checking against friend %u\n", id);
if (!is_subset_of(build.literal_info[id].vertices,
}
// Out-edges must have inf max bound, + no other shenanigans */
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(v, g)) {
if (g[e].maxBound != ROSE_BOUND_INF) {
return false;
}
// Multiple-vertex case
+ // cppcheck-suppress useStlAlgorithm
for (auto v : lit_info.vertices) {
assert(!build.isAnyStart(v));
// Out-edges must have inf max bound and not directly lead to another
// vertex with this group, e.g. 'foobar.*foobar'.
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(v, g)) {
if (g[e].maxBound != ROSE_BOUND_INF) {
return false;
return false; /* is an infix rose trigger */
}
+ // cppcheck-suppress useStlAlgorithm
for (u32 lit_id : g[t].literals) {
if (build.literal_info[lit_id].group_mask &
lit_info.group_mask) {
// In-edges must all be dot-stars with no overlap at all, as overlap
// also causes history to be used.
/* Different tables are already forbidden by previous checks */
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(v, g)) {
if (!(g[e].minBound == 0 && g[e].maxBound == ROSE_BOUND_INF)) {
return false;
static
bool isFloodProne(const map<s32, CharReach> &look, const CharReach &flood_cr) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &m : look) {
const CharReach &look_cr = m.second;
if (!overlaps(look_cr, flood_cr)) {
return false;
}
+ // cppcheck-suppress useStlAlgorithm
for (const CharReach &flood_cr : flood_reach) {
if (isFloodProne(look, flood_cr)) {
return true;
assert(!is_special(v, g));
for (auto u : inv_adjacent_vertices_range(v, g)) {
+ // cppcheck-suppress useStlAlgorithm
if (u == g.start || u == g.startDs) {
curr[idx] = g.startDs;
break;
return false;
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &oe : out_edges_range(u, g)) {
RoseVertex v = target(oe, g);
if (g[oe].maxBound != ROSE_BOUND_INF) {
}
// Undelayed vertices.
+ // cppcheck-suppress useStlAlgorithm
for (RoseVertex v : info.vertices) {
if (!isNoRunsVertex(build, v)) {
return false;
assert(d < build.literal_info.size());
const rose_literal_info &delayed_info = build.literal_info.at(d);
assert(delayed_info.undelayed_id == id);
+ // cppcheck-suppress useStlAlgorithm
for (RoseVertex v : delayed_info.vertices) {
if (!isNoRunsVertex(build, v)) {
return false;
}
// We don't handle delayed cases yet.
+ // cppcheck-suppress useStlAlgorithm
for (const auto &ue : ulits) {
const rose_literal_id &ul = *ue.first;
if (ul.delay) {
}
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &ve : vlits) {
const rose_literal_id &vl = *ve.first;
if (vl.delay) {
checked its status at offset X and X > Y). If we can not establish that
the literals used for triggering will satisfy this property, then it is
not safe to merge the engine. */
+ // cppcheck-suppress useStlAlgorithm
for (const auto &ue : ulits) {
const rose_literal_id &ul = *ue.first;
u32 ulag = ue.second;
+ // cppcheck-suppress useStlAlgorithm
for (const auto &ve : vlits) {
const rose_literal_id &vl = *ve.first;
u32 vlag = ve.second;
vector<pair<const rose_literal_id *, u32>> ulits;
ulits.reserve(tbi.g[u].literals.size());
for (u32 id : tbi.g[u].literals) {
+ // cppcheck-suppress useStlAlgorithm
ulits.emplace_back(&tbi.literals.at(id), ulag);
}
vector<pair<const rose_literal_id *, u32>> vlits;
vlits.reserve(tbi.g[v].literals.size());
for (u32 id : tbi.g[v].literals) {
+ // cppcheck-suppress useStlAlgorithm
vlits.emplace_back(&tbi.literals.at(id), vlag);
}
vector<const rose_literal_id *> pred_rose_lits;
pred_rose_lits.reserve(pred_lits.size());
for (const auto &p : pred_lits) {
+ // cppcheck-suppress useStlAlgorithm
pred_rose_lits.emplace_back(&build.literals.at(p));
}
u32 ulag = tbi.g[a].left.lag;
for (u32 id : tbi.g[a].literals) {
+ // cppcheck-suppress useStlAlgorithm
ulits.emplace_back(&tbi.literals.at(id), ulag);
}
}
u32 vlag = tbi.g[a].left.lag;
for (u32 id : tbi.g[a].literals) {
+ // cppcheck-suppress useStlAlgorithm
vlits.emplace_back(&tbi.literals.at(id), vlag);
}
}
for (auto a : targets_1) {
u32 ulag = build.g[a].left.lag;
for (u32 id : build.g[a].literals) {
+ // cppcheck-suppress useStlAlgorithm
ulits.emplace_back(&build.literals.at(id), ulag);
}
}
for (auto a : targets_2) {
u32 vlag = build.g[a].left.lag;
for (u32 id : build.g[a].literals) {
+ // cppcheck-suppress useStlAlgorithm
vlits.emplace_back(&build.literals.at(id), vlag);
}
}
}
bool RoseBuildImpl::isRootSuccessor(const RoseVertex &v) const {
+ // cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (isAnyStart(u)) {
return true;
}
bool RoseBuildImpl::isNonRootSuccessor(const RoseVertex &v) const {
+ // cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!isAnyStart(u)) {
return true;
}
bool hasAnchHistorySucc(const RoseGraph &g, RoseVertex v) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(v, g)) {
if (g[e].history == ROSE_ROLE_HISTORY_ANCH) {
return true;
}
bool hasLastByteHistorySucc(const RoseGraph &g, RoseVertex v) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(v, g)) {
if (g[e].history == ROSE_ROLE_HISTORY_LAST_BYTE) {
return true;
/* Indicates that the floating table (if it exists) will be only run
conditionally based on matches from the anchored table. */
bool RoseBuildImpl::hasNoFloatingRoots() const {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(root, g)) {
if (isFloating(v)) {
DEBUG_PRINTF("direct floating root %zu\n", g[v].index);
}
/* need to check if the anchored_root has any literals which are too deep */
+ // cppcheck-suppress useStlAlgorithm
for (auto v : adjacent_vertices_range(anchored_root, g)) {
if (isFloating(v)) {
DEBUG_PRINTF("indirect floating root %zu\n", g[v].index);
size_t maxlen = 0;
for (const auto &lit_id : lit_ids) {
+ // cppcheck-suppress useStlAlgorithm
maxlen = max(maxlen, literals.at(lit_id).elength());
}
size_t minlen = ROSE_BOUND_INF;
for (const auto &lit_id : lit_ids) {
+ // cppcheck-suppress useStlAlgorithm
minlen = min(minlen, literals.at(lit_id).elength());
}
u32 min_offset = UINT32_MAX;
for (const auto &v : lit_vertices) {
+ // cppcheck-suppress useStlAlgorithm
min_offset = min(min_offset, build.g[v].min_offset);
}
u32 max_offset = 0;
for (const auto &v : lit_vertices) {
+ // cppcheck-suppress useStlAlgorithm
max_offset = max(max_offset, build.g[v].max_offset);
}
/** Returns true if the program may read the interpreter's work_done flag */
static
bool reads_work_done_flag(const RoseProgram &prog) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &ri : prog) {
if (dynamic_cast<const RoseInstrSquashGroups *>(ri.get())) {
return true;
assert(in_degree(v, g) > 0);
rose_group already_on = ~rose_group{0};
for (const auto &u : inv_adjacent_vertices_range(v, g)) {
+ // cppcheck-suppress useStlAlgorithm
already_on &= prog_build.vertex_group_map.at(u);
}
return false;
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(v, g)) {
RoseVertex w = target(e, g);
if (!g[w].eod_accept) {
return false;
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e_a : in_edges_range(a, g)) {
RoseEdge e = edge(source(e_a, g), b, g);
if (!e || g[e].rose_top != g[e_a].rose_top) {
static
bool hasCommonSuccWithBadBounds(RoseVertex a, RoseVertex b,
const RoseGraph &g) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e_a : out_edges_range(a, g)) {
if (RoseEdge e = edge(b, target(e_a, g), g)) {
if (g[e_a].maxBound < g[e].minBound
static
bool hasCommonPredWithBadBounds(RoseVertex a, RoseVertex b,
const RoseGraph &g) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e_a : in_edges_range(a, g)) {
if (RoseEdge e = edge(source(e_a, g), b, g)) {
if (g[e_a].maxBound < g[e].minBound
}
// Otherwise, all the literals involved must have the same length.
+ // cppcheck-suppress useStlAlgorithm
for (u32 a_id : lits_a) {
const rose_literal_id &la = build.literals.at(a_id);
+ // cppcheck-suppress useStlAlgorithm
for (u32 b_id : lits_b) {
const rose_literal_id &lb = build.literals.at(b_id);
const bool equal_roses = hasEqualLeftfixes(a, b, g);
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e_a : in_edges_range(a, g)) {
if (RoseEdge e = edge(source(e_a, g), b, g)) {
DEBUG_PRINTF("common pred, e_r=%d r_t %u,%u\n",
DEBUG_PRINTF("trying to prune %u from %p (v %zu)\n", report, h.get(),
verts.size());
for (RoseVertex v : verts) {
+ // cppcheck-suppress useStlAlgorithm
if (build.g[v].left.graph == h &&
build.g[v].left.leftfix_report == report) {
DEBUG_PRINTF("report %u still in use\n", report);
if (has_successor(v, g)) {
bool only_succ = true;
for (const auto &w : adjacent_vertices_range(v, g)) {
+ // cppcheck-suppress useStlAlgorithm
if (in_degree(w, g) > 1) {
only_succ = false;
break;
bool only_pred = true;
for (const auto &u : inv_adjacent_vertices_range(v, g)) {
+ // cppcheck-suppress useStlAlgorithm
if (out_degree(u, g) > 1) {
only_pred = false;
break;
static
bool is_end_anchored(const RoseGraph &g, RoseVertex v) {
+ // cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (g[w].eod_accept) {
return true;
void upperString(string &s) {
for (auto &c : s) {
+ // cppcheck-suppress useStlAlgorithm
c = mytoupper(c);
}
}
ue2_literal rv;
for (const auto &elem: *lit) {
+ // cppcheck-suppress useStlAlgorithm
rv.push_back(elem.c, ourisalpha(elem.c));
}
double best = threads[0]->results[0].seconds;
for (const auto &t : threads) {
for (const auto &r : t->results) {
+ // cppcheck-suppress useStlAlgorithm
best = min(best, r.seconds);
}
}
u64a byte_size(const vector<DataBlock> &corpus_blocks) {
u64a total = 0;
for (const DataBlock &block : corpus_blocks) {
+ // cppcheck-suppress useStlAlgorithm
total += block.payload.size();
}
// Sanity check: all of our results should have the same match count.
for (const auto &t : threads) {
+ // cppcheck-suppress useStlAlgorithm
if (!all_of(begin(t->results), end(t->results),
[&matchesPerRun](const ResultEntry &e) {
return e.matches == matchesPerRun;
// Sanity check: all of our results should have the same match count.
for (const auto &t : threads) {
+ // cppcheck-suppress useStlAlgorithm
if (!all_of(begin(t->results), end(t->results),
[&matchesPerRun](const ResultEntry &e) {
return e.matches == matchesPerRun;
// Sanity check: all of our results should have the same match count.
for (const auto &t : threads) {
+ // cppcheck-suppress useStlAlgorithm
if (!all_of(begin(t->results), end(t->results),
[&matchesPerRun](const ResultEntry &e) {
return e.matches == matchesPerRun;
vector<size_t> to_indices(const Range &range, const Graph &g) {
vector<size_t> indices;
for (const auto &elem : range) {
+ // cppcheck-suppress useStlAlgorithm
indices.push_back(g[elem].index);
}
sort(indices.begin(), indices.end());
const Graph &g) {
vector<size_t> indices;
for (const auto &elem : range) {
+ // cppcheck-suppress useStlAlgorithm
indices.push_back(g[elem].index);
}
sort(indices.begin(), indices.end());
if (!opt.empty()) {
for (const auto &xcompile : xcompile_options) {
+ // cppcheck-suppress useStlAlgorithm
if (opt == xcompile.name) {
rv.cpu_features = xcompile.cpu_features;
found_mode = true;
/** True if this graph has no non-special successors of start or startDs. */
static
bool graph_is_empty(const NGHolder &g) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &v : adjacent_vertices_range(g.start, g)) {
if (!is_special(v, g)) {
return false;
}
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &v : adjacent_vertices_range(g.start, g)) {
if (!is_special(v, g)) {
return false;
}
for (const auto &e : raw) {
+ // cppcheck-suppress useStlAlgorithm
data.push_back(encodeUtf8(e));
}
}
// Generate a corpus from our path
for (const auto &e : path) {
+ // cppcheck-suppress useStlAlgorithm
s.push_back(getChar(e));
}