mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Fix/Suppress remaining Cppcheck warnings (#291)
Fix/suppress the following cppcheck warnings: * arithOperationsOnVoidPointer * uninitMember * const* * shadowVariable * assignmentIntegerToAddress * containerOutOfBounds * pointer-related warnings in Ragel source * missingOverride * memleak * knownConditionTrueFalse * noExplicitConstructor * invalidPrintfArgType_sint * useStlAlgorithm * cstyleCast * clarifyCondition * VSX-related cstyleCast * unsignedLessThanZero Furthermore, we added a suppression list to be used, which also includes the following: * missingIncludeSystem * missingInclude * unmatchedSuppression
This commit is contained in:
parent
cebc6541c1
commit
c837925087
@ -278,7 +278,7 @@ int main(){
|
||||
// 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;
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
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_)
|
||||
|
12
cppcheck-suppression-list.txt
Normal file
12
cppcheck-suppression-list.txt
Normal file
@ -0,0 +1,12 @@
|
||||
unknownMacro:*gtest-all.cc
|
||||
knownConditionTrueFalse:*Parser.rl
|
||||
knownConditionTrueFalse:*Parser.cpp
|
||||
variableScope:*Parser.rl
|
||||
unreadVariable:*control_verbs.cpp
|
||||
assertWithSideEffect
|
||||
syntaxError
|
||||
internalError
|
||||
checkersReport
|
||||
missingInclude
|
||||
missingIncludeSystem
|
||||
unmatchedSuppression
|
@ -39,6 +39,7 @@ namespace ue2 {
|
||||
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;
|
||||
|
@ -113,7 +113,7 @@ void dumpTeddyDupMasks(const u8 *dmsk, u32 numMasks, FILE *f) {
|
||||
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++) {
|
||||
@ -131,7 +131,7 @@ void dumpTeddyMasks(const u8 *baseMsk, u32 numMasks, u32 maskWidth, FILE *f) {
|
||||
// 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++) {
|
||||
|
@ -93,6 +93,7 @@ void dumpLits(UNUSED const vector<hwlmLiteral> &lits) {
|
||||
// Called by an assertion.
|
||||
static
|
||||
bool everyoneHasGroups(const vector<hwlmLiteral> &lits) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &lit : lits) {
|
||||
if (!lit.groups) {
|
||||
return false;
|
||||
|
@ -595,6 +595,7 @@ void GoughSSAVarNew::generate(vector<gough_ins> *out) const {
|
||||
#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;
|
||||
@ -986,7 +987,6 @@ 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;
|
||||
|
@ -145,6 +145,7 @@ void dump_var_mapping(const GoughGraph &g, const string &base,
|
||||
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) {
|
||||
@ -167,6 +168,7 @@ void dump_var_mapping(const GoughGraph &g, const string &base,
|
||||
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) {
|
||||
|
@ -50,8 +50,8 @@ 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) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
out->emplace_back(var.get());
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ void nfaExecGough16_dumpText(const struct NFA *nfa, FILE *f) {
|
||||
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);
|
||||
|
||||
|
@ -279,6 +279,7 @@ char JOIN(ENGINE_EXEC_NAME, _Q_i)(const struct NFA *nfa, struct mq *q,
|
||||
assert(rv == MO_CONTINUE_MATCHING);
|
||||
}
|
||||
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (escape_found) {
|
||||
DEBUG_PRINTF("clearing repeat due to escape\n");
|
||||
clearRepeat(info, lstate);
|
||||
@ -355,6 +356,7 @@ void JOIN(ENGINE_EXEC_NAME, _StreamSilent)(const struct NFA *nfa, struct mq *q,
|
||||
|
||||
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);
|
||||
|
@ -125,6 +125,7 @@ char PROCESS_ACCEPTS_IMPL_FN(const IMPL_NFA_T *limex, const STATE_T *s,
|
||||
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));
|
||||
|
||||
@ -135,6 +136,7 @@ char PROCESS_ACCEPTS_IMPL_FN(const IMPL_NFA_T *limex, const STATE_T *s,
|
||||
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) {
|
||||
@ -358,6 +360,7 @@ char LIMEX_INACCEPT_FN(const IMPL_NFA_T *limex, STATE_T state,
|
||||
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) {
|
||||
|
@ -140,6 +140,7 @@ reindexByStateId(const unordered_map<NFAVertex, NFAStateSet> &in,
|
||||
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;
|
||||
}
|
||||
@ -586,6 +587,7 @@ bool containsBadSubset(const limex_accel_info &accel,
|
||||
subset = state_set;
|
||||
subset.reset(j);
|
||||
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (effective_sds != NO_STATE && subset.count() == 1 &&
|
||||
subset.test(effective_sds)) {
|
||||
continue;
|
||||
@ -1088,6 +1090,7 @@ void buildAccepts(const build_info &args, ReportListCache &reports_cache,
|
||||
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;
|
||||
}
|
||||
@ -1147,6 +1150,7 @@ u32 compressedStateSize(const NGHolder &h, const NFAStateSet &maskedStates,
|
||||
|
||||
for (auto v : vertices_range(h)) {
|
||||
u32 i = state_ids.at(v);
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (i == NO_STATE || maskedStates.test(i)) {
|
||||
continue;
|
||||
}
|
||||
@ -1172,6 +1176,7 @@ bool hasSquashableInitDs(const build_info &args) {
|
||||
|
||||
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;
|
||||
@ -1232,6 +1237,7 @@ void findMaskedCompressionStates(const build_info &args,
|
||||
// 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");
|
||||
@ -1247,6 +1253,7 @@ void findMaskedCompressionStates(const build_info &args,
|
||||
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;
|
||||
}
|
||||
@ -1254,6 +1261,7 @@ void findMaskedCompressionStates(const build_info &args,
|
||||
// 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;
|
||||
}
|
||||
@ -1404,6 +1412,7 @@ u32 buildExceptionMap(const build_info &args, ReportListCache &reports_cache,
|
||||
for (auto v : vertices_range(h)) {
|
||||
const u32 i = args.state_ids.at(v);
|
||||
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (i == NO_STATE) {
|
||||
continue;
|
||||
}
|
||||
@ -1487,6 +1496,7 @@ u32 buildExceptionMap(const build_info &args, ReportListCache &reports_cache,
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -1559,6 +1569,7 @@ u32 findMaxVarShift(const build_info &args, u32 nShifts) {
|
||||
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;
|
||||
}
|
||||
@ -1588,6 +1599,7 @@ int getLimexScore(const build_info &args, u32 nShifts) {
|
||||
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;
|
||||
}
|
||||
@ -1836,6 +1848,7 @@ struct Factory {
|
||||
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)) {
|
||||
@ -1843,6 +1856,7 @@ struct Factory {
|
||||
}
|
||||
}
|
||||
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (sds_i != NO_STATE) {
|
||||
maskSetBit(limex->init, sds_i);
|
||||
maskSetBit(limex->initDS, sds_i);
|
||||
@ -1878,6 +1892,7 @@ struct Factory {
|
||||
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;
|
||||
}
|
||||
@ -1916,6 +1931,7 @@ struct Factory {
|
||||
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;
|
||||
}
|
||||
@ -2458,6 +2474,7 @@ bool isSane(const NGHolder &h, const map<u32, set<NFAVertex>> &tops,
|
||||
return false;
|
||||
}
|
||||
const u32 i = state_ids.at(v);
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (i == NO_STATE) {
|
||||
continue;
|
||||
}
|
||||
@ -2538,6 +2555,7 @@ bool isFast(const build_info &args) {
|
||||
continue;
|
||||
}
|
||||
u32 j = args.state_ids.at(w);
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (j == NO_STATE) {
|
||||
continue;
|
||||
}
|
||||
|
@ -322,6 +322,7 @@ int PE_FN(STATE_ARG, ESTATE_ARG, UNUSED u32 diffmask, STATE_T *succ,
|
||||
#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);
|
||||
|
@ -210,6 +210,7 @@ set<ReportID> all_reports(const raw_dfa &rdfa) {
|
||||
}
|
||||
|
||||
bool has_eod_accepts(const raw_dfa &rdfa) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &ds : rdfa.states) {
|
||||
if (!ds.reports_eod.empty()) {
|
||||
return true;
|
||||
@ -219,6 +220,7 @@ bool has_eod_accepts(const raw_dfa &rdfa) {
|
||||
}
|
||||
|
||||
bool has_non_eod_accepts(const raw_dfa &rdfa) {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const auto &ds : rdfa.states) {
|
||||
if (!ds.reports.empty()) {
|
||||
return true;
|
||||
|
@ -360,7 +360,7 @@ void dumpCommonHeader(FILE *f, const mcclellan *m) {
|
||||
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
|
||||
|
@ -530,7 +530,7 @@ void dumpCommonHeader(FILE *f, const mcsheng *m) {
|
||||
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);
|
||||
}
|
||||
@ -655,7 +655,7 @@ void dumpCommonHeader64(FILE *f, const mcsheng64 *m) {
|
||||
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);
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ void writeSentinel(mpv_puffette *out) {
|
||||
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;
|
||||
@ -313,6 +314,7 @@ static
|
||||
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;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ template<NFAEngineType t>
|
||||
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) {
|
||||
|
@ -137,13 +137,13 @@ void dumpTextReverse(const struct NFA *nfa, FILE *f) {
|
||||
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
|
||||
|
@ -44,6 +44,7 @@ void raw_dfa::stripExtraEodReports(void) {
|
||||
}
|
||||
|
||||
bool raw_dfa::hasEodReports(void) const {
|
||||
// cppcheck-suppress useStlAlgorithm
|
||||
for (const dstate &ds : states) {
|
||||
if (!ds.reports_eod.empty()) {
|
||||
return true;
|
||||
|
@ -76,7 +76,7 @@ struct raw_dfa {
|
||||
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();
|
||||
|
@ -232,6 +232,7 @@ public:
|
||||
|
||||
// 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;
|
||||
@ -247,6 +248,7 @@ public:
|
||||
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;
|
||||
|
@ -101,7 +101,7 @@ void dumpHeader(FILE *f, const sheng *s) {
|
||||
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),
|
||||
@ -116,7 +116,7 @@ void dumpHeader32(FILE *f, const sheng32 *s) {
|
||||
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),
|
||||
@ -131,7 +131,7 @@ void dumpHeader64(FILE *f, const sheng64 *s) {
|
||||
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),
|
||||
@ -182,9 +182,9 @@ void dumpMasks(FILE *f, const sheng *s) {
|
||||
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");
|
||||
@ -202,9 +202,9 @@ void dumpMasks32(FILE *f, const sheng32 *s) {
|
||||
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");
|
||||
@ -222,9 +222,9 @@ void dumpMasks64(FILE *f, const sheng64 *s) {
|
||||
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");
|
||||
@ -358,7 +358,7 @@ void dumpDotPreambleDfa(FILE *f) {
|
||||
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 <>
|
||||
|
@ -299,7 +299,7 @@ char nfaExecTamarama_QR(const struct NFA *n, struct mq *q, ReportID report) {
|
||||
rv = nfaQueueExecRose(q1.nfa, &q1, report);
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("exec rose rv:%u\n", rv);
|
||||
DEBUG_PRINTF("exec rose rv:%d\n", rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ buildTamarama(const TamaInfo &tamaInfo, const u32 queue,
|
||||
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);
|
||||
|
@ -220,6 +220,7 @@ bool inIsIrreducible(const NFAVertex &v, const NGHolder &g) {
|
||||
* 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)) {
|
||||
@ -244,11 +245,13 @@ bool isIrreducible(const NGHolder &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;
|
||||
|
@ -114,6 +114,7 @@ public:
|
||||
|
||||
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.
|
||||
|
@ -106,6 +106,7 @@ bool sanityCheckGraph(const NGHolder &g,
|
||||
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;
|
||||
@ -392,8 +393,8 @@ void reusePredsAsStarts(const NGHolder &g, const map<u32, CharReach> &top_reach,
|
||||
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)) {
|
||||
|
@ -463,6 +463,7 @@ void blowoutPathsLessStrictSegment(vector<vector<CharReach> > &paths) {
|
||||
/* 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) {
|
||||
|
@ -360,8 +360,8 @@ u64a litUniqueness(const string &s) {
|
||||
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;
|
||||
@ -491,8 +491,8 @@ vector<LitEdge> add_reverse_edges_and_index(LitGraph &lg) {
|
||||
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);
|
||||
|
||||
@ -881,6 +881,7 @@ bool literalIsWholeGraph(const NGHolder &g, const ue2_literal &lit) {
|
||||
}
|
||||
|
||||
// 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");
|
||||
|
@ -131,6 +131,7 @@ bool findPaths(const NGHolder &g, vector<Path> &paths) {
|
||||
|
||||
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;
|
||||
|
@ -129,6 +129,7 @@ void calculateAlphabet(const NGHolder &g, array<u16, ALPHABET_SIZE> &alpha,
|
||||
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;
|
||||
@ -327,6 +328,7 @@ void markToppableStarts(const NGHolder &g, const flat_set<NFAVertex> &unused,
|
||||
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);
|
||||
|
@ -482,6 +482,7 @@ vector<CharReach> reduced_cr(const NGHolder &g,
|
||||
|
||||
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;
|
||||
|
@ -115,6 +115,7 @@ bool isRegionEntry(const Graph &g, NFAVertex v,
|
||||
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;
|
||||
@ -128,6 +129,7 @@ bool isRegionEntry(const Graph &g, NFAVertex v,
|
||||
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;
|
||||
|
@ -2181,6 +2181,7 @@ bool hasOverlappingRepeats(UNUSED const NGHolder &g,
|
||||
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);
|
||||
|
@ -210,7 +210,6 @@ u32 countStates(const unordered_map<NFAVertex, u32> &state_ids) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -776,12 +776,14 @@ bool allMatchStatesHaveReports(const NGHolder &g) {
|
||||
|
||||
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;
|
||||
|
@ -164,7 +164,7 @@ ComponentSequence *enterSequence(ComponentSequence *parent,
|
||||
|
||||
ComponentSequence *seq = child.get();
|
||||
parent->addComponent(std::move(child));
|
||||
return seq;
|
||||
return seq; // cppcheck-suppress returnDanglingLifetime
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -99,7 +99,8 @@ public:
|
||||
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. */
|
||||
|
@ -108,6 +108,8 @@ const char *read_control_verbs(const char *ptr, const char *end, size_t start,
|
||||
try {
|
||||
%% write exec;
|
||||
} catch (LocatedParseError &error) {
|
||||
// cppcheck-suppress pointerLessThanZero
|
||||
// cppcheck-suppress pointerPositive
|
||||
if (ts >= ptr && ts <= pe) {
|
||||
error.locate(ts - ptr + start);
|
||||
} else {
|
||||
|
@ -37,6 +37,7 @@ namespace ue2 {
|
||||
/** 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 {
|
||||
|
@ -347,6 +347,7 @@ void prefilterTree(unique_ptr<Component> &root, const ParseMode &mode) {
|
||||
assert(root);
|
||||
PrefilterVisitor vis(root.get(), mode);
|
||||
|
||||
// cppcheck-suppress constVariablePointer
|
||||
Component *c = root->accept(vis);
|
||||
if (c != root.get()) {
|
||||
root.reset(c);
|
||||
|
@ -1496,6 +1496,7 @@ void transformSuffixDelay(RoseInGraph &ig, const CompileContext &cc) {
|
||||
#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;
|
||||
@ -1934,10 +1935,9 @@ bool RoseBuildImpl::addAnchoredAcyclic(const NGHolder &h) {
|
||||
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;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ bool expandFmlCandidates(const CharReach &cr, vector<ue2_literal> &curr,
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -2457,6 +2457,7 @@ bool hasEodAnchors(const RoseBuildImpl &build, const build_context &bc,
|
||||
}
|
||||
|
||||
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");
|
||||
@ -2975,8 +2976,8 @@ void buildFragmentPrograms(const RoseBuildImpl &build,
|
||||
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);
|
||||
|
@ -1325,10 +1325,8 @@ void rehomeAnchoredLiteral(RoseBuildImpl &tbi, const simple_anchored_info &sai,
|
||||
/* 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 */
|
||||
@ -1632,6 +1630,7 @@ void addAnchoredSmallBlockLiterals(RoseBuildImpl &tbi) {
|
||||
#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",
|
||||
@ -1648,7 +1647,7 @@ bool historiesAreValid(const RoseGraph &g) {
|
||||
* 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);
|
||||
@ -1659,6 +1658,7 @@ bool danglingVertexRef(RoseBuildImpl &tbi) {
|
||||
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",
|
||||
@ -1677,6 +1677,7 @@ bool danglingVertexRef(RoseBuildImpl &tbi) {
|
||||
|
||||
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);
|
||||
|
@ -1421,6 +1421,7 @@ void dumpProgram(ofstream &os, const RoseEngine *t, const char *pc) {
|
||||
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,
|
||||
@ -1868,6 +1869,7 @@ void dumpComponentInfoCsv(const RoseEngine *t, const string &base) {
|
||||
}
|
||||
}
|
||||
|
||||
// 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,
|
||||
|
@ -140,6 +140,7 @@ static
|
||||
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) {
|
||||
|
@ -1027,6 +1027,7 @@ bool hasOrphanedTops(const RoseBuildImpl &build) {
|
||||
}
|
||||
|
||||
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(),
|
||||
@ -1036,6 +1037,7 @@ bool hasOrphanedTops(const RoseBuildImpl &build) {
|
||||
}
|
||||
|
||||
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(),
|
||||
|
@ -737,8 +737,8 @@ void pruneReportIfUnused(const RoseBuildImpl &build, shared_ptr<NGHolder> h,
|
||||
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;
|
||||
|
@ -65,7 +65,7 @@ u32 findMinWidth(const RoseBuildImpl &tbi, enum rose_literal_table table) {
|
||||
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);
|
||||
@ -189,7 +189,7 @@ u32 findMaxBAWidth(const RoseBuildImpl &tbi, enum rose_literal_table table) {
|
||||
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)));
|
||||
};
|
||||
|
@ -82,6 +82,7 @@ void dumpSomSlotManager(const SomSlotManager &ssm, const Grey &grey) {
|
||||
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);
|
||||
}
|
||||
|
@ -270,22 +270,26 @@ static really_inline m128 andnot128(m128 a, m128 b) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -430,12 +434,14 @@ m128 sub_u8_m128(m128 a, m128 b) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -255,22 +255,26 @@ static really_inline m128 andnot128(m128 a, m128 b) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,6 @@ public:
|
||||
|
||||
static depth unreachable() {
|
||||
depth d;
|
||||
d.val = val_unreachable;
|
||||
return d;
|
||||
}
|
||||
|
||||
@ -179,7 +178,7 @@ public:
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@ -202,7 +201,7 @@ public:
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -227,8 +227,6 @@ void describeClass(ostream &os, const CharReach &incr, size_t maxLength,
|
||||
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() << ']';
|
||||
|
@ -62,6 +62,7 @@ private:
|
||||
|
||||
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)
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
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;
|
||||
@ -238,7 +238,7 @@ public:
|
||||
: 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;
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
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)
|
||||
|
@ -228,6 +228,7 @@ public:
|
||||
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);
|
||||
|
@ -537,14 +537,14 @@ really_inline SuperVector<16> SuperVector<16>::Ones_vshl(uint8_t const N)
|
||||
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 <>
|
||||
|
@ -41,16 +41,16 @@
|
||||
#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)
|
||||
@ -58,7 +58,7 @@
|
||||
#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))
|
||||
@ -68,31 +68,35 @@
|
||||
#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)
|
||||
|
@ -55,7 +55,7 @@ struct CompileCHStats {
|
||||
class EngineCHContext : public EngineContext{
|
||||
public:
|
||||
explicit EngineCHContext(const ch_database_t *db);
|
||||
~EngineCHContext();
|
||||
virtual ~EngineCHContext() override;
|
||||
|
||||
ch_scratch_t *scratch = nullptr;
|
||||
};
|
||||
@ -64,7 +64,7 @@ public:
|
||||
class EngineChimera : public Engine {
|
||||
public:
|
||||
explicit EngineChimera(ch_database_t *db, CompileCHStats cs);
|
||||
~EngineChimera();
|
||||
virtual ~EngineChimera() override;
|
||||
|
||||
std::unique_ptr<EngineContext> makeContext() const override;
|
||||
|
||||
|
@ -56,7 +56,7 @@ struct CompileHSStats {
|
||||
class EngineHSContext : public EngineContext {
|
||||
public:
|
||||
explicit EngineHSContext(const hs_database_t *db);
|
||||
~EngineHSContext();
|
||||
virtual ~EngineHSContext() override;
|
||||
|
||||
hs_scratch_t *scratch = nullptr;
|
||||
};
|
||||
@ -64,7 +64,7 @@ public:
|
||||
/** 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;
|
||||
};
|
||||
@ -73,7 +73,7 @@ public:
|
||||
class EngineHyperscan : public Engine {
|
||||
public:
|
||||
explicit EngineHyperscan(hs_database_t *db, CompileHSStats cs);
|
||||
~EngineHyperscan();
|
||||
virtual ~EngineHyperscan() override;
|
||||
|
||||
std::unique_ptr<EngineContext> makeContext() const override;
|
||||
|
||||
|
@ -54,7 +54,7 @@ struct CompilePCREStats {
|
||||
class EnginePCREContext : public EngineContext{
|
||||
public:
|
||||
explicit EnginePCREContext(int capture_cnt);
|
||||
~EnginePCREContext();
|
||||
virtual ~EnginePCREContext() override;
|
||||
|
||||
int *ovec = nullptr;
|
||||
};
|
||||
@ -72,7 +72,7 @@ class EnginePCRE : public Engine {
|
||||
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;
|
||||
|
||||
|
@ -759,11 +759,9 @@ void displayResults(const vector<unique_ptr<ThreadContext>> &threads,
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -816,11 +814,9 @@ void displayCsvResults(const vector<unique_ptr<ThreadContext>> &threads,
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -871,11 +867,9 @@ void sqlResults(const vector<unique_ptr<ThreadContext>> &threads,
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -963,6 +957,7 @@ void runBenchmark(const Engine &db,
|
||||
|
||||
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);
|
||||
|
@ -143,7 +143,7 @@ void usage(const char *name, const char *error) {
|
||||
}
|
||||
|
||||
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'},
|
||||
@ -294,7 +294,7 @@ void dumpDb(const struct hs_database *out, const Grey &grey) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ void clearDir(const string &path) {
|
||||
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 == "..") {
|
||||
@ -423,7 +423,7 @@ void dumpScratch(const hs_database_t *db, const Grey &grey) {
|
||||
(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);
|
||||
}
|
||||
@ -442,7 +442,7 @@ void dumpInfo(const hs_database_t *db, const Grey &grey) {
|
||||
(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);
|
||||
}
|
||||
@ -482,7 +482,7 @@ unsigned int dumpDataMulti(const vector<const char *> &patterns,
|
||||
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;
|
||||
|
@ -192,6 +192,7 @@ void *count_malloc(size_t n) {
|
||||
*(reinterpret_cast<size_t *>(pp)) = n;
|
||||
void *p = static_cast<char *>(pp) + 16;
|
||||
|
||||
// cppcheck-suppress memleak
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -218,6 +219,7 @@ void *count_malloc_b(size_t n) {
|
||||
*(reinterpret_cast<size_t *>(pp)) = n;
|
||||
void *p = static_cast<char *>(pp) + 32;
|
||||
|
||||
// cppcheck-suppress memleak
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,6 @@ TEST(ng_charreach, assignment) {
|
||||
cr2 = cr;
|
||||
|
||||
ASSERT_EQ(cr.count(), cr2.count());
|
||||
ASSERT_TRUE(cr == cr2);
|
||||
}
|
||||
|
||||
TEST(ng_charreach, flip) {
|
||||
|
@ -138,7 +138,7 @@ vector<u32> getValidFdrEngines() {
|
||||
|
||||
|
||||
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) {
|
||||
@ -151,7 +151,7 @@ bytecode_ptr<FDR> buildFDREngineHinted(std::vector<hwlmLiteral> &lits,
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -133,7 +133,7 @@ static vector<u32> getValidFdrEngines() {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -370,31 +370,24 @@ TEST(flat_map, get_allocator) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -340,31 +340,24 @@ TEST(flat_set, iter_interop) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -55,11 +55,11 @@ public:
|
||||
}
|
||||
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:
|
||||
|
@ -94,11 +94,11 @@ public:
|
||||
}
|
||||
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:
|
||||
@ -116,11 +116,11 @@ public:
|
||||
}
|
||||
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:
|
||||
|
@ -66,6 +66,7 @@ ostream& operator<<(ostream &os, const RepeatInfo &info) {
|
||||
|
||||
class RepeatTest : public TestWithParam<RepeatTestInfo> {
|
||||
protected:
|
||||
RepeatTest() = default;
|
||||
virtual void SetUp() {
|
||||
test_info = GetParam();
|
||||
|
||||
@ -94,12 +95,12 @@ protected:
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
@ -728,6 +729,7 @@ void test_sparse3entryExpire(const RepeatInfo *info, RepeatControl *ctrl,
|
||||
|
||||
class SparseOptimalTest : public TestWithParam<tuple<u32, RepeatTestInfo> > {
|
||||
protected:
|
||||
SparseOptimalTest() = default;
|
||||
virtual void SetUp() {
|
||||
u32 period;
|
||||
tie(period, test_info) = GetParam();
|
||||
@ -773,13 +775,13 @@ protected:
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -223,7 +223,7 @@ class CorpusGeneratorImpl : public CorpusGenerator {
|
||||
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;
|
||||
|
||||
@ -419,7 +419,7 @@ class CorpusGeneratorUtf8 : public CorpusGenerator {
|
||||
public:
|
||||
CorpusGeneratorUtf8(const NGHolder &graph_in, const ExpressionInfo &expr_in,
|
||||
CorpusProperties &props);
|
||||
~CorpusGeneratorUtf8() = default;
|
||||
virtual ~CorpusGeneratorUtf8() override = default;
|
||||
|
||||
void generateCorpus(vector<string> &data) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user