mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-16 17:31:51 +03:00
noExplicitConstructor
This commit is contained in:
@@ -384,7 +384,10 @@ void resolveEdges(ReportManager &rm, NGHolder &g, const ExpressionInfo &expr,
|
||||
/* there may already be a different edge from start to eod if so
|
||||
* we need to make it unconditional and alive
|
||||
*/
|
||||
if (NFAEdge start_eod = edge(u, g.acceptEod, g)) {
|
||||
NFAEdge start_eod;
|
||||
bool exists;
|
||||
std::tie(start_eod, exists) = edge(u, g.acceptEod, g);
|
||||
if (exists) {
|
||||
g[start_eod].assert_flags = 0;
|
||||
dead->erase(start_eod);
|
||||
} else {
|
||||
@@ -437,7 +440,10 @@ void resolveEdges(ReportManager &rm, NGHolder &g, const ExpressionInfo &expr,
|
||||
/* there may already be a different edge from start to eod if so
|
||||
* we need to make it unconditional and alive
|
||||
*/
|
||||
if (NFAEdge start_eod = edge(u, g.acceptEod, g)) {
|
||||
NFAEdge start_eod;
|
||||
bool exists;
|
||||
std::tie(start_eod, exists) = edge(u, g.acceptEod, g);
|
||||
if (exists) {
|
||||
g[start_eod].assert_flags = 0;
|
||||
dead->erase(start_eod);
|
||||
} else {
|
||||
@@ -496,7 +502,8 @@ void ensureCodePointStart(ReportManager &rm, NGHolder &g,
|
||||
* boundaries. Assert resolution handles the badness coming from asserts.
|
||||
* The only other source of trouble is startDs->accept connections.
|
||||
*/
|
||||
NFAEdge orig = edge(g.startDs, g.accept, g);
|
||||
NFAEdge orig;
|
||||
std::tie(orig, std::ignore) = edge(g.startDs, g.accept, g);
|
||||
if (expr.utf8 && orig) {
|
||||
DEBUG_PRINTF("rectifying %u\n", expr.report);
|
||||
Report ir = rm.getBasicInternalReport(expr);
|
||||
|
||||
@@ -98,9 +98,9 @@ class ClassInfo {
|
||||
public:
|
||||
struct ClassDepth {
|
||||
ClassDepth() {}
|
||||
ClassDepth(const NFAVertexDepth &d)
|
||||
explicit ClassDepth(const NFAVertexDepth &d)
|
||||
: d1(d.fromStart), d2(d.fromStartDotStar) {}
|
||||
ClassDepth(const NFAVertexRevDepth &rd)
|
||||
explicit ClassDepth(const NFAVertexRevDepth &rd)
|
||||
: d1(rd.toAccept), d2(rd.toAcceptEod) {}
|
||||
DepthMinMax d1;
|
||||
DepthMinMax d2;
|
||||
@@ -337,9 +337,9 @@ vector<VertexInfoSet> partitionGraph(vector<unique_ptr<VertexInfo>> &infos,
|
||||
ClassInfo::ClassDepth depth;
|
||||
|
||||
if (eq == LEFT_EQUIVALENCE) {
|
||||
depth = depths[vi->vert_index];
|
||||
depth = ClassInfo::ClassDepth(depths[vi->vert_index]);
|
||||
} else {
|
||||
depth = rdepths[vi->vert_index];
|
||||
depth = ClassInfo::ClassDepth(rdepths[vi->vert_index]);
|
||||
}
|
||||
ClassInfo ci(g, *vi, depth, eq);
|
||||
|
||||
@@ -547,8 +547,8 @@ void mergeClass(vector<unique_ptr<VertexInfo>> &infos, NGHolder &g,
|
||||
pred_info->succ.erase(old_vertex_info);
|
||||
|
||||
// if edge doesn't exist, create it
|
||||
NFAEdge e = add_edge_if_not_present(pred_info->v, new_v, g);
|
||||
|
||||
NFAEdge e;
|
||||
std::tie(e, std::ignore) = add_edge_if_not_present(pred_info->v, new_v, g);
|
||||
// put edge tops, if applicable
|
||||
if (!edgetops.empty()) {
|
||||
assert(g[e].tops.empty() || g[e].tops == edgetops);
|
||||
@@ -558,7 +558,8 @@ void mergeClass(vector<unique_ptr<VertexInfo>> &infos, NGHolder &g,
|
||||
pred_info->succ.insert(new_vertex_info);
|
||||
|
||||
if (new_v_eod) {
|
||||
NFAEdge ee = add_edge_if_not_present(pred_info->v, new_v_eod,
|
||||
NFAEdge ee;
|
||||
std::tie(ee, std::ignore) = add_edge_if_not_present(pred_info->v, new_v_eod,
|
||||
g);
|
||||
|
||||
// put edge tops, if applicable
|
||||
|
||||
@@ -594,7 +594,8 @@ private:
|
||||
// find which accepts source vertex connects to
|
||||
flat_set<NFAVertex> targets;
|
||||
for (const auto &accept : accepts) {
|
||||
NFAEdge e = edge(src, accept, g);
|
||||
NFAEdge e;
|
||||
std::tie(e, std::ignore) = edge(src, accept, g);
|
||||
if (e) {
|
||||
targets.insert(accept);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ bytecode_ptr<NFA> buildLbrDot(const CharReach &cr, const depth &repeatMin,
|
||||
const depth &repeatMax, u32 minPeriod,
|
||||
bool is_reset, ReportID report) {
|
||||
if (!cr.all()) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
enum RepeatType rtype = chooseRepeatType(repeatMin, repeatMax, minPeriod,
|
||||
@@ -176,7 +176,7 @@ bytecode_ptr<NFA> buildLbrVerm(const CharReach &cr, const depth &repeatMin,
|
||||
const CharReach escapes(~cr);
|
||||
|
||||
if (escapes.count() != 1) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
enum RepeatType rtype = chooseRepeatType(repeatMin, repeatMax, minPeriod,
|
||||
@@ -199,7 +199,7 @@ bytecode_ptr<NFA> buildLbrNVerm(const CharReach &cr, const depth &repeatMin,
|
||||
const CharReach escapes(cr);
|
||||
|
||||
if (escapes.count() != 1) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
enum RepeatType rtype = chooseRepeatType(repeatMin, repeatMax, minPeriod,
|
||||
@@ -228,7 +228,7 @@ bytecode_ptr<NFA> buildLbrShuf(const CharReach &cr, const depth &repeatMin,
|
||||
minPeriod, rtype);
|
||||
|
||||
if (shuftiBuildMasks(~cr, (u8 *)&ls->mask_lo, (u8 *)&ls->mask_hi) == -1) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("built shuf lbr\n");
|
||||
@@ -296,7 +296,7 @@ bytecode_ptr<NFA> constructLBR(const CharReach &cr, const depth &repeatMin,
|
||||
|
||||
if (!nfa) {
|
||||
assert(0);
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
return nfa;
|
||||
@@ -307,11 +307,11 @@ bytecode_ptr<NFA> constructLBR(const CastleProto &proto,
|
||||
const CompileContext &cc,
|
||||
const ReportManager &rm) {
|
||||
if (!cc.grey.allowLbr) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
if (proto.repeats.size() != 1) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
const PureRepeat &repeat = proto.repeats.begin()->second;
|
||||
@@ -319,7 +319,7 @@ bytecode_ptr<NFA> constructLBR(const CastleProto &proto,
|
||||
|
||||
if (repeat.reports.size() != 1) {
|
||||
DEBUG_PRINTF("too many reports\n");
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
bool is_reset;
|
||||
@@ -346,16 +346,16 @@ bytecode_ptr<NFA> constructLBR(const NGHolder &g,
|
||||
const CompileContext &cc,
|
||||
const ReportManager &rm) {
|
||||
if (!cc.grey.allowLbr) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
PureRepeat repeat;
|
||||
if (!isPureRepeat(g, repeat)) {
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
if (repeat.reports.size() != 1) {
|
||||
DEBUG_PRINTF("too many reports\n");
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
CastleProto proto(g.kind, repeat);
|
||||
|
||||
@@ -652,7 +652,7 @@ constructNFA(const NGHolder &h_in, const ReportManager *rm,
|
||||
u32 numStates = countStates(state_ids);
|
||||
if (numStates > NFA_MAX_STATES) {
|
||||
DEBUG_PRINTF("Can't build an NFA with %u states\n", numStates);
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
map<NFAVertex, BoundedRepeatSummary> br_cyclic;
|
||||
@@ -722,14 +722,14 @@ bytecode_ptr<NFA> constructReversedNFA_i(const NGHolder &h_in, u32 hint,
|
||||
assert(h.kind == NFA_REV_PREFIX); /* triggered, raises internal callbacks */
|
||||
|
||||
// Do state numbering.
|
||||
auto state_ids = numberStates(h, {});
|
||||
auto state_ids = numberStates(h, flat_set<graph_detail::vertex_descriptor<ue2_graph<NGHolder, NFAGraphVertexProps, NFAGraphEdgeProps>>>());
|
||||
|
||||
// Quick exit: if we've got an embarrassment of riches, i.e. more states
|
||||
// than we can implement in our largest NFA model, bail here.
|
||||
u32 numStates = countStates(state_ids);
|
||||
if (numStates > NFA_MAX_STATES) {
|
||||
DEBUG_PRINTF("Can't build an NFA with %u states\n", numStates);
|
||||
return nullptr;
|
||||
return bytecode_ptr<NFA>(nullptr);
|
||||
}
|
||||
|
||||
assert(sanityCheckGraph(h, state_ids));
|
||||
|
||||
@@ -70,7 +70,7 @@ bool bad_mixed_sensitivity(const ue2_literal &s);
|
||||
* Score all the edges in the given graph, returning them in \p scores indexed
|
||||
* by edge_index. */
|
||||
std::vector<u64a> scoreEdges(const NGHolder &h,
|
||||
const flat_set<NFAEdge> &known_bad = {});
|
||||
const flat_set<NFAEdge> &known_bad = flat_set<NFAEdge>());
|
||||
|
||||
/** Returns a score for a literal set. Lower scores are better. */
|
||||
u64a scoreSet(const std::set<ue2_literal> &s);
|
||||
|
||||
@@ -93,7 +93,8 @@ void addReverseEdges(NGHolder &g, vector<NFAEdge> &reverseEdge,
|
||||
if (it == allEdges.end()) {
|
||||
// No reverse edge, add one.
|
||||
NFAVertex u = source(fwd, g), v = target(fwd, g);
|
||||
NFAEdge rev = add_edge(v, u, g);
|
||||
NFAEdge rev;
|
||||
std::tie(rev, std::ignore) = add_edge(v, u, g);
|
||||
it = allEdges.insert(make_pair(make_pair(vidx, uidx), rev)).first;
|
||||
// Add to capacity map.
|
||||
u32 revIndex = g[rev].index;
|
||||
|
||||
@@ -307,7 +307,9 @@ void markForRemoval(const NFAVertex v, VertexInfoMap &infoMap,
|
||||
|
||||
static
|
||||
bool hasInEdgeTops(const NGHolder &g, NFAVertex v) {
|
||||
NFAEdge e = edge(g.start, v, g);
|
||||
|
||||
NFAEdge e;
|
||||
std::tie(e, std::ignore) = edge(g.start, v, g);
|
||||
return e && !g[e].tops.empty();
|
||||
}
|
||||
|
||||
|
||||
@@ -1135,7 +1135,7 @@ NFAVertex buildTriggerStates(NGHolder &g, const vector<CharReach> &trigger,
|
||||
g[v].char_reach = cr;
|
||||
add_edge(u, v, g);
|
||||
if (u == g.start) {
|
||||
g[edge(u, v, g)].tops.insert(top);
|
||||
g[edge(u, v, g).first].tops.insert(top);
|
||||
}
|
||||
u = v;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ void wireStartToTops(NGHolder &g, const flat_set<NFAVertex> &tops,
|
||||
vector<NFAEdge> &tempEdges) {
|
||||
for (NFAVertex v : tops) {
|
||||
assert(!isLeafNode(v, g));
|
||||
|
||||
const NFAEdge &e = add_edge(g.start, v, g);
|
||||
auto edge_result = add_edge(g.start, v, g);
|
||||
const NFAEdge &e = edge_result.first;
|
||||
tempEdges.emplace_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,8 @@ void splitRHS(const NGHolder &base, const vector<NFAVertex> &pivots,
|
||||
|
||||
for (auto pivot : pivots) {
|
||||
assert(contains(*rhs_map, pivot));
|
||||
NFAEdge e = add_edge(rhs->start, (*rhs_map)[pivot], *rhs);
|
||||
auto edge_result = add_edge(rhs->start, (*rhs_map)[pivot], *rhs);
|
||||
NFAEdge e = edge_result.first;
|
||||
(*rhs)[e].tops.insert(DEFAULT_TOP);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,10 +196,11 @@ u32 commonPrefixLength(const NGHolder &ga, const ranking_info &a_ranking,
|
||||
}
|
||||
|
||||
a_count++;
|
||||
NFAEdge b_edge;
|
||||
bool b_edge_bool;
|
||||
std::tie(b_edge, b_edge_bool) = edge(b_ranking.at(i), b_ranking.at(sid), gb);
|
||||
|
||||
NFAEdge b_edge = edge(b_ranking.at(i), b_ranking.at(sid), gb);
|
||||
|
||||
if (!b_edge) {
|
||||
if (!b_edge_bool) {
|
||||
max = i;
|
||||
DEBUG_PRINTF("lowering max to %u due to edge %zu->%u\n",
|
||||
max, i, sid);
|
||||
@@ -505,16 +506,26 @@ bool mergeableStarts(const NGHolder &h1, const NGHolder &h2) {
|
||||
/* TODO: relax top checks if reports match */
|
||||
|
||||
// If both graphs have edge (start, accept), the tops must match.
|
||||
NFAEdge e1_accept = edge(h1.start, h1.accept, h1);
|
||||
NFAEdge e2_accept = edge(h2.start, h2.accept, h2);
|
||||
if (e1_accept && e2_accept && h1[e1_accept].tops != h2[e2_accept].tops) {
|
||||
bool bool_e1_accept;
|
||||
NFAEdge e1_accept;
|
||||
NFAEdge e2_accept;
|
||||
std::tie(e1_accept, bool_e1_accept) = edge(h1.start, h1.accept, h1);
|
||||
bool bool_e2_accept;
|
||||
std::tie(e2_accept, bool_e2_accept) = edge(h2.start, h2.accept, h2);
|
||||
|
||||
if (bool_e1_accept && bool_e2_accept && h1[e1_accept].tops != h2[e2_accept].tops) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If both graphs have edge (start, acceptEod), the tops must match.
|
||||
NFAEdge e1_eod = edge(h1.start, h1.acceptEod, h1);
|
||||
NFAEdge e2_eod = edge(h2.start, h2.acceptEod, h2);
|
||||
if (e1_eod && e2_eod && h1[e1_eod].tops != h2[e2_eod].tops) {
|
||||
bool bool_e1_eod;
|
||||
NFAEdge e1_eod;
|
||||
NFAEdge e2_eod;
|
||||
std::tie(e1_eod, bool_e1_eod) = edge(h1.start, h1.acceptEod, h1);
|
||||
bool bool_e2_eod;
|
||||
std::tie(e2_eod, bool_e2_eod) = edge(h2.start, h2.acceptEod, h2);
|
||||
|
||||
if (bool_e1_eod && bool_e2_eod && h1[e1_eod].tops != h2[e2_eod].tops) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void clone_out_edges(NGHolder &g, NFAVertex source, NFAVertex dest) {
|
||||
if (edge(dest, t, g).second) {
|
||||
continue;
|
||||
}
|
||||
NFAEdge clone = add_edge(dest, t, g);
|
||||
NFAEdge clone = add_edge(dest, t, g).first;
|
||||
u32 idx = g[clone].index;
|
||||
g[clone] = g[e];
|
||||
g[clone].index = idx;
|
||||
@@ -139,7 +139,7 @@ void clone_in_edges(NGHolder &g, NFAVertex s, NFAVertex dest) {
|
||||
for (const auto &e : in_edges_range(s, g)) {
|
||||
NFAVertex ss = source(e, g);
|
||||
assert(!edge(ss, dest, g).second);
|
||||
NFAEdge clone = add_edge(ss, dest, g);
|
||||
NFAEdge clone = add_edge(ss, dest, g).first;
|
||||
u32 idx = g[clone].index;
|
||||
g[clone] = g[e];
|
||||
g[clone].index = idx;
|
||||
@@ -278,9 +278,11 @@ bool can_only_match_at_eod(const NGHolder &g) {
|
||||
}
|
||||
|
||||
bool matches_everywhere(const NGHolder &h) {
|
||||
NFAEdge e = edge(h.startDs, h.accept, h);
|
||||
bool bool_e;
|
||||
NFAEdge e;
|
||||
std::tie(e, bool_e) = edge(h.startDs, h.accept, h);
|
||||
|
||||
return e && !h[e].assert_flags;
|
||||
return bool_e && !h[e].assert_flags;
|
||||
}
|
||||
|
||||
bool is_virtual_start(NFAVertex v, const NGHolder &g) {
|
||||
@@ -568,7 +570,7 @@ void cloneHolder(NGHolder &out, const NGHolder &in) {
|
||||
|
||||
NFAVertex s = out_mapping[si];
|
||||
NFAVertex t = out_mapping[ti];
|
||||
NFAEdge e2 = add_edge(s, t, out);
|
||||
NFAEdge e2 = add_edge(s, t, out).first;
|
||||
out[e2] = in[e];
|
||||
}
|
||||
|
||||
@@ -718,7 +720,7 @@ u32 removeTrailingLiteralStates(NGHolder &g, const ue2_literal &lit,
|
||||
clearReports(g);
|
||||
|
||||
for (auto v : pred) {
|
||||
NFAEdge e = add_edge(v, g.accept, g);
|
||||
NFAEdge e = add_edge(v, g.accept, g).first;
|
||||
g[v].reports.insert(0);
|
||||
if (is_triggered(g) && v == g.start) {
|
||||
g[e].tops.insert(DEFAULT_TOP);
|
||||
|
||||
@@ -1243,7 +1243,8 @@ void splitEdgesByCut(const NGHolder &h, RoseInGraph &vg,
|
||||
* makes a more svelte graphy */
|
||||
clear_in_edges(temp_map[pivot], *new_lhs);
|
||||
NFAEdge pivot_edge = add_edge(temp_map[prev_v], temp_map[pivot],
|
||||
*new_lhs);
|
||||
*new_lhs).first;
|
||||
|
||||
if (is_triggered(h) && prev_v == h.start) {
|
||||
(*new_lhs)[pivot_edge].tops.insert(DEFAULT_TOP);
|
||||
}
|
||||
@@ -1969,7 +1970,7 @@ void restoreTrailingLiteralStates(NGHolder &g, const ue2_literal &lit,
|
||||
}
|
||||
|
||||
for (auto v : preds) {
|
||||
NFAEdge e = add_edge_if_not_present(v, prev, g);
|
||||
NFAEdge e = add_edge_if_not_present(v, prev, g).first;
|
||||
if (v == g.start && is_triggered(g)) {
|
||||
g[e].tops.insert(DEFAULT_TOP);
|
||||
}
|
||||
@@ -2305,7 +2306,7 @@ void splitEdgesForSuffix(const NGHolder &base_graph, RoseInGraph &vg,
|
||||
add_edge(lhs->accept, lhs->acceptEod, *lhs);
|
||||
clearReports(*lhs);
|
||||
for (NFAVertex v : splitters) {
|
||||
NFAEdge e = add_edge(v_map[v], lhs->accept, *lhs);
|
||||
NFAEdge e = add_edge(v_map[v], lhs->accept, *lhs).first;
|
||||
if (v == base_graph.start) {
|
||||
(*lhs)[e].tops.insert(DEFAULT_TOP);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user