involving use of accumulate() .
static
bool hasAssertVertices(const NGHolder &g) {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
int flags = g[v].assert_flags;
if (flags & WORDBOUNDARY_FLAGS) {
const vector<LiteralIndex> &bucket_lits = bucketToLits[b];
u32 min_len = ~0U;
for (const LiteralIndex &lit_idx : bucket_lits) {
+ // cppcheck-suppress useStlAlgorithm
min_len = min(min_len, verify_u32(lits[lit_idx].s.length()));
}
if (contains(bucketToLits, b)) {
vector<hwlmLiteral> vl;
for (const LiteralIndex &lit_idx : bucketToLits.at(b)) {
+ // cppcheck-suppress useStlAlgorithm
vl.emplace_back(lits[lit_idx]);
}
};
out->clear();
for (const auto &def : defns) {
+ // cppcheck-suppress useStlAlgorithm
out->emplace_back(def);
}
}
u32 n_small_lits = 0;
for (const auto &lit : vl) {
if (lit.s.length() < eng.numMasks) {
+ // cppcheck-suppress useStlAlgorithm
n_small_lits++;
}
}
getTeddyDescriptions(&descs);
for (const auto &desc : descs) {
+ // cppcheck-suppress useStlAlgorithm
if (desc.getID() == engineID) {
return std::make_unique<TeddyEngineDescription>(desc);
}
vector<vector<CharReach>> rv;
rv.reserve(paths.size());
for (auto &p : paths) {
+ // cppcheck-suppress useStlAlgorithm
rv.emplace_back(vector<CharReach>(std::make_move_iterator(p.reach.begin()),
std::make_move_iterator(p.reach.end())));
}
depth findMinWidth(const CastleProto &proto) {
depth min_width(depth::infinity());
for (const PureRepeat &pr : proto.repeats | map_values) {
+ // cppcheck-suppress useStlAlgorithm
min_width = min(min_width, pr.bounds.min);
}
return min_width;
depth findMaxWidth(const CastleProto &proto) {
depth max_width(0);
for (const PureRepeat &pr : proto.repeats | map_values) {
+ // cppcheck-suppress useStlAlgorithm
max_width = max(max_width, pr.bounds.max);
}
return max_width;
// First, see if this repeat is already in this castle.
for (const auto &m : repeats) {
+ // cppcheck-suppress useStlAlgorithm
if (m.second == pr) {
DEBUG_PRINTF("repeat already present, with top %u\n", m.first);
return m.first;
static
bool hasZeroMinBound(const CastleProto &proto) {
const depth zero(0);
+ // cppcheck-suppress useStlAlgorithm
for (const PureRepeat &pr : proto.repeats | map_values) {
if (pr.bounds.min == zero) {
return true;
new_states.reserve(num_partitions);
for (const auto &m : ordering) {
+ // cppcheck-suppress useStlAlgorithm
new_states.emplace_back(rdfa.states[m.first]);
}
rdfa.states = std::move(new_states);
GoughSSAVar *GoughSSAVarJoin::get_input(const GoughEdge &prev) const {
for (const auto &var_edge : input_map) {
+ // cppcheck-suppress useStlAlgorithm
if (contains(var_edge.second, prev)) {
return var_edge.first;
}
}
bool find_normal_self_loop(GoughVertex v, const GoughGraph &g, GoughEdge *out) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(v, g)) {
if (target(e, g) != v) {
continue;
const map<gough_edge_id, vector<gough_ins> > &blocks,
const set<GoughVertex> &succs,
const vector<gough_ins> &block_sl) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(u, g)) {
if (!g[e].reach.any()) { /* ignore top edges */
continue;
bool verify_neighbour_no_block(const GoughGraph &g, GoughVertex u,
const map<gough_edge_id, vector<gough_ins> > &blocks,
const set<GoughVertex> &succs) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(u, g)) {
if (!g[e].reach.any()) { /* ignore top edges */
continue;
succs.insert(target(e, g));
}
+ // cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (w != v && !verify_neighbour(g, w, blocks, succs, block_sl)) {
return false;
}
succs.insert(target(e, g));
+ // cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (w != v && !verify_neighbour_no_block(g, w, blocks, succs)) {
return false;
template<typename VarP, typename VarQ>
void emplace_back_all_raw(vector<VarP> *out, const vector<VarQ> &in) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &var : in) {
out->emplace_back(var.get());
}
void add_to_dom_ordering(const vector<VarP> &vars,
vector<GoughSSAVar *> *out) {
for (const auto &var : vars) {
+ // cppcheck-suppress useStlAlgorithm
out->emplace_back(var.get());
}
}
static
bool allow_wide_accel(const vector<NFAVertex> &vv, const NGHolder &g,
NFAVertex sds_or_proxy) {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vv) {
if (allow_wide_accel(v, g, sds_or_proxy)) {
return true;
vector<NFAVertex> astates;
for (const auto &m : accel_map) {
+ // cppcheck-suppress useStlAlgorithm
astates.emplace_back(m.first);
}
continue;
}
for (const auto &s_mask : args.squashMap | map_values) {
+ // cppcheck-suppress useStlAlgorithm
if (!s_mask.test(state_id)) {
may_turn_off |= 1U << accel_id;
break;
}
}
for (const auto &s_mask : args.reportSquashMap | map_values) {
+ // cppcheck-suppress useStlAlgorithm
if (!s_mask.test(state_id)) {
may_turn_off |= 1U << accel_id;
break;
#include <cstring>
#include <map>
#include <memory>
+#include <numeric>
#include <queue>
#include <set>
#include <vector>
size_t rv = info.wide_symbol_chain.size() * sizeof(u32) + 4;
// wide info body
- for (const auto &chain : info.wide_symbol_chain) {
- rv += ROUNDUP_N(chain.size(), 2) +
- (info.impl_alpha_size + 1) * sizeof(u16) + 2;
- }
+ auto chainz = [info=info](size_t z, const vector<symbol_t> &chain) {
+ return z + (size_t)(ROUNDUP_N(chain.size(), 2) +
+ (info.impl_alpha_size + 1) * sizeof(u16) + 2);
+ };
+ rv += std::accumulate(info.wide_symbol_chain.begin(), info.wide_symbol_chain.end(), 0, chainz);
+ // for (const auto &chain : info.wide_symbol_chain) {
+ // rv += ROUNDUP_N(chain.size(), 2) +
+ // (info.impl_alpha_size + 1) * sizeof(u16) + 2;
+ // }
return ROUNDUP_16(rv);
}
}
for (const auto &next : raw.states[s].next) {
+ // cppcheck-suppress useStlAlgorithm
if (can_die_early(raw, next, visited, age_limit - 1)) {
return true;
}
}
nibble_masks.clear();
for (const auto &e : new_masks) {
+ // cppcheck-suppress useStlAlgorithm
nibble_masks.emplace_back(e.second);
}
}
#include "util/container.h"
#include "util/verify_types.h"
+#include <numeric>
+
using namespace std;
namespace ue2 {
sizeof(u32) * subSize + 64; // offsets to subengines in bytecode and
// padding for subengines
- for (const auto &sub : tamaInfo.subengines) {
- total_size += ROUNDUP_CL(sub->length);
- }
+
+ auto subl = [](size_t z, NFA *sub) {
+ return z + (size_t)(ROUNDUP_CL(sub->length));
+ };
+ total_size += std::accumulate(tamaInfo.subengines.begin(), tamaInfo.subengines.end(), 0, subl);
+ // for (const auto &sub : tamaInfo.subengines) {
+ // total_size += ROUNDUP_CL(sub->length);
+ // }
// use subSize as a sentinel value for no active subengines,
// so add one to subSize here
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;
}
for (auto v : otherV) {
+ // cppcheck-suppress useStlAlgorithm
if (!edge(dotV, v, g).second) {
return;
}
/* 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;
* 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;
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;
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;
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;
unsigned nonSpecialVertices = 0;
for (auto w : adjacent_vertices_range(v, g)) {
if (!is_special(w, g) && w != v) {
+ // cppcheck-suppress useStlAlgorithm
nonSpecialVertices++;
}
}
unsigned nonSpecialVertices = 0;
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!is_special(u, g) && u != v) {
+ // cppcheck-suppress useStlAlgorithm
nonSpecialVertices++;
}
}
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;
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 ||
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;
}
int offsetAdjust = rm.getReport(*reports.begin()).offsetAdjust;
+ // cppcheck-suppress useStlAlgorithm
for (auto report : reports) {
const Report &ir = rm.getReport(report);
if (ir.offsetAdjust != offsetAdjust) {
}
// 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.");
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);
}
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);
}
#include <algorithm>
#include <fstream>
+#include <numeric>
#include <queue>
#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
static
u64a litCountBits(const ue2_literal &lit) {
u64a n = 0;
+ // cppcheck-suppress useStlAlgorithm
for (const auto &c : lit) {
n += c.nocase ? 7 : 8;
}
}
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);
+ // for (const auto &lit : s) {
+ // score += calculateScore(lit);
+ // }
return score;
}
template <class Graph>
bool isSingletonRegion(const Graph &g, NFAVertex v,
const std::unordered_map<NFAVertex, u32> ®ion_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;
}
}
+ // 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)) {
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)) {
/// Are no bits set?
bool none() const {
+ // cppcheck-suppress useStlAlgorithm
+ // XXX maybe do this one..
for (const auto &e : bits) {
if (e != 0) {
return false;
vertex_descriptor v) const {
if (in_degree_impl(v) < out_degree_impl(u)) {
for (const edge_descriptor &e : in_edges_range(v, *this)) {
+ // cppcheck-suppress useStlAlgorithm
if (source_impl(e) == u) {
return {e, true};
}
}
} else {
for (const edge_descriptor &e : out_edges_range(u, *this)) {
+ // cppcheck-suppress useStlAlgorithm
if (target_impl(e) == v) {
return {e, true};
}