mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Merge pull request #263 from gtsoul-tech/bug/cppcheck-61
Cppcheck knownConditionTrueFalse error
This commit is contained in:
commit
692a63c8ca
@ -48,6 +48,7 @@ hs_error_t HS_CDECL hs_valid_platform(void) {
|
|||||||
return HS_ARCH_ERROR;
|
return HS_ARCH_ERROR;
|
||||||
}
|
}
|
||||||
#elif !defined(VS_SIMDE_BACKEND) && (defined(ARCH_ARM32) || defined(ARCH_AARCH64))
|
#elif !defined(VS_SIMDE_BACKEND) && (defined(ARCH_ARM32) || defined(ARCH_AARCH64))
|
||||||
|
//check_neon returns true for now
|
||||||
if (check_neon()) {
|
if (check_neon()) {
|
||||||
return HS_SUCCESS;
|
return HS_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1481,6 +1481,7 @@ u32 buildExceptionMap(const build_info &args, ReportListCache &reports_cache,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
u32 j = args.state_ids.at(w);
|
u32 j = args.state_ids.at(w);
|
||||||
|
// j can be NO_STATE if args.state_ids.at(w) returns NO_STATE
|
||||||
if (j == NO_STATE) {
|
if (j == NO_STATE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -785,7 +785,7 @@ enum RepeatMatch repeatHasMatchRange(const struct RepeatInfo *info,
|
|||||||
if (diff > info->repeatMax) {
|
if (diff > info->repeatMax) {
|
||||||
DEBUG_PRINTF("range list is stale\n");
|
DEBUG_PRINTF("range list is stale\n");
|
||||||
return REPEAT_STALE;
|
return REPEAT_STALE;
|
||||||
} else if (diff >= info->repeatMin && diff <= info->repeatMax) {
|
} else if (diff >= info->repeatMin) {
|
||||||
return REPEAT_MATCH;
|
return REPEAT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +836,7 @@ enum RepeatMatch repeatHasMatchBitmap(const struct RepeatInfo *info,
|
|||||||
if (diff > info->repeatMax) {
|
if (diff > info->repeatMax) {
|
||||||
DEBUG_PRINTF("stale\n");
|
DEBUG_PRINTF("stale\n");
|
||||||
return REPEAT_STALE;
|
return REPEAT_STALE;
|
||||||
} else if (diff >= info->repeatMin && diff <= info->repeatMax) {
|
} else if (diff >= info->repeatMin) {
|
||||||
return REPEAT_MATCH;
|
return REPEAT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1495,7 +1495,7 @@ void findExclusiveInfixes(RoseBuildImpl &build, build_context &bc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
void buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||||
QueueIndexFactory &qif, set<u32> *no_retrigger_queues,
|
QueueIndexFactory &qif, set<u32> *no_retrigger_queues,
|
||||||
set<u32> *eager_queues, bool do_prefix) {
|
set<u32> *eager_queues, bool do_prefix) {
|
||||||
RoseGraph &g = tbi.g;
|
RoseGraph &g = tbi.g;
|
||||||
@ -1581,7 +1581,7 @@ bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
|||||||
leftfix);
|
leftfix);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -2059,16 +2059,8 @@ bool buildNfas(RoseBuildImpl &tbi, build_context &bc, QueueIndexFactory &qif,
|
|||||||
suffixTriggers.clear();
|
suffixTriggers.clear();
|
||||||
|
|
||||||
*leftfixBeginQueue = qif.allocated_count();
|
*leftfixBeginQueue = qif.allocated_count();
|
||||||
|
buildLeftfixes(tbi, bc, qif, no_retrigger_queues, eager_queues,true);
|
||||||
if (!buildLeftfixes(tbi, bc, qif, no_retrigger_queues, eager_queues,
|
buildLeftfixes(tbi, bc, qif, no_retrigger_queues, eager_queues,false);
|
||||||
true)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!buildLeftfixes(tbi, bc, qif, no_retrigger_queues, eager_queues,
|
|
||||||
false)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1687,7 +1687,7 @@ void replaceTops(NGHolder &h, const map<u32, u32> &top_mapping) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool setDistinctTops(NGHolder &h1, const NGHolder &h2,
|
void setDistinctTops(NGHolder &h1, const NGHolder &h2,
|
||||||
map<u32, u32> &top_mapping) {
|
map<u32, u32> &top_mapping) {
|
||||||
flat_set<u32> tops1 = getTops(h1), tops2 = getTops(h2);
|
flat_set<u32> tops1 = getTops(h1), tops2 = getTops(h2);
|
||||||
|
|
||||||
@ -1697,7 +1697,7 @@ bool setDistinctTops(NGHolder &h1, const NGHolder &h2,
|
|||||||
// If our tops don't intersect, we're OK to merge with no changes.
|
// If our tops don't intersect, we're OK to merge with no changes.
|
||||||
if (!has_intersection(tops1, tops2)) {
|
if (!has_intersection(tops1, tops2)) {
|
||||||
DEBUG_PRINTF("tops don't intersect\n");
|
DEBUG_PRINTF("tops don't intersect\n");
|
||||||
return true;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we have to renumber the tops in h1 so that they don't overlap
|
// Otherwise, we have to renumber the tops in h1 so that they don't overlap
|
||||||
@ -1712,18 +1712,17 @@ bool setDistinctTops(NGHolder &h1, const NGHolder &h2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
replaceTops(h1, top_mapping);
|
replaceTops(h1, top_mapping);
|
||||||
return true;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
void setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
||||||
const deque<RoseVertex> &verts1) {
|
const deque<RoseVertex> &verts1) {
|
||||||
map<u32, u32> top_mapping;
|
map<u32, u32> top_mapping;
|
||||||
if (!setDistinctTops(h1, h2, top_mapping)) {
|
|
||||||
return false;
|
setDistinctTops(h1, h2, top_mapping);
|
||||||
}
|
|
||||||
|
|
||||||
if (top_mapping.empty()) {
|
if (top_mapping.empty()) {
|
||||||
return true; // No remapping necessary.
|
return ; // No remapping necessary.
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto v : verts1) {
|
for (auto v : verts1) {
|
||||||
@ -1741,19 +1740,17 @@ bool setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool setDistinctSuffixTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
void setDistinctSuffixTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
||||||
const deque<RoseVertex> &verts1) {
|
const deque<RoseVertex> &verts1) {
|
||||||
map<u32, u32> top_mapping;
|
map<u32, u32> top_mapping;
|
||||||
if (!setDistinctTops(h1, h2, top_mapping)) {
|
setDistinctTops(h1, h2, top_mapping);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (top_mapping.empty()) {
|
if (top_mapping.empty()) {
|
||||||
return true; // No remapping necessary.
|
return ; // No remapping necessary.
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto v : verts1) {
|
for (auto v : verts1) {
|
||||||
@ -1763,7 +1760,7 @@ bool setDistinctSuffixTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
|||||||
g[v].suffix.top = top_mapping[t];
|
g[v].suffix.top = top_mapping[t];
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Estimate the number of accel states in the given graph when built as
|
/** \brief Estimate the number of accel states in the given graph when built as
|
||||||
@ -1837,10 +1834,7 @@ void mergeNfaLeftfixes(RoseBuildImpl &tbi, LeftfixBouquet &roses) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!setDistinctRoseTops(g, victim, *r1.graph(), verts2)) {
|
setDistinctRoseTops(g, victim, *r1.graph(), verts2);
|
||||||
DEBUG_PRINTF("can't set distinct tops\n");
|
|
||||||
continue; // next h2
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(victim.kind == r1.graph()->kind);
|
assert(victim.kind == r1.graph()->kind);
|
||||||
assert(!generates_callbacks(*r1.graph()));
|
assert(!generates_callbacks(*r1.graph()));
|
||||||
@ -2120,10 +2114,7 @@ void mergeSuffixes(RoseBuildImpl &tbi, SuffixBouquet &suffixes,
|
|||||||
old_tops[v] = g[v].suffix.top;
|
old_tops[v] = g[v].suffix.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!setDistinctSuffixTops(g, victim, *s1.graph(), verts2)) {
|
setDistinctSuffixTops(g, victim, *s1.graph(), verts2);
|
||||||
DEBUG_PRINTF("can't set distinct tops\n");
|
|
||||||
continue; // next h2
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mergeNfaPair(victim, *s1.graph(), &tbi.rm, tbi.cc)) {
|
if (!mergeNfaPair(victim, *s1.graph(), &tbi.rm, tbi.cc)) {
|
||||||
DEBUG_PRINTF("merge failed\n");
|
DEBUG_PRINTF("merge failed\n");
|
||||||
|
@ -62,7 +62,7 @@ bool mergeableRoseVertices(const RoseBuildImpl &tbi, RoseVertex u,
|
|||||||
bool mergeableRoseVertices(const RoseBuildImpl &tbi,
|
bool mergeableRoseVertices(const RoseBuildImpl &tbi,
|
||||||
const std::set<RoseVertex> &v1,
|
const std::set<RoseVertex> &v1,
|
||||||
const std::set<RoseVertex> &v2);
|
const std::set<RoseVertex> &v2);
|
||||||
bool setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
void setDistinctRoseTops(RoseGraph &g, NGHolder &h1, const NGHolder &h2,
|
||||||
const std::deque<RoseVertex> &verts1);
|
const std::deque<RoseVertex> &verts1);
|
||||||
|
|
||||||
} // namespace ue2
|
} // namespace ue2
|
||||||
|
@ -1294,12 +1294,7 @@ bool attemptRoseGraphMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a,
|
|||||||
|
|
||||||
DEBUG_PRINTF("victim %zu states\n", num_vertices(*a_h));
|
DEBUG_PRINTF("victim %zu states\n", num_vertices(*a_h));
|
||||||
DEBUG_PRINTF("winner %zu states\n", num_vertices(*b_h));
|
DEBUG_PRINTF("winner %zu states\n", num_vertices(*b_h));
|
||||||
|
setDistinctRoseTops(g, victim, *b_h, deque<RoseVertex>(1, a));
|
||||||
if (!setDistinctRoseTops(g, victim, *b_h, deque<RoseVertex>(1, a))) {
|
|
||||||
assert(roseHasTops(build, a));
|
|
||||||
assert(roseHasTops(build, b));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(victim.kind == b_h->kind);
|
assert(victim.kind == b_h->kind);
|
||||||
assert(!generates_callbacks(*b_h));
|
assert(!generates_callbacks(*b_h));
|
||||||
|
@ -154,7 +154,7 @@ TEST_P(FDRFloodp, NoMask) {
|
|||||||
|
|
||||||
struct hs_scratch scratch;
|
struct hs_scratch scratch;
|
||||||
scratch.fdr_conf = NULL;
|
scratch.fdr_conf = NULL;
|
||||||
while (1) {
|
while (c != 255) {
|
||||||
SCOPED_TRACE((unsigned int)c);
|
SCOPED_TRACE((unsigned int)c);
|
||||||
u8 bit = 1 << (c & 0x7);
|
u8 bit = 1 << (c & 0x7);
|
||||||
u8 cAlt = c ^ bit;
|
u8 cAlt = c ^ bit;
|
||||||
@ -233,9 +233,7 @@ TEST_P(FDRFloodp, NoMask) {
|
|||||||
}
|
}
|
||||||
matchesCounts.clear();
|
matchesCounts.clear();
|
||||||
|
|
||||||
if (++c == 0) {
|
++c;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +246,7 @@ TEST_P(FDRFloodp, WithMask) {
|
|||||||
|
|
||||||
struct hs_scratch scratch;
|
struct hs_scratch scratch;
|
||||||
scratch.fdr_conf = NULL;
|
scratch.fdr_conf = NULL;
|
||||||
while (1) {
|
while (c != 255) {
|
||||||
u8 bit = 1 << (c & 0x7);
|
u8 bit = 1 << (c & 0x7);
|
||||||
u8 cAlt = c ^ bit;
|
u8 cAlt = c ^ bit;
|
||||||
SCOPED_TRACE((unsigned int)c);
|
SCOPED_TRACE((unsigned int)c);
|
||||||
@ -396,9 +394,7 @@ TEST_P(FDRFloodp, WithMask) {
|
|||||||
}
|
}
|
||||||
matchesCounts.clear();
|
matchesCounts.clear();
|
||||||
|
|
||||||
if (++c == '\0') {
|
++c;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +410,7 @@ TEST_P(FDRFloodp, StreamingMask) {
|
|||||||
|
|
||||||
struct hs_scratch scratch;
|
struct hs_scratch scratch;
|
||||||
scratch.fdr_conf = NULL;
|
scratch.fdr_conf = NULL;
|
||||||
while (1) {
|
while (c != 255) {
|
||||||
u8 bit = 1 << (c & 0x7);
|
u8 bit = 1 << (c & 0x7);
|
||||||
u8 cAlt = c ^ bit;
|
u8 cAlt = c ^ bit;
|
||||||
SCOPED_TRACE((unsigned int)c);
|
SCOPED_TRACE((unsigned int)c);
|
||||||
@ -548,9 +544,7 @@ TEST_P(FDRFloodp, StreamingMask) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++c == '\0') {
|
++c;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
matchesCounts.clear();
|
matchesCounts.clear();
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,7 @@ std::ostream &operator<<(std::ostream &os, const flat_set<T> &f) {
|
|||||||
os << "{";
|
os << "{";
|
||||||
for (auto it = begin(f); it != end(f); ++it) {
|
for (auto it = begin(f); it != end(f); ++it) {
|
||||||
os << *it;
|
os << *it;
|
||||||
if (it != end(f)) {
|
os << ", ";
|
||||||
os << ", ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
os << "}";
|
os << "}";
|
||||||
return os;
|
return os;
|
||||||
|
@ -149,9 +149,7 @@ std::ostream &operator<<(std::ostream &os, const insertion_ordered_set<K> &s) {
|
|||||||
os << "{";
|
os << "{";
|
||||||
for (auto it = begin(s); it != end(s); ++it) {
|
for (auto it = begin(s); it != end(s); ++it) {
|
||||||
os << *it;
|
os << *it;
|
||||||
if (it != end(s)) {
|
os << ", ";
|
||||||
os << ", ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
os << "}";
|
os << "}";
|
||||||
return os;
|
return os;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user