mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-17 17:55:28 +03:00
first batch of cppcheck disables and a few more stl-ifications,
involving use of accumulate() .
This commit is contained in:
@@ -137,6 +137,7 @@ NFAVertex findReformable(const NGHolder &g, const set<NFAVertex> &starts,
|
||||
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;
|
||||
@@ -307,6 +308,7 @@ void reformUnanchoredRepeatsComponent(NGHolder &g,
|
||||
}
|
||||
|
||||
for (auto v : otherV) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
if (!edge(dotV, v, g).second) {
|
||||
return;
|
||||
}
|
||||
@@ -441,6 +443,7 @@ bool gatherParticipants(const NGHolder &g,
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -77,17 +77,20 @@ static constexpr u32 MAX_TAIL_SHELL_DEPTH = 3;
|
||||
* 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;
|
||||
|
||||
@@ -157,6 +157,7 @@ vector<bool> findLoopReachable(const Graph &g,
|
||||
|
||||
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;
|
||||
|
||||
@@ -63,6 +63,7 @@ bool checkVerticesFwd(const NGHolder &g, const set<NFAVertex> &sad,
|
||||
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;
|
||||
@@ -85,6 +86,7 @@ bool checkVerticesRev(const NGHolder &g, const set<NFAVertex> &sad,
|
||||
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;
|
||||
|
||||
@@ -197,6 +197,7 @@ bool outIsIrreducible(NFAVertex &v, const NGHolder &g) {
|
||||
unsigned nonSpecialVertices = 0;
|
||||
for (auto w : adjacent_vertices_range(v, g)) {
|
||||
if (!is_special(w, g) && w != v) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
nonSpecialVertices++;
|
||||
}
|
||||
}
|
||||
@@ -208,6 +209,7 @@ bool inIsIrreducible(NFAVertex &v, const NGHolder &g) {
|
||||
unsigned nonSpecialVertices = 0;
|
||||
for (auto u : inv_adjacent_vertices_range(v, g)) {
|
||||
if (!is_special(u, g) && u != v) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
nonSpecialVertices++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ void checkVertex(const ReportManager &rm, const NGHolder &g, NFAVertex v,
|
||||
|
||||
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;
|
||||
|
||||
@@ -75,6 +75,7 @@ bool hasSameBounds(const Container &reports, const ReportManager &rm) {
|
||||
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 ||
|
||||
@@ -225,6 +226,7 @@ void updateReportBounds(ReportManager &rm, NGHolder &g,
|
||||
|
||||
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;
|
||||
@@ -439,6 +441,7 @@ bool hasOffsetAdjust(const ReportManager &rm, NGHolder &g,
|
||||
}
|
||||
|
||||
int offsetAdjust = rm.getReport(*reports.begin()).offsetAdjust;
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (auto report : reports) {
|
||||
const Report &ir = rm.getReport(report);
|
||||
if (ir.offsetAdjust != offsetAdjust) {
|
||||
|
||||
@@ -673,6 +673,7 @@ void validate_fuzzy_compile(const NGHolder &g, u32 edit_distance, bool hamming,
|
||||
}
|
||||
// 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.");
|
||||
|
||||
@@ -453,6 +453,7 @@ void haig_do_preds(const NGHolder &g, const stateset &nfa_states,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,9 +172,11 @@ bool is_equal_i(const NGHolder &a, const NGHolder &b,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <queue>
|
||||
|
||||
#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
|
||||
@@ -359,6 +360,7 @@ u64a litUniqueness(const string &s) {
|
||||
static
|
||||
u64a litCountBits(const ue2_literal &lit) {
|
||||
u64a n = 0;
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &c : lit) {
|
||||
n += c.nocase ? 7 : 8;
|
||||
}
|
||||
@@ -670,10 +672,11 @@ u64a scoreSet(const set<ue2_literal> &s) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -141,12 +141,14 @@ bool isRegionExit(const Graph &g, NFAVertex v,
|
||||
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;
|
||||
@@ -154,11 +156,13 @@ bool isSingletonRegion(const Graph &g, NFAVertex v,
|
||||
}
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
@@ -201,7 +205,7 @@ bool isOptionalRegion(const Graph &g, NFAVertex v,
|
||||
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)) {
|
||||
|
||||
Reference in New Issue
Block a user