// we imitate the noodle unit tests
std::string str;
const size_t char_len = 5;
- str.resize(char_len + 1);
+ str.resize(char_len + 2);
for (size_t j = 0; j < char_len; j++) {
srand(time(NULL));
int key = rand() % +36;
std::vector<u8> buf;
// Noodle
- struct hs_scratch scratch;
+ struct hs_scratch scratch{};
ue2::bytecode_ptr<noodTable> nt;
MicroBenchmark(char const *label_, size_t size_)
--- /dev/null
+unknownMacro:*gtest-all.cc
+knownConditionTrueFalse:*Parser.rl
+knownConditionTrueFalse:*Parser.cpp
+variableScope:*Parser.rl
+unreadVariable:*control_verbs.cpp
+assertWithSideEffect
+syntaxError
+internalError
+checkersReport
+missingInclude
+missingIncludeSystem
+unmatchedSuppression
size_t maxLen(const vector<hwlmLiteral> &lits) {
size_t rv = 0;
for (const auto &lit : lits) {
+ // cppcheck-suppress useStlAlgorithm
rv = max(rv, lit.s.size());
}
return rv;
u32 maskWidth = 2;
fprintf(f, " dup nibble masks:\n");
for (u32 i = 0; i < numMasks * 2; i++) {
- fprintf(f, " -%d%s: ", 1 + i / 2, (i % 2) ? "hi" : "lo");
+ fprintf(f, " -%u%s: ", 1 + i / 2, (i % 2) ? "hi" : "lo");
for (u32 j = 0; j < 16 * maskWidth * 2; j++) {
u8 val = dmsk[i * 16 * maskWidth * 2 + j];
for (u32 k = 0; k < 8; k++) {
// dump nibble masks
fprintf(f, " nibble masks:\n");
for (u32 i = 0; i < numMasks * 2; i++) {
- fprintf(f, " -%d%s: ", 1 + i / 2, (i % 2) ? "hi" : "lo");
+ fprintf(f, " -%u%s: ", 1 + i / 2, (i % 2) ? "hi" : "lo");
for (u32 j = 0; j < 16 * maskWidth; j++) {
u8 val = baseMsk[i * 16 * maskWidth + j];
for (u32 k = 0; k < 8; k++) {
// Called by an assertion.
static
bool everyoneHasGroups(const vector<hwlmLiteral> &lits) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &lit : lits) {
if (!lit.groups) {
return false;
#ifndef NDEBUG
template<typename C, typename K>
bool contains_loose(const C &container, const K &key) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &elem : container) {
if (elem == key) {
return true;
}
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;
fprintf(f, "\tuses:");
vector<u32> used_id;
for (const GoughSSAVar *var : used) {
+ // cppcheck-suppress useStlAlgorithm
used_id.emplace_back(var->slot);
}
for (const u32 &id : used_id) {
fprintf(f, "\tuses:");
vector<u32> used_id;
for (const GoughSSAVar *var : used) {
+ // cppcheck-suppress useStlAlgorithm
used_id.emplace_back(var->slot);
}
for (const u32 &id : used_id) {
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) {
+ // cppcheck-suppress useStlAlgorithm
out->emplace_back(var.get());
}
}
m->state_count, m->length);
fprintf(f, "astart: %hu, fstart: %hu\n", m->start_anchored,
m->start_floating);
- fprintf(f, "single accept: %d\n", !!(int)m->flags & MCCLELLAN_FLAG_SINGLE);
+ fprintf(f, "single accept: %d\n", !!(m->flags & MCCLELLAN_FLAG_SINGLE));
fprintf(f, "sherman_limit: %u, sherman_end: %u\n", m->sherman_limit,
m->sherman_end);
assert(rv == MO_CONTINUE_MATCHING);
}
+ // cppcheck-suppress knownConditionTrueFalse
if (escape_found) {
DEBUG_PRINTF("clearing repeat due to escape\n");
clearRepeat(info, lstate);
size_t eloc = 0;
char escaped = FWDSCAN_FN(nfa, buf, 0, length, &eloc);
+ // cppcheck-suppress knownConditionTrueFalse
if (escaped) {
assert(eloc < length);
DEBUG_PRINTF("escape found at %zu, clearing repeat\n", eloc);
const STATE_T accept_mask = *acceptMask;
STATE_T accepts = AND_STATE(*s, accept_mask);
+ DEBUG_PRINTF("sizeof(STATE_T): %ld, sizeof(CHUNK_T): %ld, NUM_STATE_CHUNKS: %ld\n", sizeof(STATE_T), sizeof(CHUNK_T), NUM_STATE_CHUNKS);
// Caller must ensure that we have at least one accept state on.
assert(ISNONZERO_STATE(accepts));
memcpy(mask_chunks, &accept_mask, sizeof(accept_mask));
u32 base_index = 0; // Cumulative sum of mask popcount up to current chunk.
+ // cppcheck-suppress unsignedLessThanZero
for (u32 i = 0; i < NUM_STATE_CHUNKS; i++) {
CHUNK_T chunk = chunks[i];
while (chunk != 0) {
memcpy(mask_chunks, &accept_mask, sizeof(accept_mask));
u32 base_index = 0; // Cumulative sum of mask popcount up to current chunk.
+ // cppcheck-suppress unsignedLessThanZero
for (u32 i = 0; i < NUM_STATE_CHUNKS; i++) {
CHUNK_T chunk = chunks[i];
while (chunk != 0) {
for (size_t i = m.second.find_first(); i != m.second.npos;
i = m.second.find_next(i)) {
u32 state_id = indexToState[i];
+ // cppcheck-suppress knownConditionTrueFalse
if (state_id == NO_STATE) {
continue;
}
subset = state_set;
subset.reset(j);
+ // cppcheck-suppress knownConditionTrueFalse
if (effective_sds != NO_STATE && subset.count() == 1 &&
subset.test(effective_sds)) {
continue;
for (auto v : vertices_range(h)) {
u32 state_id = args.state_ids.at(v);
+ // cppcheck-suppress knownConditionTrueFalse
if (state_id == NO_STATE || !is_match_vertex(v, h)) {
continue;
}
for (auto v : vertices_range(h)) {
u32 i = state_ids.at(v);
+ // cppcheck-suppress knownConditionTrueFalse
if (i == NO_STATE || maskedStates.test(i)) {
continue;
}
NFAStateSet initDs(args.num_states);
u32 sds_state = args.state_ids.at(h.startDs);
+ // cppcheck-suppress knownConditionTrueFalse
if (sds_state == NO_STATE) {
DEBUG_PRINTF("no states in initds\n");
return false;
// Rose leftfixes can mask out initds, which is worth doing if it will
// stay on forever (i.e. it's not squashable).
u32 sds_i = args.state_ids.at(h.startDs);
+ // cppcheck-suppress knownConditionTrueFalse
if (sds_i != NO_STATE && !hasSquashableInitDs(args)) {
maskedStates.set(sds_i);
DEBUG_PRINTF("masking out initds state\n");
for (const auto &e : edges_range(h)) {
u32 from = args.state_ids.at(source(e, h));
u32 to = args.state_ids.at(target(e, h));
+ // cppcheck-suppress knownConditionTrueFalse
if (from == NO_STATE) {
continue;
}
// We cannot mask out EOD accepts, as they have to perform an
// action after they're switched on that may be delayed until the
// next stream write.
+ // cppcheck-suppress knownConditionTrueFalse
if (to == NO_STATE && target(e, h) != h.acceptEod) {
continue;
}
for (auto v : vertices_range(h)) {
const u32 i = args.state_ids.at(v);
+ // cppcheck-suppress knownConditionTrueFalse
if (i == NO_STATE) {
continue;
}
}
u32 j = args.state_ids.at(w);
// j can be NO_STATE if args.state_ids.at(w) returns NO_STATE
+ // cppcheck-suppress knownConditionTrueFalse
if (j == NO_STATE) {
continue;
}
for (const auto &e : edges_range(h)) {
u32 from = args.state_ids.at(source(e, h));
u32 to = args.state_ids.at(target(e, h));
+ // cppcheck-suppress knownConditionTrueFalse
if (from == NO_STATE || to == NO_STATE) {
continue;
}
for (const auto &e : edges_range(h)) {
u32 from = args.state_ids.at(source(e, h));
u32 to = args.state_ids.at(target(e, h));
+ // cppcheck-suppress knownConditionTrueFalse
if (from == NO_STATE || to == NO_STATE) {
continue;
}
u32 s_i = args.state_ids.at(h.start);
u32 sds_i = args.state_ids.at(h.startDs);
+ // cppcheck-suppress knownConditionTrueFalse
if (s_i != NO_STATE) {
maskSetBit(limex->init, s_i);
if (is_triggered(h)) {
}
}
+ // cppcheck-suppress knownConditionTrueFalse
if (sds_i != NO_STATE) {
maskSetBit(limex->init, sds_i);
maskSetBit(limex->initDS, sds_i);
for (const auto &e : edges_range(h)) {
u32 from = args.state_ids.at(source(e, h));
u32 to = args.state_ids.at(target(e, h));
+ // cppcheck-suppress knownConditionTrueFalse
if (from == NO_STATE || to == NO_STATE) {
continue;
}
for (const auto &e : edges_range(h)) {
u32 from = args.state_ids.at(source(e, h));
u32 to = args.state_ids.at(target(e, h));
+ // cppcheck-suppress knownConditionTrueFalse
if (from == NO_STATE || to == NO_STATE) {
continue;
}
return false;
}
const u32 i = state_ids.at(v);
+ // cppcheck-suppress knownConditionTrueFalse
if (i == NO_STATE) {
continue;
}
continue;
}
u32 j = args.state_ids.at(w);
+ // cppcheck-suppress knownConditionTrueFalse
if (j == NO_STATE) {
continue;
}
#ifdef ARCH_64_BIT
t >>= 1; // Due to diffmask64, which leaves holes in the bitmask.
#endif
+ // cppcheck-suppress unsignedLessThanZero
assert(t < ARRAY_LENGTH(chunks));
CHUNK_T word = chunks[t];
assert(word != 0);
}
bool has_eod_accepts(const raw_dfa &rdfa) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &ds : rdfa.states) {
if (!ds.reports_eod.empty()) {
return true;
}
bool has_non_eod_accepts(const raw_dfa &rdfa) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &ds : rdfa.states) {
if (!ds.reports.empty()) {
return true;
fprintf(f, "astart: %hu, fstart: %hu\n", m->start_anchored,
m->start_floating);
fprintf(f, "single accept: %d, has_accel: %d\n",
- !!(int)m->flags & MCCLELLAN_FLAG_SINGLE, m->has_accel);
+ !!(m->flags & MCCLELLAN_FLAG_SINGLE), m->has_accel);
}
static
fprintf(f, "astart: %hu, fstart: %hu\n", m->start_anchored,
m->start_floating);
fprintf(f, "single accept: %d, has_accel: %d\n",
- !!(int)m->flags & MCSHENG_FLAG_SINGLE, m->has_accel);
+ !!(m->flags & MCSHENG_FLAG_SINGLE), m->has_accel);
fprintf(f, "sheng_end: %hu\n", m->sheng_end);
fprintf(f, "sheng_accel_limit: %hu\n", m->sheng_accel_limit);
}
fprintf(f, "astart: %hu, fstart: %hu\n", m->start_anchored,
m->start_floating);
fprintf(f, "single accept: %d, has_accel: %d\n",
- !!(int)m->flags & MCSHENG_FLAG_SINGLE, m->has_accel);
+ !!(m->flags & MCSHENG_FLAG_SINGLE), m->has_accel);
fprintf(f, "sheng_end: %hu\n", m->sheng_end);
fprintf(f, "sheng_accel_limit: %hu\n", m->sheng_accel_limit);
}
static
void writeDeadPoint(mpv_kilopuff *out, const vector<raw_puff> &puffs) {
for (const auto &puff : puffs) {
+ // cppcheck-suppress useStlAlgorithm
if (puff.unbounded) { /* mpv can never die */
out->dead_point = MPV_DEAD_VALUE;
return;
const mpv_counter_info &findCounter(const vector<mpv_counter_info> &counters,
u32 i) {
for (const auto &counter : counters) {
+ // cppcheck-suppress useStlAlgorithm
if (i >= counter.kilo_begin && i < counter.kilo_end) {
return counter;
}
static
string getDescriptionLimEx(const NFA *nfa) {
const typename NFATraits<t>::implNFA_t *limex =
- (const typename NFATraits<t>::implNFA_t *)getImplNfa(nfa);
+ reinterpret_cast<const typename NFATraits<t>::implNFA_t *>(getImplNfa(nfa));
ostringstream oss;
oss << NFATraits<t>::name << "/" << limex->exceptionCount;
if (limex->repeatCount) {
char c2 = nfa->rAccelData.array[1];
if (!twofer) {
- fprintf(f, " \\x%02hhx (%c) ", c1, isprint(c1) ? c1 : '?');
+ fprintf(f, " \\x%02hhx (%c) ", static_cast<u8>(c1), isprint(c1) ? c1 : '?');
} else {
- fprintf(f, " \\x%02hhx\\x%02hhx (%c%c) ", c1, c2,
+ fprintf(f, " \\x%02hhx\\x%02hhx (%c%c) ", static_cast<u8>(c1), static_cast<u8>(c2),
isprint(c1) ? c1 : '?', isprint(c2) ? c2 : '?');
}
- fprintf(f, "offset %hhd\n", nfa->rAccelOffset);
+ fprintf(f, "offset %hhu\n", nfa->rAccelOffset);
}
} // namespace ue2
}
bool raw_dfa::hasEodReports(void) const {
+ // cppcheck-suppress useStlAlgorithm
for (const dstate &ds : states) {
if (!ds.reports_eod.empty()) {
return true;
u16 alpha_size = 0; /* including special symbols */
/* mapping from input symbol --> equiv class id */
- std::array<u16, ALPHABET_SIZE> alpha_remap;
+ std::array<u16, ALPHABET_SIZE> alpha_remap{};
explicit raw_dfa(nfa_kind k) : kind(k) {}
virtual ~raw_dfa();
// Must all be external reports.
assert(rm);
+ // cppcheck-suppress useStlAlgorithm
for (const auto &report_id : test_reports) {
if (!isExternalReport(rm->getReport(report_id))) {
return false;
flat_set<ReportID> seen_reports;
for (const auto &rdfa : nfas) {
for (const auto &report_id : all_reports(*rdfa)) {
+ // cppcheck-suppress useStlAlgorithm
if (!seen_reports.insert(report_id).second) {
DEBUG_PRINTF("report %u in several dfas\n", report_id);
return true;
fprintf(f, "aux base offset: %u, reports base offset: %u, "
"accel offset: %u\n",
s->aux_offset, s->report_offset, s->accel_offset);
- fprintf(f, "anchored start state: %u, floating start state: %u\n",
+ fprintf(f, "anchored start state: %d, floating start state: %d\n",
s->anchored & SHENG_STATE_MASK, s->floating & SHENG_STATE_MASK);
fprintf(f, "has accel: %u can die: %u single report: %u\n",
!!(s->flags & SHENG_FLAG_HAS_ACCEL),
fprintf(f, "aux base offset: %u, reports base offset: %u, "
"accel offset: %u\n",
s->aux_offset, s->report_offset, s->accel_offset);
- fprintf(f, "anchored start state: %u, floating start state: %u\n",
+ fprintf(f, "anchored start state: %d, floating start state: %d\n",
s->anchored & SHENG32_STATE_MASK, s->floating & SHENG32_STATE_MASK);
fprintf(f, "has accel: %u can die: %u single report: %u\n",
!!(s->flags & SHENG_FLAG_HAS_ACCEL),
fprintf(f, "aux base offset: %u, reports base offset: %u, "
"accel offset: %u\n",
s->aux_offset, s->report_offset, s->accel_offset);
- fprintf(f, "anchored start state: %u, floating start state: %u\n",
+ fprintf(f, "anchored start state: %d, floating start state: %d\n",
s->anchored & SHENG64_STATE_MASK, s->floating & SHENG64_STATE_MASK);
fprintf(f, "has accel: %u can die: %u single report: %u\n",
!!(s->flags & SHENG_FLAG_HAS_ACCEL),
for (u32 pos = 0; pos < 16; pos++) {
u8 c = buf[pos];
if (c & SHENG_STATE_FLAG_MASK) {
- fprintf(f, "%2u* ", c & SHENG_STATE_MASK);
+ fprintf(f, "%2d* ", c & SHENG_STATE_MASK);
} else {
- fprintf(f, "%2u ", c & SHENG_STATE_MASK);
+ fprintf(f, "%2d ", c & SHENG_STATE_MASK);
}
}
fprintf(f, "\n");
for (u32 pos = 0; pos < 64; pos++) {
u8 c = buf[pos];
if (c & SHENG32_STATE_FLAG_MASK) {
- fprintf(f, "%2u* ", c & SHENG32_STATE_MASK);
+ fprintf(f, "%2d* ", c & SHENG32_STATE_MASK);
} else {
- fprintf(f, "%2u ", c & SHENG32_STATE_MASK);
+ fprintf(f, "%2d ", c & SHENG32_STATE_MASK);
}
}
fprintf(f, "\n");
for (u32 pos = 0; pos < 64; pos++) {
u8 c = buf[pos];
if (c & SHENG64_STATE_FLAG_MASK) {
- fprintf(f, "%2u* ", c & SHENG64_STATE_MASK);
+ fprintf(f, "%2d* ", c & SHENG64_STATE_MASK);
} else {
- fprintf(f, "%2u ", c & SHENG64_STATE_MASK);
+ fprintf(f, "%2d ", c & SHENG64_STATE_MASK);
}
}
fprintf(f, "\n");
template <typename T>
static
void describeNode(UNUSED const NFA *n, UNUSED const T *s, UNUSED u16 i,
- UNUSED FILE *f) {
+ UNUSED FILE *f) { // cppcheck-suppress constParameterPointer
}
template <>
rv = nfaQueueExecRose(q1.nfa, &q1, report);
}
- DEBUG_PRINTF("exec rose rv:%u\n", rv);
+ DEBUG_PRINTF("exec rose rv:%d\n", rv);
return rv;
}
sizeof(u32) * subSize + 64; // offsets to subengines in bytecode and
// padding for subengines
- auto subl = [](size_t z, NFA *sub) {
+ auto subl = [](size_t z, const NFA *sub) {
return z + (size_t)(ROUNDUP_CL(sub->length));
};
total_size += std::accumulate(tamaInfo.subengines.begin(), tamaInfo.subengines.end(), 0, subl);
* 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)) {
#ifndef NDEBUG
static
bool hasEdgeAsserts(NFAVertex v, const NGHolder &g) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(v, g)) {
if (g[e].assert_flags != 0) {
return true;
}
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(v, g)) {
if (g[e].assert_flags != 0) {
return true;
nfa_kind kind; /* Role that this plays in Rose */
+ // cppcheck-suppress duplInheritedMember
static const size_t N_SPECIAL_VERTICES = N_SPECIALS;
public:
const vertex_descriptor start; //!< Anchored start vertex.
return false;
}
u32 s = state_ids.at(v);
+ // cppcheck-suppress knownConditionTrueFalse
if (s != NO_STATE && !seen_states.insert(s).second) {
DEBUG_PRINTF("vertex %zu has dupe state %u\n", g[v].index, s);
return false;
auto cands = [&g=g](const NFAVertex &u) {
return (hasSelfLoop(u, g));
};
- const auto &u = unhandled_succ_tops | map_keys;
- std::copy_if(begin(u), end(u), std::back_inserter(cand_starts), cands);
+ const auto &ust = unhandled_succ_tops | map_keys;
+ std::copy_if(begin(ust), end(ust), std::back_inserter(cand_starts), cands);
for (NFAVertex u : cand_starts) {
if (!contains(unhandled_succ_tops, u)) {
/* paths segments which are a superset of an earlier segment should never be
* picked as an acceleration segment -> to improve processing just replace
* with dot */
+ // cppcheck-suppress constVariableReference
for (auto &p : paths) {
for (auto it = p.begin(); it != p.end(); ++it) {
for (auto jt = next(it); jt != p.end(); ++jt) {
static
u64a litCountBits(const ue2_literal &lit) {
u64a n = 0;
- // cppcheck-suppress useStlAlgorithm
for (const auto &c : lit) {
+ // cppcheck-suppress useStlAlgorithm
n += c.nocase ? 7 : 8;
}
return n;
vector<LitEdge> fwd_edges;
fwd_edges.reserve(edge_count);
- const auto &e = edges_range(lg);
- std::copy(begin(e), end(e), std::back_inserter(fwd_edges));
+ const auto &er = edges_range(lg);
+ std::copy(begin(er), end(er), std::back_inserter(fwd_edges));
vector<LitEdge> rev_map(2 * edge_count);
}
// Our last value for v should have only start states for predecessors.
+ // cppcheck-suppress useStlAlgorithm
for (auto u : inv_adjacent_vertices_range(v, g)) {
if (!is_any_start(u, g)) {
DEBUG_PRINTF("pred is not start\n");
static
bool hasLargeDegreeVertex(const NGHolder &g) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &v : vertices_range(g)) {
if (is_special(v, g)) { // specials can have large degree
continue;
static
bool allExternalReports(const ReportManager &rm,
const flat_set<ReportID> &reports) {
+ // cppcheck-suppress useStlAlgorithm
for (auto report_id : reports) {
if (!isExternalReport(rm.getReport(report_id))) {
return false;
continue;
}
for (const auto &trigger : triggers) {
+ // cppcheck-suppress useStlAlgorithm
if (triggerAllowed(g, v, triggers, trigger)) {
DEBUG_PRINTF("idx %zu is valid location for top\n", g[v].index);
out->set(g[v].index);
static
bool anyOutSpecial(NFAVertex v, const NGHolder &g) {
+ // cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (is_special(w, g) && w != v) {
return true;
const std::unordered_map<NFAVertex, u32> ®ion_map) {
// Note that some graph types do not have inv_adjacent_vertices, so we must
// use in_edges here.
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : in_edges_range(v, g)) {
if (!inSameRegion(g, v, source(e, g), region_map)) {
return true;
template <class Graph>
bool isRegionExit(const Graph &g, NFAVertex v,
const std::unordered_map<NFAVertex, u32> ®ion_map) {
+ // cppcheck-suppress useStlAlgorithm
for (auto w : adjacent_vertices_range(v, g)) {
if (!inSameRegion(g, v, w, region_map)) {
return true;
DEBUG_PRINTF("already seen pos %zu\n", g[br.pos_trigger].index);
return true;
}
+ // cppcheck-suppress useStlAlgorithm
for (auto v : br.tug_triggers) {
if (contains(involved, v)) {
DEBUG_PRINTF("already seen tug %zu\n", g[v].index);
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);
}
}
bool isCorrectlyTopped(const NGHolder &g) {
if (is_triggered(g)) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(g.start, g)) {
if (g[e].tops.empty() != (target(e, g) == g.startDs)) {
return false;
}
}
} else {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : out_edges_range(g.start, g)) {
if (!g[e].tops.empty()) {
return false;
ComponentSequence *seq = child.get();
parent->addComponent(std::move(child));
- return seq;
+ return seq; // cppcheck-suppress returnDanglingLifetime
}
static
const NFABuilder &getBuilder() const override { return builder; }
/** \brief Wire up the lasts of one component to the firsts of another. */
- void connectRegions(const vector<PositionInfo> &lasts,
+ // cppcheck-suppress virtualCallInConstructor
+ virtual void connectRegions(const vector<PositionInfo> &lasts,
const vector<PositionInfo> &firsts) override;
/** \brief Wire the lasts of the main sequence to accepts. */
try {
%% write exec;
} catch (LocatedParseError &error) {
+ // cppcheck-suppress pointerLessThanZero
+ // cppcheck-suppress pointerPositive
if (ts >= ptr && ts <= pe) {
error.locate(ts - ptr + start);
} else {
/** Class representing a component state. */
class PositionInfo {
public:
+ // cppcheck-suppress noExplicitConstructor
PositionInfo(unsigned int p) : pos(p), flags(0) {}
bool operator<(const PositionInfo &other) const {
assert(root);
PrefilterVisitor vis(root.get(), mode);
+ // cppcheck-suppress constVariablePointer
Component *c = root->accept(vis);
if (c != root.get()) {
root.reset(c);
#ifndef NDEBUG
static
bool validateKinds(const RoseInGraph &g) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : edges_range(g)) {
if (g[e].graph && g[e].graph->kind != whatRoseIsThis(g, e)) {
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)) {
+ added_lit_ids)) { // cppcheck-suppress useStlAlgorithm
removeAddedLiterals(*this, added_lit_ids);
return false;
}
}
}
- if (curr.back().length() > MAX_MASK2_WIDTH &&
+ if (!curr.empty() && curr.back().length() > MAX_MASK2_WIDTH &&
any_of(begin(curr), end(curr), mixed_sensitivity)) {
DEBUG_PRINTF("mixed-sensitivity lit is too long, stopping\n");
return false;
}
const RoseGraph &g = build.g;
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
if (g[v].eod_accept) {
DEBUG_PRINTF("literally report eod\n");
if (pfrag.included_frag_id != INVALID_FRAG_ID &&
!lit_prog.empty()) {
const auto &cfrag = fragments[pfrag.included_frag_id];
- assert(pfrag.s.length() >= cfrag.s.length() &&
- !pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
+ // cppcheck-suppress comparisonOfTwoFuncsReturningBoolError
+ assert(pfrag.s.length() >= cfrag.s.length() && !pfrag.s.any_nocase() >= !cfrag.s.any_nocase());
u32 child_offset = cfrag.lit_program_offset;
DEBUG_PRINTF("child %u offset %u\n", cfrag.fragment_id,
child_offset);
/* ensure bounds on the vertex's in-edge are correct */
assert(in_degree(v, tbi.g) == 1);
const RoseEdge &e = *in_edges(v, tbi.g).first;
- assert(tbi.g[e].minBound == sai.min_bound + sai.literal.length());
- assert(tbi.g[e].maxBound == sai.max_bound + sai.literal.length());
- tbi.g[e].minBound = sai.min_bound;
- tbi.g[e].maxBound = sai.max_bound;
+ tbi.g[e].minBound = sai.min_bound; // cppcheck-suppress danglingTempReference
+ tbi.g[e].maxBound = sai.max_bound; // cppcheck-suppress danglingTempReference
}
/* mark the old literal as empty */
#ifndef NDEBUG
static
bool historiesAreValid(const RoseGraph &g) {
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : edges_range(g)) {
if (g[e].history == ROSE_ROLE_HISTORY_INVALID) {
DEBUG_PRINTF("edge [%zu,%zu] has invalid history\n",
* that no longer exists in the graph.
*/
static
-bool danglingVertexRef(RoseBuildImpl &tbi) {
+bool danglingVertexRef(const RoseBuildImpl &tbi) {
RoseGraph::vertex_iterator vi, ve;
tie(vi, ve) = vertices(tbi.g);
const unordered_set<RoseVertex> valid_vertices(vi, ve);
return true;
}
+ // cppcheck-suppress useStlAlgorithm
for (const auto &e : tbi.ghost) {
if (!contains(valid_vertices, e.first)) {
DEBUG_PRINTF("ghost key vertex %zu not in graph\n",
static
bool roleOffsetsAreValid(const RoseGraph &g) {
+ // cppcheck-suppress useStlAlgorithm
for (auto v : vertices_range(g)) {
if (g[v].min_offset >= ROSE_BOUND_INF) {
DEBUG_PRINTF("invalid min_offset for role %zu\n", g[v].index);
os << " base_offset " << ri->base_offset << endl;
os << " last_start " << ri->last_start << endl;
os << " fail_jump " << offset + ri->fail_jump << endl;
+ // cppcheck-suppress pointerOutOfBounds
dumpMultipathShufti(os, 16, ri->nib_mask, ri->nib_mask + 16,
ri->bucket_select_mask,
ri->data_select_mask,
}
}
+ // cppcheck-suppress invalidPrintfArgType_sint
fprintf(f, "%u,%zd,\"%s\",%u,%u,%u,%s,%s\n", i,
(reinterpret_cast<const char *>(n) - reinterpret_cast<const char *>(t)), describe(*n).c_str(),
n->nPositions, n->streamStateSize, n->length,
bool isSuffix(const vector<vector<CharReach>> &triggers1,
const vector<vector<CharReach>> &triggers2) {
// literal suffix test
+ // cppcheck-suppress useStlAlgorithm
for (const auto &lit1 : triggers1) {
// cppcheck-suppress useStlAlgorithm
for (const auto &lit2 : triggers2) {
}
for (const auto &e : leftfixes) {
+ // cppcheck-suppress useStlAlgorithm
if (all_tops(e.first) != e.second) {
DEBUG_PRINTF("rose tops (%s) don't match rose graph (%s)\n",
as_string_list(all_tops(e.first)).c_str(),
}
for (const auto &e : suffixes) {
+ // cppcheck-suppress useStlAlgorithm
if (all_tops(e.first) != e.second) {
DEBUG_PRINTF("suffix tops (%s) don't match rose graph (%s)\n",
as_string_list(all_tops(e.first)).c_str(),
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 &&
+ // cppcheck-suppress useStlAlgorithm
build.g[v].left.leftfix_report == report) {
DEBUG_PRINTF("report %u still in use\n", report);
return;
const RoseGraph &g = tbi.g;
vector<RoseVertex> table_verts;
- auto tvs = [&tbi=tbi, &table=table](const RoseVertex &v) {
+ auto tvs = [&tbi=tbi, table](const RoseVertex &v) {
return (tbi.hasLiteralInTable(v, table));
};
const auto &vr = vertices_range(g);
table == ROSE_FLOATING ? "floating" : "anchored");
vector<RoseVertex> table_verts;
- auto tvs = [&tbi=tbi, &table=table](const RoseVertex &v) {
+ auto tvs = [&tbi=tbi, table](const RoseVertex &v) {
return ((table == ROSE_FLOATING && tbi.isFloating(v))
|| (table == ROSE_ANCHORED && tbi.isAnchored(v)));
};
fprintf(f, "\t shared reset (users = %zu)\n", ir.entries.size());
} else if (contains(by_slot, i)) {
const SlotCacheEntry &ce = *by_slot.at(i);
+ // cppcheck-suppress knownConditionTrueFalse
if (ce.parent_slot != SomSlotManager::NO_PARENT) {
fprintf(f, "\tparent:%u", ce.parent_slot);
}
// aligned load
static really_inline m128 load128(const void *ptr) {
assert(ISALIGNED_N(ptr, alignof(m128)));
+ // cppcheck-suppress cstyleCast
return (m128) vld1q_s32((const int32_t *)ptr);
}
// aligned store
static really_inline void store128(void *ptr, m128 a) {
assert(ISALIGNED_N(ptr, alignof(m128)));
+ // cppcheck-suppress cstyleCast
vst1q_s32((int32_t *)ptr, a);
}
// unaligned load
static really_inline m128 loadu128(const void *ptr) {
+ // cppcheck-suppress cstyleCast
return (m128) vld1q_s32((const int32_t *)ptr);
}
// unaligned store
static really_inline void storeu128(void *ptr, m128 a) {
+ // cppcheck-suppress cstyleCast
vst1q_s32((int32_t *)ptr, a);
}
static really_inline
m128 set4x32(u32 x3, u32 x2, u32 x1, u32 x0) {
uint32_t ALIGN_ATTR(16) data[4] = { x0, x1, x2, x3 };
+ // cppcheck-suppress cstyleCast
return (m128) vld1q_u32((uint32_t *) data);
}
static really_inline
m128 set2x64(u64a hi, u64a lo) {
uint64_t ALIGN_ATTR(16) data[2] = { lo, hi };
+ // cppcheck-suppress cstyleCast
return (m128) vld1q_u64((uint64_t *) data);
}
// aligned load
static really_inline m128 load128(const void *ptr) {
assert(ISALIGNED_N(ptr, alignof(m128)));
+ // cppcheck-suppress cstyleCast
return (m128) vec_xl(0, (const int32_t*)ptr);
}
// aligned store
static really_inline void store128(void *ptr, m128 a) {
assert(ISALIGNED_N(ptr, alignof(m128)));
+ // cppcheck-suppress cstyleCast
vec_st(a, 0, (int32_t*)ptr);
}
// unaligned load
static really_inline m128 loadu128(const void *ptr) {
+ // cppcheck-suppress cstyleCast
return (m128) vec_xl(0, (const int32_t*)ptr);
}
// unaligned store
static really_inline void storeu128(void *ptr, m128 a) {
+ // cppcheck-suppress cstyleCast
vec_xst(a, 0, (int32_t*)ptr);
}
static depth unreachable() {
depth d;
- d.val = val_unreachable;
return d;
}
}
s64a rv = val + d;
- if (rv < 0 || (u64a)rv >= val_infinity) {
+ if ((u64a)rv >= val_infinity) {
DEBUG_PRINTF("depth %lld too large to represent!\n", rv);
throw DepthOverflowError();
}
}
s64a rv = val - d;
- if (rv < 0 || (u64a)rv >= val_infinity) {
+ if ((u64a)rv >= val_infinity) {
DEBUG_PRINTF("depth %lld too large to represent!\n", rv);
throw DepthOverflowError();
}
int out_count = describeClassInt(out, incr, maxLength, out_type);
std::ostringstream neg;
- UNUSED int neg_count = describeClassInt(neg, ~incr, maxLength, out_type);
-
if (out.tellp() <= neg.tellp()) {
if (out_count > 1) {
os << '[' << out.str() << ']';
public:
template <class OtherIter, class OtherValue>
+ // cppcheck-suppress noExplicitConstructor
iter_wrapper(iter_wrapper<OtherIter, OtherValue> other,
typename std::enable_if<std::is_convertible<
OtherIter, WrappedIter>::value>::type * = nullptr)
adj_edge_iterator<Reverse>, edge_descriptor,
boost::forward_traversal_tag, edge_descriptor> {
vertex_descriptor u;
- const base_type *g;
+ const base_type *g = nullptr;
typename Traits::in_edge_iterator in_it;
typename Traits::out_edge_iterator out_it;
bool done_in = false;
: public boost::iterator_facade<edge_iterator, edge_descriptor,
boost::forward_traversal_tag,
edge_descriptor> {
- const base_type *g;
+ const base_type *g = nullptr;
typename Traits::edge_iterator it;
public:
edge_iterator() = default;
template<class, class> friend class iter_wrapper;
template<class OtherIter, class OtherValue>
+ // cppcheck-suppress noExplicitConstructor
iter_wrapper(iter_wrapper<OtherIter, OtherValue> other,
typename std::enable_if<std::is_convertible<
OtherIter, WrappedIter>::value>::type * = nullptr)
assert(sub != INVALID_SUBSET);
ENSURE_AT_LEAST(&subset_count, sub + 1);
}
+ // cppcheck-suppress unsignedPositive
assert(subset_count <= state_to_subset.size());
subsets.resize(subset_count);
template <>
really_inline SuperVector<16> SuperVector<16>::loadu(void const *ptr)
{
- return SuperVector<16>(vec_xl(0, (const long64_t*)ptr));
+ return SuperVector<16>(vec_xl(0, reinterpret_cast<const long64_t*>(ptr)));
}
template <>
really_inline SuperVector<16> SuperVector<16>::load(void const *ptr)
{
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
- return SuperVector<16>(vec_xl(0, (const long64_t*)ptr));
+ return SuperVector<16>(vec_xl(0, reinterpret_cast<const long64_t*>(ptr)));
}
template <>
#include "unaligned.h"
// Aligned loads
-#ifndef __cplusplus__
+#ifndef __cplusplus
#define load_u8(a) (*(const u8 *)(a))
#define load_u16(a) (*(const u16 *)(a))
#define load_u32(a) (*(const u32 *)(a))
#define load_u64a(a) (*(const u64a *)(a))
#else
-#define load_u8(a) (*(reinterpret_cast<const u8 *>(a))
-#define load_u16(a) (*(reinterpret_cast<const u16 *>(a))
-#define load_u32(a) (*(reinterpret_cast<const u32 *>(a))
-#define load_u64a(a) (*(reinterpret_cast<const u64a *>(a))
+#define load_u8(a) (*(reinterpret_cast<const u8 *>(a)))
+#define load_u16(a) (*(reinterpret_cast<const u16 *>(a)))
+#define load_u32(a) (*(reinterpret_cast<const u32 *>(a)))
+#define load_u64a(a) (*(reinterpret_cast<const u64a *>(a)))
#endif // __cplusplus__
#define load_m128(a) load128(a)
#define load_m256(a) load256(a)
#define load_m512(a) load512(a)
// Unaligned loads
-#ifndef __cplusplus__
+#ifndef __cplusplus
#define loadu_u8(a) (*(const u8 *)(a))
#define loadu_u16(a) unaligned_load_u16((const u8 *)(a))
#define loadu_u32(a) unaligned_load_u32((const u8 *)(a))
#define loadu_u16(a) unaligned_load_u16(reinterpret_cast<const u8 *>(a))
#define loadu_u32(a) unaligned_load_u32(reinterpret_cast<const u8 *>(a))
#define loadu_u64a(a) unaligned_load_u64a(reinterpret_cast<const u8 *>(a))
-#endif // __cplusplus__
+#endif // __cplusplus
#define loadu_m128(a) loadu128(a)
#define loadu_m256(a) loadu256(a)
#define loadu_m384(a) loadu384(a)
#define loadu_m512(a) loadu512(a)
// Aligned stores
-#ifndef __cplusplus__
+#ifndef __cplusplus
+#define store_u8(ptr, a) do { *((u8 *)(ptr)) = (a); } while(0)
+#define store_u16(ptr, a) do { *((u16 *)(ptr)) = (a); } while(0)
+#define store_u32(ptr, a) do { *((u32 *)(ptr)) = (a); } while(0)
+#define store_u64a(ptr, a) do { *((u64a *)(ptr)) = (a); } while(0)
+#else
#define store_u8(ptr, a) do { *(reinterpret_cast<u8 *>(ptr)) = (a); } while(0)
#define store_u16(ptr, a) do { *(reinterpret_cast<u16 *>(ptr)) = (a); } while(0)
#define store_u32(ptr, a) do { *(reinterpret_cast<u32 *>(ptr)) = (a); } while(0)
#define store_u64a(ptr, a) do { *(reinterpret_cast<u64a *>(ptr)) = (a); } while(0)
-#else
-#endif // __cplusplus__
+#endif // __cplusplus
#define store_m128(ptr, a) store128(ptr, a)
#define store_m256(ptr, a) store256(ptr, a)
#define store_m384(ptr, a) store384(ptr, a)
#define store_m512(ptr, a) store512(ptr, a)
// Unaligned stores
-#ifndef __cplusplus__
+#ifndef __cplusplus
#define storeu_u8(ptr, a) do { *(u8 *)(ptr) = (a); } while(0)
#else
#define storeu_u8(ptr, a) do { *(reinterpret_cast<u8 *>(ptr)) = (a); } while(0)
-#endif // __cplusplus__
+#endif // __cplusplus
#define storeu_u16(ptr, a) unaligned_store_u16(ptr, a)
#define storeu_u32(ptr, a) unaligned_store_u32(ptr, a)
#define storeu_u64a(ptr, a) unaligned_store_u64a(ptr, a)
class EngineCHContext : public EngineContext{
public:
explicit EngineCHContext(const ch_database_t *db);
- ~EngineCHContext();
+ virtual ~EngineCHContext() override;
ch_scratch_t *scratch = nullptr;
};
class EngineChimera : public Engine {
public:
explicit EngineChimera(ch_database_t *db, CompileCHStats cs);
- ~EngineChimera();
+ virtual ~EngineChimera() override;
std::unique_ptr<EngineContext> makeContext() const override;
class EngineHSContext : public EngineContext {
public:
explicit EngineHSContext(const hs_database_t *db);
- ~EngineHSContext();
+ virtual ~EngineHSContext() override;
hs_scratch_t *scratch = nullptr;
};
/** Streaming mode scans have persistent stream state associated with them. */
class EngineHSStream : public EngineStream {
public:
- ~EngineHSStream();
+ virtual ~EngineHSStream() override;
hs_stream_t *id = nullptr;
EngineHSContext *ctx = nullptr;
};
class EngineHyperscan : public Engine {
public:
explicit EngineHyperscan(hs_database_t *db, CompileHSStats cs);
- ~EngineHyperscan();
+ virtual ~EngineHyperscan() override;
std::unique_ptr<EngineContext> makeContext() const override;
class EnginePCREContext : public EngineContext{
public:
explicit EnginePCREContext(int capture_cnt);
- ~EnginePCREContext();
+ virtual ~EnginePCREContext() override;
int *ovec = nullptr;
};
public:
explicit EnginePCRE(std::vector<std::unique_ptr<PcreDB>> dbs_in,
CompilePCREStats cs, int capture_cnt_in);
- ~EnginePCRE();
+ virtual ~EnginePCRE() override;
std::unique_ptr<EngineContext> makeContext() const override;
// 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) {
+ if (!all_of(begin(t->results), end(t->results), [&matchesPerRun](const ResultEntry &e) {
return e.matches == matchesPerRun;
- })) {
+ })) { // cppcheck-suppress useStlAlgorithm
printf("\nWARNING: PER-SCAN MATCH COUNTS ARE INCONSISTENT!\n\n");
break;
}
// 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) {
+ if (!all_of(begin(t->results), end(t->results), [&matchesPerRun](const ResultEntry &e) {
return e.matches == matchesPerRun;
- })) {
+ })) { // cppcheck-suppress useStlAlgorithm
printf("\nWARNING: PER-SCAN MATCH COUNTS ARE INCONSISTENT!\n\n");
break;
}
// 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) {
+ if (!all_of(begin(t->results), end(t->results), [&matchesPerRun](const ResultEntry &e) {
return e.matches == matchesPerRun;
- })) {
+ })) { // cppcheck-suppress useStlAlgorithm
printf("\nWARNING: PER-SCAN MATCH COUNTS ARE INCONSISTENT!\n\n");
break;
}
for (unsigned i = 0; i < numThreads; i++) {
auto t = makeThreadContext(db, corpus_blocks, i, sync_barrier);
+ // cppcheck-suppress knownConditionTrueFalse
int core = useAffinity ? (int)threadCores[i] : -1;
if (!t->start(core)) {
printf("Unable to start processing thread %u\n", i);
}
static
-void processArgs(int argc, char *argv[], Grey &grey) {
+void processArgs(int argc, char *argv[], Grey &grey) { // cppcheck-suppress constParameterReference
static const char *options = "d:De:E:G:hLNo:Ps:VXx:z:8";
static struct option longOptions[] = {
{"dump_db", no_argument, nullptr, 'D'},
size_t len = 0;
hs_error_t err = hs_serialize_database(out, &bytes, &len);
if (err != HS_SUCCESS) {
- printf("ERROR: hs_serialize_database() failed with error %u\n", err);
+ printf("ERROR: hs_serialize_database() failed with error %d\n", err);
return;
}
exit(1);
}
- struct dirent *d_ent;
+ const struct dirent *d_ent;
while (nullptr != (d_ent = readdir(dir))) {
string name(d_ent->d_name);
if (name == "." || name == "..") {
(grey.dumpPath + "scratch.txt").c_str(), strerror(errno));
}
} else {
- printf("ERROR: hs_alloc_scratch() failed with error %u\n", err);
+ printf("ERROR: hs_alloc_scratch() failed with error %d\n", err);
}
hs_free_scratch(scratch);
}
(grey.dumpPath + "db_info.txt").c_str(), strerror(errno));
}
} else {
- printf("ERROR: hs_database_info() failed with error %u\n", err);
+ printf("ERROR: hs_database_info() failed with error %d\n", err);
}
free(info);
}
if (compile_err && compile_err->message) {
printf("ERROR: Compile failed: %s\n", compile_err->message);
} else {
- printf("ERROR: hs_compile_multi_int() returned error %u", err);
+ printf("ERROR: hs_compile_multi_int() returned error %d", err);
}
hs_free_compile_error(compile_err);
return 1;
*(reinterpret_cast<size_t *>(pp)) = n;
void *p = static_cast<char *>(pp) + 16;
+ // cppcheck-suppress memleak
return p;
}
*(reinterpret_cast<size_t *>(pp)) = n;
void *p = static_cast<char *>(pp) + 32;
+ // cppcheck-suppress memleak
return p;
}
cr2 = cr;
ASSERT_EQ(cr.count(), cr2.count());
- ASSERT_TRUE(cr == cr2);
}
TEST(ng_charreach, flip) {
static
-bytecode_ptr<FDR> buildFDREngineHinted(std::vector<hwlmLiteral> &lits,
+bytecode_ptr<FDR> buildFDREngineHinted(const std::vector<hwlmLiteral> &lits,
bool make_small, u32 hint,
const target_t &target,
const Grey &grey) {
}
static
-bytecode_ptr<FDR> buildFDREngine(std::vector<hwlmLiteral> &lits,
+bytecode_ptr<FDR> buildFDREngine(const std::vector<hwlmLiteral> &lits,
bool make_small, const target_t &target,
const Grey &grey) {
auto proto = fdrBuildProto(HWLM_ENGINE_FDR, lits, make_small, target, grey);
}
static
-bytecode_ptr<FDR> buildFDREngineHinted(std::vector<hwlmLiteral> &lits,
+bytecode_ptr<FDR> buildFDREngineHinted(const std::vector<hwlmLiteral> &lits,
bool make_small, u32 hint,
const target_t &target,
const Grey &grey) {
TEST(flat_map, compare_ops) {
flat_map<u32, u32> f1 = {{0, 1}, {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}};
- flat_map<u32, u32> f1_copy = f1;
flat_map<u32, u32> f2 = {{2, 1}, {4, 2}, {6, 3}, {8, 4}, {10, 5}, {12, 6}};
EXPECT_TRUE(f1 == f1);
- EXPECT_TRUE(f1 == f1_copy);
EXPECT_FALSE(f1 == f2);
EXPECT_FALSE(f1 != f1);
- EXPECT_FALSE(f1 != f1_copy);
EXPECT_TRUE(f1 != f2);
EXPECT_FALSE(f1 < f1);
- EXPECT_FALSE(f1 < f1_copy);
EXPECT_TRUE(f1 < f2);
EXPECT_TRUE(f1 <= f1);
- EXPECT_TRUE(f1 <= f1_copy);
EXPECT_TRUE(f1 <= f2);
EXPECT_FALSE(f1 > f1);
- EXPECT_FALSE(f1 > f1_copy);
EXPECT_FALSE(f1 > f2);
EXPECT_TRUE(f1 >= f1);
- EXPECT_TRUE(f1 >= f1_copy);
EXPECT_FALSE(f1 >= f2);
}
TEST(flat_set, compare_ops) {
flat_set<u32> f1 = {1, 2, 3, 4, 5};
- flat_set<u32> f1_copy = f1;
flat_set<u32> f2 = {2, 4, 6, 8, 10};
EXPECT_TRUE(f1 == f1);
- EXPECT_TRUE(f1 == f1_copy);
EXPECT_FALSE(f1 == f2);
EXPECT_FALSE(f1 != f1);
- EXPECT_FALSE(f1 != f1_copy);
EXPECT_TRUE(f1 != f2);
EXPECT_FALSE(f1 < f1);
- EXPECT_FALSE(f1 < f1_copy);
EXPECT_TRUE(f1 < f2);
EXPECT_TRUE(f1 <= f1);
- EXPECT_TRUE(f1 <= f1_copy);
EXPECT_TRUE(f1 <= f2);
EXPECT_FALSE(f1 > f1);
- EXPECT_FALSE(f1 > f1_copy);
EXPECT_FALSE(f1 > f2);
EXPECT_TRUE(f1 >= f1);
- EXPECT_TRUE(f1 >= f1_copy);
EXPECT_FALSE(f1 >= f2);
}
}
operator u8 *() {
assert(data);
- return data.get() + 7;
+ return reinterpret_cast<u8 *>(data.get()) + 7;
}
operator const u8 *() const {
assert(data);
- return data.get() + 7;
+ return reinterpret_cast<u8 *>(data.get()) + 7;
}
private:
}
operator u8 *() {
assert(data);
- return data.get() + 7;
+ return reinterpret_cast<u8 *>(data.get()) + 7;
}
operator const u8 *() const {
assert(data);
- return data.get() + 7;
+ return reinterpret_cast<u8 *>(data.get()) + 7;
}
private:
}
operator u8 *() {
assert(data);
- return data.get() + 7;
+ return reinterpret_cast<u8 *>(data.get()) + 7;
}
operator const u8 *() const {
assert(data);
- return data.get() + 7;
+ return reinterpret_cast<u8 *>(data.get()) + 7;
}
private:
class RepeatTest : public TestWithParam<RepeatTestInfo> {
protected:
+ RepeatTest() = default;
virtual void SetUp() {
test_info = GetParam();
delete [] state_int;
}
- RepeatTestInfo test_info; // Test params
- RepeatInfo info; // Repeat info structure
- RepeatControl *ctrl;
- char *state;
+ RepeatTestInfo test_info{}; // Test params
+ RepeatInfo info{}; // Repeat info structure
+ RepeatControl *ctrl = nullptr;
+ char *state = nullptr;
private:
- char *state_int;
+ char *state_int = nullptr;
};
class SparseOptimalTest : public TestWithParam<tuple<u32, RepeatTestInfo> > {
protected:
+ SparseOptimalTest() = default;
virtual void SetUp() {
u32 period;
tie(period, test_info) = GetParam();
delete[] ptr;
}
- RepeatTestInfo test_info; // Test params
- RepeatInfo *info; // Repeat info structure
- RepeatControl *ctrl;
- char *state;
+ RepeatTestInfo test_info{}; // Test params
+ RepeatInfo *info = nullptr; // Repeat info structure
+ RepeatControl *ctrl = nullptr;
+ char *state = nullptr;
private:
- char *ptr;
- char *state_int;
+ char *ptr = nullptr;
+ char *state_int = nullptr;
};
public:
CorpusGeneratorImpl(const NGHolder &graph_in, const ExpressionInfo &expr_in,
CorpusProperties &props);
- virtual ~CorpusGeneratorImpl() = default;
+ virtual ~CorpusGeneratorImpl() override = default;
void generateCorpus(vector<string> &data) override;
public:
CorpusGeneratorUtf8(const NGHolder &graph_in, const ExpressionInfo &expr_in,
CorpusProperties &props);
- ~CorpusGeneratorUtf8() = default;
+ virtual ~CorpusGeneratorUtf8() override = default;
void generateCorpus(vector<string> &data) override;