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

@@ -182,6 +182,7 @@ vector<vector<CharReach>> generate_paths(const raw_dfa &rdfa,
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())));
}

View File

@@ -676,6 +676,7 @@ set<ReportID> all_reports(const CastleProto &proto) {
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;
@@ -684,6 +685,7 @@ depth findMinWidth(const CastleProto &proto) {
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;
@@ -750,6 +752,7 @@ u32 CastleProto::merge(const PureRepeat &pr) {
// 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;
@@ -974,6 +977,7 @@ void addToHolder(NGHolder &g, u32 top, const PureRepeat &pr) {
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;

View File

@@ -263,6 +263,7 @@ void mapping_new_states(const HopcroftInfo &info,
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);

View File

@@ -643,6 +643,7 @@ void GoughSSAVarJoin::generate(UNUSED vector<gough_ins> *out) const {
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;
}
@@ -985,6 +986,7 @@ void copy_in_blocks(raw_som_dfa &raw, u8 alphaShift, const GoughGraph &cfg,
}
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;

View File

@@ -146,6 +146,7 @@ bool verify_neighbour(const GoughGraph &g, GoughVertex u,
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;
@@ -172,6 +173,7 @@ static
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;
@@ -229,6 +231,7 @@ bool allow_two_byte_accel(const GoughGraph &g,
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;
@@ -249,6 +252,7 @@ bool allow_two_byte_accel(const GoughGraph &g,
}
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;

View File

@@ -50,6 +50,7 @@ namespace ue2 {
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());
}
@@ -380,6 +381,7 @@ template<typename VarP>
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());
}
}

View File

@@ -482,6 +482,7 @@ bool allow_wide_accel(NFAVertex v, const NGHolder &g, NFAVertex sds_or_proxy) {
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;
@@ -624,6 +625,7 @@ void fillAccelInfo(build_info &bi) {
vector<NFAVertex> astates;
for (const auto &m : accel_map) {
// cppcheck-suppress useStlAlgorithm
astates.emplace_back(m.first);
}
@@ -800,12 +802,14 @@ u32 getEffectiveAccelStates(const build_info &args,
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;

View File

@@ -55,6 +55,7 @@
#include <cstring>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
@@ -529,10 +530,11 @@ size_t calcWideRegionSize(const dfa_info &info) {
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);
return ROUNDUP_16(rv);
}

View File

@@ -265,6 +265,7 @@ bool can_die_early(const raw_dfa &raw, dstate_id_t s,
}
for (const auto &next : raw.states[s].next) {
// cppcheck-suppress useStlAlgorithm
if (can_die_early(raw, next, visited, age_limit - 1)) {
return true;
}

View File

@@ -182,6 +182,7 @@ bool shuftiBuildDoubleMasks(const CharReach &onechar,
}
nibble_masks.clear();
for (const auto &e : new_masks) {
// cppcheck-suppress useStlAlgorithm
nibble_masks.emplace_back(e.second);
}
}

View File

@@ -44,6 +44,8 @@
#include "util/container.h"
#include "util/verify_types.h"
#include <numeric>
using namespace std;
namespace ue2 {