mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2026-01-05 07:55:27 +03:00
Merge branch 'develop' into wip-cppcheck271-part2
This commit is contained in:
@@ -106,25 +106,27 @@ void writeCastleScanEngine(const CharReach &cr, Castle *c) {
|
||||
#ifdef HAVE_SVE2
|
||||
if (cr.count() <= 16) {
|
||||
c->type = CASTLE_NVERM16;
|
||||
vermicelli16Build(cr, (u8 *)&c->u.verm16.mask);
|
||||
vermicelli16Build(cr, reinterpret_cast<u8 *>(&c->u.verm16.mask));
|
||||
return;
|
||||
}
|
||||
if (negated.count() <= 16) {
|
||||
c->type = CASTLE_VERM16;
|
||||
vermicelli16Build(negated, (u8 *)&c->u.verm16.mask);
|
||||
vermicelli16Build(negated, reinterpret_cast<u8 *>(&c->u.verm16.mask));
|
||||
return;
|
||||
}
|
||||
#endif // HAVE_SVE2
|
||||
|
||||
if (shuftiBuildMasks(negated, (u8 *)&c->u.shuf.mask_lo,
|
||||
(u8 *)&c->u.shuf.mask_hi) != -1) {
|
||||
if (shuftiBuildMasks(negated,
|
||||
reinterpret_cast<u8 *>(&c->u.shuf.mask_lo),
|
||||
reinterpret_cast<u8 *>(&c->u.shuf.mask_hi)) != -1) {
|
||||
c->type = CASTLE_SHUFTI;
|
||||
return;
|
||||
}
|
||||
|
||||
c->type = CASTLE_TRUFFLE;
|
||||
truffleBuildMasks(negated, (u8 *)(u8 *)&c->u.truffle.mask1,
|
||||
(u8 *)&c->u.truffle.mask2);
|
||||
truffleBuildMasks(negated,
|
||||
reinterpret_cast<u8 *>(&c->u.truffle.mask1),
|
||||
reinterpret_cast<u8 *>(&c->u.truffle.mask2));
|
||||
}
|
||||
|
||||
static
|
||||
@@ -227,11 +229,13 @@ vector<u32> removeClique(CliqueGraph &cg) {
|
||||
while (!graph_empty(cg)) {
|
||||
const vector<u32> &c = cliquesVec.back();
|
||||
vector<CliqueVertex> dead;
|
||||
for (const auto &v : vertices_range(cg)) {
|
||||
if (find(c.begin(), c.end(), cg[v].stateId) != c.end()) {
|
||||
dead.emplace_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
auto deads = [&c=c, &cg=cg](const CliqueVertex &v) {
|
||||
return (find(c.begin(), c.end(), cg[v].stateId) != c.end());
|
||||
};
|
||||
const auto &vr = vertices_range(cg);
|
||||
std::copy_if(begin(vr), end(vr), std::back_inserter(dead), deads);
|
||||
|
||||
for (const auto &v : dead) {
|
||||
clear_vertex(v, cg);
|
||||
remove_vertex(v, cg);
|
||||
@@ -294,7 +298,7 @@ vector<vector<u32>> checkExclusion(u32 &streamStateSize,
|
||||
size_t lower = 0;
|
||||
size_t total = 0;
|
||||
while (lower < trigSize) {
|
||||
vector<CliqueVertex> vertices;
|
||||
vector<CliqueVertex> clvertices;
|
||||
unique_ptr<CliqueGraph> cg = make_unique<CliqueGraph>();
|
||||
|
||||
vector<vector<size_t>> min_reset_dist;
|
||||
@@ -302,7 +306,7 @@ vector<vector<u32>> checkExclusion(u32 &streamStateSize,
|
||||
// get min reset distance for each repeat
|
||||
for (size_t i = lower; i < upper; i++) {
|
||||
CliqueVertex v = add_vertex(CliqueVertexProps(i), *cg);
|
||||
vertices.emplace_back(v);
|
||||
clvertices.emplace_back(v);
|
||||
|
||||
const vector<size_t> &tmp_dist =
|
||||
minResetDistToEnd(triggers[i], cr);
|
||||
@@ -311,11 +315,11 @@ vector<vector<u32>> checkExclusion(u32 &streamStateSize,
|
||||
|
||||
// find exclusive pair for each repeat
|
||||
for (size_t i = lower; i < upper; i++) {
|
||||
CliqueVertex s = vertices[i - lower];
|
||||
CliqueVertex s = clvertices[i - lower];
|
||||
for (size_t j = i + 1; j < upper; j++) {
|
||||
if (findExclusivePair(i, j, lower, min_reset_dist,
|
||||
triggers)) {
|
||||
CliqueVertex d = vertices[j - lower];
|
||||
CliqueVertex d = clvertices[j - lower];
|
||||
add_edge(s, d, *cg);
|
||||
}
|
||||
}
|
||||
@@ -600,9 +604,9 @@ buildCastle(const CastleProto &proto,
|
||||
nfa->minWidth = verify_u32(minWidth);
|
||||
nfa->maxWidth = maxWidth.is_finite() ? verify_u32(maxWidth) : 0;
|
||||
|
||||
char * const base_ptr = (char *)nfa.get() + sizeof(NFA);
|
||||
char * const base_ptr = reinterpret_cast<char *>(nfa.get()) + sizeof(NFA);
|
||||
char *ptr = base_ptr;
|
||||
Castle *c = (Castle *)ptr;
|
||||
Castle *c = reinterpret_cast<Castle *>(ptr);
|
||||
c->numRepeats = verify_u32(subs.size());
|
||||
c->numGroups = exclusiveInfo.numGroups;
|
||||
c->exclusive = verify_s8(exclusive);
|
||||
@@ -613,7 +617,7 @@ buildCastle(const CastleProto &proto,
|
||||
writeCastleScanEngine(cr, c);
|
||||
|
||||
ptr += sizeof(Castle);
|
||||
SubCastle *subCastles = ((SubCastle *)(ROUNDUP_PTR(ptr, alignof(u32))));
|
||||
SubCastle *subCastles = reinterpret_cast<SubCastle *>(ROUNDUP_PTR(ptr, alignof(u32)));
|
||||
copy(subs.begin(), subs.end(), subCastles);
|
||||
|
||||
u32 length = 0;
|
||||
@@ -623,16 +627,16 @@ buildCastle(const CastleProto &proto,
|
||||
SubCastle *sub = &subCastles[i];
|
||||
sub->repeatInfoOffset = offset;
|
||||
|
||||
ptr = (char *)sub + offset;
|
||||
ptr = reinterpret_cast<char *>(sub) + offset;
|
||||
memcpy(ptr, &infos[i], sizeof(RepeatInfo));
|
||||
|
||||
if (patchSize[i]) {
|
||||
RepeatInfo *info = (RepeatInfo *)ptr;
|
||||
u64a *table = ((u64a *)(ROUNDUP_PTR(((char *)(info) +
|
||||
sizeof(*info)), alignof(u64a))));
|
||||
RepeatInfo *info = reinterpret_cast<RepeatInfo *>(ptr);
|
||||
u64a *table = reinterpret_cast<u64a *>(ROUNDUP_PTR(info +
|
||||
sizeof(*info), alignof(u64a)));
|
||||
copy(tables.begin() + tableIdx,
|
||||
tables.begin() + tableIdx + patchSize[i], table);
|
||||
u32 diff = (char *)table - (char *)info +
|
||||
u32 diff = reinterpret_cast<ptrdiff_t>(table) - reinterpret_cast<ptrdiff_t>(info) +
|
||||
sizeof(u64a) * patchSize[i];
|
||||
info->length = diff;
|
||||
length += diff;
|
||||
@@ -655,7 +659,6 @@ buildCastle(const CastleProto &proto,
|
||||
if (!stale_iter.empty()) {
|
||||
c->staleIterOffset = verify_u32(ptr - base_ptr);
|
||||
copy_bytes(ptr, stale_iter);
|
||||
ptr += byte_length(stale_iter);
|
||||
}
|
||||
|
||||
return nfa;
|
||||
@@ -922,7 +925,7 @@ void addToHolder(NGHolder &g, u32 top, const PureRepeat &pr) {
|
||||
u32 min_bound = pr.bounds.min; // always finite
|
||||
if (min_bound == 0) { // Vacuous case, we can only do this once.
|
||||
assert(!edge(g.start, g.accept, g).second);
|
||||
NFAEdge e = add_edge(g.start, g.accept, g);
|
||||
NFAEdge e = add_edge(g.start, g.accept, g).first;
|
||||
g[e].tops.insert(top);
|
||||
g[u].reports.insert(pr.reports.begin(), pr.reports.end());
|
||||
min_bound = 1;
|
||||
@@ -931,7 +934,7 @@ void addToHolder(NGHolder &g, u32 top, const PureRepeat &pr) {
|
||||
for (u32 i = 0; i < min_bound; i++) {
|
||||
NFAVertex v = add_vertex(g);
|
||||
g[v].char_reach = pr.reach;
|
||||
NFAEdge e = add_edge(u, v, g);
|
||||
NFAEdge e = add_edge(u, v, g).first;
|
||||
if (u == g.start) {
|
||||
g[e].tops.insert(top);
|
||||
}
|
||||
@@ -950,7 +953,7 @@ void addToHolder(NGHolder &g, u32 top, const PureRepeat &pr) {
|
||||
if (head != u) {
|
||||
add_edge(head, v, g);
|
||||
}
|
||||
NFAEdge e = add_edge(u, v, g);
|
||||
NFAEdge e = add_edge(u, v, g).first;
|
||||
if (u == g.start) {
|
||||
g[e].tops.insert(top);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user