]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
noExplicitConstructor
authorgtsoul-tech <gtsoulkanakis@gmail.com>
Fri, 10 May 2024 07:07:47 +0000 (10:07 +0300)
committergtsoul-tech <gtsoulkanakis@gmail.com>
Fri, 10 May 2024 07:07:47 +0000 (10:07 +0300)
52 files changed:
examples/patbench.cc
examples/pcapscan.cc
src/compiler/asserts.cpp
src/compiler/compiler.cpp
src/hwlm/hwlm_build.cpp
src/nfa/castlecompile.cpp
src/nfa/goughcompile.cpp
src/nfa/limex_compile.cpp
src/nfa/mcclellancompile.cpp
src/nfa/mcsheng_compile.cpp
src/nfa/rdfa_graph.h
src/nfa/shengcompile.cpp
src/nfagraph/ng_asserts.cpp
src/nfagraph/ng_equivalence.cpp
src/nfagraph/ng_fuzzy.cpp
src/nfagraph/ng_lbr.cpp
src/nfagraph/ng_limex.cpp
src/nfagraph/ng_literal_analysis.h
src/nfagraph/ng_netflow.cpp
src/nfagraph/ng_redundancy.cpp
src/nfagraph/ng_repeat.cpp
src/nfagraph/ng_restructuring.cpp
src/nfagraph/ng_split.cpp
src/nfagraph/ng_uncalc_components.cpp
src/nfagraph/ng_util.cpp
src/nfagraph/ng_violet.cpp
src/rose/rose_build_add.cpp
src/rose/rose_build_add_mask.cpp
src/rose/rose_build_anchored.cpp
src/rose/rose_build_bytecode.cpp
src/rose/rose_build_castle.cpp
src/rose/rose_build_compile.cpp
src/rose/rose_build_convert.cpp
src/rose/rose_build_dedupe.cpp
src/rose/rose_build_groups.cpp
src/rose/rose_build_impl.h
src/rose/rose_build_instructions.h
src/rose/rose_build_lookaround.cpp
src/rose/rose_build_matchers.cpp
src/rose/rose_build_merge.cpp
src/rose/rose_build_program.cpp
src/rose/rose_build_role_aliasing.cpp
src/rose/rose_build_width.cpp
src/smallwrite/smallwrite_build.cpp
src/util/alloc.h
src/util/bitfield.h
src/util/bytecode_ptr.h
src/util/flat_containers.h
src/util/hash_dynamic_bitset.h
src/util/ue2_graph.h
unit/internal/lbr.cpp
util/ng_corpus_editor.cpp

index 6a5ce4777a877f7d18b6ce8e9556e78bfa7cf3d8..d8b836d9456507c0558f9b014f9f6baa1e083eed 100644 (file)
@@ -202,7 +202,7 @@ struct FiveTuple {
     unsigned int dstPort;
 
     // Construct a FiveTuple from a TCP or UDP packet.
-    FiveTuple(const struct ip *iphdr) {
+    explicit FiveTuple(const struct ip *iphdr) {
         // IP fields
         protocol = iphdr->ip_p;
         srcAddr = iphdr->ip_src.s_addr;
@@ -442,7 +442,7 @@ class Sigdata {
 
 public:
     Sigdata() {}
-    Sigdata(const char *filename) {
+    explicit Sigdata(const char *filename) {
         parseFile(filename, patterns, flags, ids, originals);
 
     }
index 1ec98d781eaae72d33023370213dc83d29a8dbbb..5c2c7a9d7cfe7e79ec82d4d8ff852ea526e4a06f 100644 (file)
@@ -99,7 +99,7 @@ struct FiveTuple {
     unsigned int dstPort;
 
     // Construct a FiveTuple from a TCP or UDP packet.
-    FiveTuple(const struct ip *iphdr) {
+    explicit FiveTuple(const struct ip *iphdr) {
         // IP fields
         protocol = iphdr->ip_p;
         srcAddr = iphdr->ip_src.s_addr;
index 51a052b04f4435e897f0518b35c61689c6092ef1..946dfda1bed2e5c6773d3d37325fdf164d39a430 100644 (file)
@@ -176,7 +176,8 @@ void replaceAssertVertex(NGHolder &g, NFAVertex t, const ExpressionInfo &expr,
             auto ecit = edge_cache.find(cache_key);
             if (ecit == edge_cache.end()) {
                 DEBUG_PRINTF("adding edge %zu %zu\n", g[u].index, g[v].index);
-                NFAEdge e = add_edge(u, v, g);
+                NFAEdge e;
+                std::tie(e, std::ignore) = add_edge(u, v, g);
                 edge_cache.emplace(cache_key, e);
                 g[e].assert_flags = flags;
                 if (++assert_edge_count > MAX_ASSERT_EDGES) {
index 35f46b3fea2e7af157e6c46302f764c188136289..c4d74738bd9d453a77aad9342163a9cb710d0158 100644 (file)
@@ -443,7 +443,7 @@ bytecode_ptr<RoseEngine> generateRoseEngine(NG &ng) {
     if (!rose) {
         DEBUG_PRINTF("error building rose\n");
         assert(0);
-        return nullptr;
+        return bytecode_ptr<RoseEngine>(nullptr);
     }
 
     dumpReportManager(ng.rm, ng.cc.grey);
index 7837819ac9181c64132d2251f4e9feb5ff7eef11..73f05921d178b32696e87c7344afacac7e1cf849 100644 (file)
@@ -143,7 +143,7 @@ bytecode_ptr<HWLM> hwlmBuild(const HWLMProto &proto, const CompileContext &cc,
     }
 
     if (!eng) {
-        return nullptr;
+        return bytecode_ptr<HWLM>(nullptr);
     }
 
     assert(engSize);
index bef36451a0a5cc5f4db3e1a6848e187ea3a12bc6..d0602ae053d248082919949d1d34a4582e6be8c1 100644 (file)
@@ -920,7 +920,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;
@@ -929,7 +929,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);
         }
@@ -948,7 +948,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);
             }
index 62cdf72c63477b5e90444d5262926c2d72bf2976..aff921341599269f3fb4e62a818e02e23066393e 100644 (file)
@@ -1050,7 +1050,7 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
            || !cc.streaming);
 
     if (!cc.grey.allowGough) {
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     DEBUG_PRINTF("hello world\n");
@@ -1081,7 +1081,7 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
     auto basic_dfa = mcclellanCompile_i(raw, gbs, cc);
     assert(basic_dfa);
     if (!basic_dfa) {
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     u8 alphaShift
index 5bc2730114f9944739d044c16efa6aff9cfaae31..1b5d3fe2efdf71299c7b48764781606db876aa68 100644 (file)
@@ -555,7 +555,8 @@ void filterAccelStates(NGHolder &g, const map<u32, set<NFAVertex>> &tops,
 
     // Similarly, connect (start, startDs) if necessary.
     if (!edge(g.start, g.startDs, g).second) {
-        NFAEdge e = add_edge(g.start, g.startDs, g);
+        NFAEdge e;
+        std::tie(e, std::ignore) = add_edge(g.start, g.startDs, g);
         tempEdges.emplace_back(e); // Remove edge later.
     }
 
@@ -2219,7 +2220,7 @@ struct Factory {
     static
     bytecode_ptr<NFA> generateNfa(const build_info &args) {
         if (args.num_states > NFATraits<dtype>::maxStates) {
-            return nullptr;
+            return bytecode_ptr<NFA>(nullptr);
         }
 
         // Build bounded repeat structures.
@@ -2578,7 +2579,7 @@ bytecode_ptr<NFA> generate(NGHolder &h,
 
     if (!cc.grey.allowLimExNFA) {
         DEBUG_PRINTF("limex not allowed\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     // If you ask for a particular type, it had better be an NFA.
@@ -2613,7 +2614,7 @@ bytecode_ptr<NFA> generate(NGHolder &h,
 
     if (scores.empty()) {
         DEBUG_PRINTF("No NFA returned a valid score for this case.\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     // Sort acceptable models in priority order, lowest score first.
@@ -2632,7 +2633,7 @@ bytecode_ptr<NFA> generate(NGHolder &h,
     }
 
     DEBUG_PRINTF("NFA build failed.\n");
-    return nullptr;
+    return bytecode_ptr<NFA>(nullptr);
 }
 
 u32 countAccelStates(NGHolder &h,
index d0e305733b9947827de57ba7c34658cba157ebd3..e88c15b564e1e64bf5d2ba019750cd84d9cffcf7 100644 (file)
@@ -625,7 +625,7 @@ bytecode_ptr<NFA> mcclellanCompile16(dfa_info &info, const CompileContext &cc,
     if (!allocateFSN16(info, &count_real_states, &wide_limit)) {
         DEBUG_PRINTF("failed to allocate state numbers, %zu states total\n",
                      info.size());
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     DEBUG_PRINTF("count_real_states: %d\n", count_real_states);
index 81db7024dd36a6a9ebeffc0211f7dc431ab9c8e5..c3675073c7ed8ac01f87d28f7a05a02afd4efd62 100644 (file)
@@ -1035,7 +1035,7 @@ bytecode_ptr<NFA> mcshengCompile16(dfa_info &info, dstate_id_t sheng_end,
     if (!allocateImplId16(info, sheng_end, &sherman_limit)) {
         DEBUG_PRINTF("failed to allocate state numbers, %zu states total\n",
                      info.size());
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
     u16 count_real_states = sherman_limit - sheng_end;
 
@@ -1189,7 +1189,7 @@ bytecode_ptr<NFA> mcsheng64Compile16(dfa_info&info, dstate_id_t sheng_end,
     if (!allocateImplId16(info, sheng_end, &sherman_limit)) {
         DEBUG_PRINTF("failed to allocate state numbers, %zu states total\n",
                      info.size());
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
     u16 count_real_states = sherman_limit - sheng_end;
 
@@ -1414,7 +1414,7 @@ bytecode_ptr<NFA> mcsheng64Compile8(dfa_info &info, dstate_id_t sheng_end,
 bytecode_ptr<NFA> mcshengCompile(raw_dfa &raw, const CompileContext &cc,
                                  const ReportManager &rm) {
     if (!cc.grey.allowMcSheng) {
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     mcclellan_build_strat mbs(raw, rm, false);
@@ -1435,7 +1435,7 @@ bytecode_ptr<NFA> mcshengCompile(raw_dfa &raw, const CompileContext &cc,
 
     if (sheng_end <= DEAD_STATE + 1) {
         info.states = old_states;
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     bytecode_ptr<NFA> nfa;
@@ -1462,12 +1462,12 @@ bytecode_ptr<NFA> mcshengCompile(raw_dfa &raw, const CompileContext &cc,
 bytecode_ptr<NFA> mcshengCompile64(raw_dfa &raw, const CompileContext &cc,
                                    const ReportManager &rm) {
     if (!cc.grey.allowMcSheng) {
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     if (!cc.target_info.has_avx512vbmi()) {
         DEBUG_PRINTF("McSheng64 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     mcclellan_build_strat mbs(raw, rm, false);
@@ -1488,7 +1488,7 @@ bytecode_ptr<NFA> mcshengCompile64(raw_dfa &raw, const CompileContext &cc,
     sheng_end64 = find_sheng_states(info, accel_escape_info, MAX_SHENG64_STATES);
 
     if (sheng_end64 <= DEAD_STATE + 1) {
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     } else {
         using64state = true;
     }
index 6d166c2fb7c563e60f75e6c6740797c998a1ae8b..d042560de3a67d6d857df3d2c5f869607a1c00c2 100644 (file)
@@ -45,7 +45,7 @@ struct RdfaEdgeProps {
 };
 
 struct RdfaGraph : public ue2_graph<RdfaGraph, RdfaVertexProps, RdfaEdgeProps> {
-    RdfaGraph(const raw_dfa &rdfa);
+    explicit RdfaGraph(const raw_dfa &rdfa);
 };
 
 
index ed1860fe42046490bd357169c25c623b926dafe7..c8a6dacaa8925726ea213bb377b3d3b4801219f6 100644 (file)
@@ -690,7 +690,7 @@ bytecode_ptr<NFA> shengCompile_int(raw_dfa &raw, const CompileContext &cc,
     }
 
     if (!createShuffleMasks<T>((T *)getMutableImplNfa(nfa.get()), info, accelInfo)) {
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     return nfa;
@@ -701,7 +701,7 @@ bytecode_ptr<NFA> shengCompile(raw_dfa &raw, const CompileContext &cc,
                                set<dstate_id_t> *accel_states) {
     if (!cc.grey.allowSheng) {
         DEBUG_PRINTF("Sheng is not allowed!\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     sheng_build_strat strat(raw, rm, only_accel_init);
@@ -716,7 +716,7 @@ bytecode_ptr<NFA> shengCompile(raw_dfa &raw, const CompileContext &cc,
                  info.can_die ? "can" : "cannot", info.size());
     if (info.size() > 16) {
         DEBUG_PRINTF("Too many states\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     return shengCompile_int<sheng>(raw, cc, accel_states, strat, info);
@@ -727,18 +727,18 @@ bytecode_ptr<NFA> sheng32Compile(raw_dfa &raw, const CompileContext &cc,
                                  set<dstate_id_t> *accel_states) {
     if (!cc.grey.allowSheng) {
         DEBUG_PRINTF("Sheng is not allowed!\n");
-        return nullptr;
+        bytecode_ptr<NFA>(nullptr);
     }
 
 #ifdef HAVE_SVE
     if (svcntb()<32) {
         DEBUG_PRINTF("Sheng32 failed, SVE width is too small!\n");
-        return nullptr;
+        bytecode_ptr<NFA>(nullptr);
     }
 #else
     if (!cc.target_info.has_avx512vbmi()) {
         DEBUG_PRINTF("Sheng32 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
-        return nullptr;
+        bytecode_ptr<NFA>(nullptr);
     }
 #endif
 
@@ -755,7 +755,7 @@ bytecode_ptr<NFA> sheng32Compile(raw_dfa &raw, const CompileContext &cc,
     assert(info.size() > 16);
     if (info.size() > 32) {
         DEBUG_PRINTF("Too many states\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     return shengCompile_int<sheng32>(raw, cc, accel_states, strat, info);
@@ -766,18 +766,18 @@ bytecode_ptr<NFA> sheng64Compile(raw_dfa &raw, const CompileContext &cc,
                                  set<dstate_id_t> *accel_states) {
     if (!cc.grey.allowSheng) {
         DEBUG_PRINTF("Sheng is not allowed!\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
 #ifdef HAVE_SVE
     if (svcntb()<64) {
         DEBUG_PRINTF("Sheng64 failed, SVE width is too small!\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 #else
     if (!cc.target_info.has_avx512vbmi()) {
         DEBUG_PRINTF("Sheng64 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 #endif
 
@@ -794,7 +794,7 @@ bytecode_ptr<NFA> sheng64Compile(raw_dfa &raw, const CompileContext &cc,
     assert(info.size() > 32);
     if (info.size() > 64) {
         DEBUG_PRINTF("Too many states\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
     vector<dstate> old_states;
     old_states = info.states;
index 764ebed1b964c3f1b2afad369ac625f0d7ecede8..1dfcb95e3e94d4c4b5dc898926451fc71feb7ed7 100644 (file)
@@ -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);
index c45096c5c8a1a0cb80a53048f33d4aed5ac6280f..7c9d0a2c5b6d0fad8ec8fbbcb0357c6f5c5d1cca 100644 (file)
@@ -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
index 20c762880a35d7ea25b533be9380819d6ade1cd3..af41e070586371e011ea48107f8887a03e04a11d 100644 (file)
@@ -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);
                     }
index 039eeb3b4f4c9697202e6cf104c200cf067846a2..a6630a950f99ed747f6b119762d11e167e3cc7ec 100644 (file)
@@ -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);
index 27d8c5244add7ae4bf360caf8aa5716d3c1bd657..41d696758b50b00589e8781850b85f76c5f2007d 100644 (file)
@@ -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));
index 6bb87556102d5225ba1141eb026e9e8f72c57470..b1e20053a80252fe265ef59b96ae587fedb2500f 100644 (file)
@@ -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);
index b48e33c467ee6e88e1ec2bc9e38dab663bd6d1f1..6e65093fb78162904609d3c12d8195cb45fdc534 100644 (file)
@@ -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;
index 90da92f2fd169d0e37f95bc39fb5e6f0d3491ee3..6da9a7fa4c0a0baafe06fc09b79989a3a131905e 100644 (file)
@@ -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();
 }
 
index 71c95fce05f633dae6aa4ad0276a1f04912fd164..c401a24ba25532d3a194f3db4539344b87b94659 100644 (file)
@@ -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;
     }
index 73b4d23e5f6bbbfce034e33d974ab5c42b2e10b5..a05f0f63c7ea5c75eeb29f3dcefa8e023f5faf0f 100644 (file)
@@ -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);
     }
 }
index 91a099fc38abd2f0b39b58bfe937fcaa52b5b2b8..528b72f7ac9ab71c8bd0287aa21fadbb41cfacce 100644 (file)
@@ -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);
     }
 
index fc4ffe1a6fda3f5e6ec4a6463b512210ffe407a8..57744681eb6568d59ae9d42292b23335c98d698a 100644 (file)
@@ -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;
     }
 
index b1d39d2e3a6d5019a7cdba600edb0578fa3ff879..c5525cc7de86aaaf988e269de80523fa2852c1c9 100644 (file)
@@ -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);
index 525d2f1431a7e8ddea7590785ef3954b41f77b48..69c9acd7329760d51eff44e8313176fda3792625 100644 (file)
@@ -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);
         }
index 816acc1604aa564060d2ecd361171c109c326645..b7b2ae999faa2f420bc8161d6d5e975efa3312fe 100644 (file)
@@ -131,7 +131,7 @@ RoseVertex createVertex(RoseBuildImpl *build, const RoseVertex parent,
     /* fill in report information */
     g[v].reports.insert(reports.begin(), reports.end());
 
-    RoseEdge e = add_edge(parent, v, g);
+    RoseEdge e = add_edge(parent, v, g).first;
     DEBUG_PRINTF("adding edge (%u, %u) to parent\n", minBound, maxBound);
 
     g[e].minBound = minBound;
@@ -161,7 +161,7 @@ RoseVertex createAnchoredVertex(RoseBuildImpl *build, u32 literalId,
     DEBUG_PRINTF("created anchored vertex %zu with lit id %u\n", g[v].index,
                  literalId);
 
-    RoseEdge e = add_edge(build->anchored_root, v, g);
+    RoseEdge e = add_edge(build->anchored_root, v, g).first;
     g[e].minBound = min_offset;
     g[e].maxBound = max_offset;
 
@@ -307,7 +307,7 @@ void createVertices(RoseBuildImpl *tbi,
 
         RoseVertex p = pv.first;
 
-        RoseEdge e = add_edge(p, w, g);
+        RoseEdge e = add_edge(p, w, g).first;
         DEBUG_PRINTF("adding edge (%u,%u) to parent\n", edge_props.minBound,
                      edge_props.maxBound);
         g[e].minBound = edge_props.minBound;
@@ -345,7 +345,7 @@ void createVertices(RoseBuildImpl *tbi,
 
         for (const auto &pv : parents) {
             const RoseInEdgeProps &edge_props = bd.ig[pv.second];
-            RoseEdge e = add_edge(pv.first, g_v, tbi->g);
+            RoseEdge e = add_edge(pv.first, g_v, tbi->g).first;
             g[e].minBound = edge_props.minBound;
             g[e].maxBound = edge_props.maxBound;
             g[e].history = selectHistory(*tbi, bd, pv.second, e);
@@ -698,7 +698,7 @@ void makeEodEventLeftfix(RoseBuildImpl &build, RoseVertex u,
         g[v].left.graph = eod_leftfix;
         g[v].left.leftfix_report = report_mapping.second;
         g[v].left.lag = 0;
-        RoseEdge e1 = add_edge(u, v, g);
+        RoseEdge e1 = add_edge(u, v, g).first;
         g[e1].minBound = 0;
         g[e1].maxBound = ROSE_BOUND_INF;
         g[v].min_offset = add_rose_depth(g[u].min_offset,
@@ -718,7 +718,7 @@ void makeEodEventLeftfix(RoseBuildImpl &build, RoseVertex u,
         g[w].reports = report_mapping.first;
         g[w].min_offset = g[v].min_offset;
         g[w].max_offset = g[v].max_offset;
-        RoseEdge e = add_edge(v, w, g);
+        RoseEdge e = add_edge(v, w, g).first;
         g[e].minBound = 0;
         g[e].maxBound = 0;
         /* No need to set history as the event is only delivered at the last
@@ -794,7 +794,7 @@ void doRoseAcceptVertex(RoseBuildImpl *tbi,
                 g[w].reports = ig[iv].reports;
                 g[w].min_offset = g[u].min_offset;
                 g[w].max_offset = g[u].max_offset;
-                RoseEdge e = add_edge(u, w, g);
+                RoseEdge e = add_edge(u, w, g).first;
                 g[e].minBound = 0;
                 g[e].maxBound = 0;
                 g[e].history = ROSE_ROLE_HISTORY_LAST_BYTE;
@@ -1719,7 +1719,7 @@ bool addEodOutfix(RoseBuildImpl &build, const NGHolder &h) {
         g[v].left.graph = eod_leftfix;
         g[v].left.leftfix_report = report_mapping.second;
         g[v].left.lag = 0;
-        RoseEdge e1 = add_edge(build.anchored_root, v, g);
+        RoseEdge e1 = add_edge(build.anchored_root, v, g).first;
         g[e1].minBound = 0;
         g[e1].maxBound = ROSE_BOUND_INF;
         g[v].min_offset = findMinWidth(*eod_leftfix);
@@ -1737,7 +1737,7 @@ bool addEodOutfix(RoseBuildImpl &build, const NGHolder &h) {
         g[w].reports = report_mapping.first;
         g[w].min_offset = g[v].min_offset;
         g[w].max_offset = g[v].max_offset;
-        RoseEdge e = add_edge(v, w, g);
+        RoseEdge e = add_edge(v, w, g).first;
         g[e].minBound = 0;
         g[e].maxBound = 0;
         g[e].history = ROSE_ROLE_HISTORY_NONE;
index 6c84c40a897b8f69d91104c19f43a4a644ba8fe5..d764b6daf8e6f28dff273a55635442ca595f4f1b 100644 (file)
@@ -540,7 +540,7 @@ void addTransientMask(RoseBuildImpl &build, const vector<CharReach> &mask,
             g[v].left.leftfix_report = mask_report;
         } else {
             // Make sure our edge bounds are correct.
-            RoseEdge e = edge(parent, v, g);
+            RoseEdge e = edge(parent, v, g).first;
             g[e].minBound = 0;
             g[e].maxBound = anchored ? 0 : ROSE_BOUND_INF;
             g[e].history = anchored ? ROSE_ROLE_HISTORY_ANCH
@@ -552,7 +552,7 @@ void addTransientMask(RoseBuildImpl &build, const vector<CharReach> &mask,
         g[v].max_offset = v_max_offset;
 
         if (eod) {
-            RoseEdge e = add_edge(v, eod_v, g);
+            RoseEdge e = add_edge(v, eod_v, g).first;
             g[e].minBound = 0;
             g[e].maxBound = 0;
             g[e].history = ROSE_ROLE_HISTORY_LAST_BYTE;
@@ -582,7 +582,7 @@ unique_ptr<NGHolder> buildMaskRhs(const flat_set<ReportID> &reports,
         succ = u;
     }
 
-    NFAEdge e = add_edge(h.start, succ, h);
+    NFAEdge e = add_edge(h.start, succ, h).first;
     h[e].tops.insert(DEFAULT_TOP);
 
     return rhs;
index 027aefd0b8cdf6701d57d01e9d884d9692c32a34..303a8ec9c5a1d0a8d4d70faf57b61b925622281c 100644 (file)
@@ -873,7 +873,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
 
     if (dfas.empty()) {
         DEBUG_PRINTF("empty\n");
-        return nullptr;
+        return bytecode_ptr<anchored_matcher_info>(nullptr);
     }
 
     for (auto &rdfa : dfas) {
index 06b257dd601a8836849cf8fb460271851dd9d00f..d2ef6f087ba9724d6157bc8f079c3dc33eb2c633 100644 (file)
@@ -1054,7 +1054,7 @@ left_id updateLeftfixWithEager(RoseGraph &g, const eager_info &ei,
         DEBUG_PRINTF("added %u literal chars back, new lag %u\n", lag_adjust,
                      g[v].left.lag);
     }
-    left_id leftfix = g[succs[0]].left;
+    left_id leftfix = left_id(left_id(g[succs[0]].left));
 
     if (leftfix.graph()) {
         assert(leftfix.graph()->kind == NFA_PREFIX
@@ -1593,7 +1593,7 @@ void findSuffixTriggers(const RoseBuildImpl &tbi,
             continue;
         }
         PredTopPair ptp(v, g[v].suffix.top);
-        (*suffixTriggers)[g[v].suffix].insert(ptp);
+        (*suffixTriggers)[suffix_id(g[v].suffix)].insert(ptp);
     }
 }
 
@@ -1613,7 +1613,7 @@ public:
     explicit OutfixBuilder(const RoseBuildImpl &build_in) : build(build_in) {}
 
     bytecode_ptr<NFA> operator()(boost::blank&) const {
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     };
 
     bytecode_ptr<NFA> operator()(unique_ptr<raw_dfa> &rdfa) const {
@@ -1660,7 +1660,7 @@ public:
     bytecode_ptr<NFA> operator()(UNUSED const MpvProto &mpv) const {
         // MPV construction handled separately.
         assert(mpv.puffettes.empty());
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
 private:
@@ -2304,12 +2304,12 @@ bool anyEndfixMpvTriggers(const RoseBuildImpl &build) {
         if (!g[v].suffix) {
             continue;
         }
-        if (contains(done, g[v].suffix)) {
+        if (contains(done, suffix_id(g[v].suffix))) {
             continue; /* already done */
         }
-        done.insert(g[v].suffix);
+        done.insert(suffix_id(g[v].suffix));
 
-        if (hasMpvTrigger(all_reports(g[v].suffix), build.rm)) {
+        if (hasMpvTrigger(all_reports(suffix_id(g[v].suffix)), build.rm)) {
             return true;
         }
     }
@@ -2369,7 +2369,7 @@ void recordResources(RoseResources &resources, const RoseBuildImpl &build,
             resources.has_eod = true;
             break;
         }
-        if (g[v].suffix && has_eod_accepts(g[v].suffix)) {
+        if (g[v].suffix && has_eod_accepts(suffix_id(g[v].suffix))) {
             resources.has_eod = true;
             break;
         }
@@ -2454,7 +2454,7 @@ bool hasEodAnchors(const RoseBuildImpl &build, const build_context &bc,
             DEBUG_PRINTF("literally report eod\n");
             return true;
         }
-        if (g[v].suffix && has_eod_accepts(g[v].suffix)) {
+        if (g[v].suffix && has_eod_accepts(suffix_id(g[v].suffix))) {
             DEBUG_PRINTF("eod suffix\n");
             return true;
         }
@@ -2529,7 +2529,7 @@ void writeNfaInfo(const RoseBuildImpl &build, build_context &bc,
         if (!g[v].suffix) {
             continue;
         }
-        u32 qi = bc.suffixes.at(g[v].suffix);
+        u32 qi = bc.suffixes.at(suffix_id(g[v].suffix));
         assert(qi < infos.size());
         if (build.isInETable(v)) {
             infos.at(qi).eod = 1;
@@ -3185,7 +3185,7 @@ set<ReportID> findEngineReports(const RoseBuildImpl &build) {
     const auto &g = build.g;
     for (auto v : vertices_range(g)) {
         if (g[v].suffix) {
-            insert(&reports, all_reports(g[v].suffix));
+            insert(&reports, all_reports(suffix_id(g[v].suffix)));
         }
     }
 
@@ -3641,7 +3641,7 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     prepMpv(*this, bc, &historyRequired, &mpv_as_outfix);
     proto.outfixBeginQueue = qif.allocated_count();
     if (!prepOutfixes(*this, bc, &historyRequired)) {
-        return nullptr;
+        return bytecode_ptr<RoseEngine>(nullptr);
     }
     proto.outfixEndQueue = qif.allocated_count();
     proto.leftfixBeginQueue = proto.outfixEndQueue;
@@ -3652,7 +3652,7 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     /* Note: buildNfas may reduce the lag for vertices that have prefixes */
     if (!buildNfas(*this, bc, qif, &no_retrigger_queues, &eager_queues,
                    &proto.leftfixBeginQueue)) {
-        return nullptr;
+        return bytecode_ptr<RoseEngine>(nullptr);
     }
     u32 eodNfaIterOffset = buildEodNfaIterator(bc, proto.leftfixBeginQueue);
     buildCountingMiracles(bc);
index 990f0c55cfffc35b61ddd982f9924b2086e7217b..6fcb319c0413df7650d4e8fad5dee288a8ae473b 100644 (file)
@@ -252,11 +252,11 @@ bool unmakeCastles(RoseBuildImpl &tbi) {
     for (auto v : vertices_range(g)) {
         const LeftEngInfo &left = g[v].left;
         if (left.castle && left.castle->repeats.size() > 1) {
-            left_castles[left].emplace_back(v);
+            left_castles[left_id(left)].emplace_back(v);
         }
         const RoseSuffixInfo &suffix = g[v].suffix;
         if (suffix.castle && suffix.castle->repeats.size() > 1) {
-            suffix_castles[suffix].emplace_back(v);
+            suffix_castles[suffix_id(suffix)].emplace_back(v);
         }
     }
 
index e67c9149a33aa4780e3617fed7035a797d44f20e..bddc13a42c2bfaad50b3347c82520dd1085b14fa 100644 (file)
@@ -811,7 +811,7 @@ void RoseBuildImpl::findTransientLeftfixes(void) {
             continue;
         }
 
-        const left_id &left(g[v].left);
+        const left_id &left(left_id(g[v].left));
 
         if (::ue2::isAnchored(left) && !isInETable(v)) {
             /* etable prefixes currently MUST be transient as we do not know
@@ -863,7 +863,7 @@ map<left_id, vector<RoseVertex>> findLeftSucc(const RoseBuildImpl &build) {
     for (auto v : vertices_range(build.g)) {
         if (build.g[v].left) {
             const LeftEngInfo &lei = build.g[v].left;
-            leftfixes[lei].emplace_back(v);
+            leftfixes[left_id(lei)].emplace_back(v);
         }
     }
     return leftfixes;
@@ -1250,7 +1250,7 @@ void buildRoseSquashMasks(RoseBuildImpl &tbi) {
             if (!info.delayed_ids.empty()
                 || !all_of_in(info.vertices,
                               [&](RoseVertex v) {
-                                  return left == tbi.g[v].left; })) {
+                                  return left == left_id(tbi.g[v].left); })) {
                 DEBUG_PRINTF("group %llu is unsquashable\n", info.group_mask);
                 unsquashable |= info.group_mask;
             }
@@ -1393,7 +1393,7 @@ void addSmallBlockLiteral(RoseBuildImpl &tbi, const simple_anchored_info &sai,
             g[v].max_offset = sai.max_bound + sai.literal.length();
             lit_info.vertices.insert(v);
 
-            RoseEdge e = add_edge(anchored_root, v, g);
+            RoseEdge e = add_edge(anchored_root, v, g).first;
             g[e].minBound = sai.min_bound;
             g[e].maxBound = sai.max_bound;
         }
@@ -1417,7 +1417,7 @@ void addSmallBlockLiteral(RoseBuildImpl &tbi, const ue2_literal &lit,
     g[v].literals.insert(lit_id);
     g[v].reports = reports;
 
-    RoseEdge e = add_edge(tbi.root, v, g);
+    RoseEdge e = add_edge(tbi.root, v, g).first;
     g[e].minBound = 0;
     g[e].maxBound = ROSE_BOUND_INF;
     g[v].min_offset = 1;
index c89c6ddd2e03bafa1cab3107aec831f527998cc8..36c41e01aef5401ec52a86366db1b243968beac9 100644 (file)
@@ -99,7 +99,7 @@ unique_ptr<NGHolder> makeFloodProneSuffix(const ue2_literal &s, size_t len,
     NFAVertex u = h->start;
     for (auto it = s.begin() + s.length() - len; it != s.end(); ++it) {
         NFAVertex v = addHolderVertex(*it, *h);
-        NFAEdge e = add_edge(u, v, *h);
+        NFAEdge e = add_edge(u, v, *h).first;
         if (u == h->start) {
             (*h)[e].tops.insert(DEFAULT_TOP);
         }
@@ -410,7 +410,7 @@ bool handleStartPrefixCliche(const NGHolder &h, RoseGraph &g, RoseVertex v,
         assert(g[e_old].maxBound >= bound_max);
         setEdgeBounds(g, e_old, bound_min, bound_max);
     } else {
-        RoseEdge e_new = add_edge(ar, v, g);
+        RoseEdge e_new = add_edge(ar, v, g).first;
         setEdgeBounds(g, e_new, bound_min, bound_max);
         to_delete->emplace_back(e_old);
     }
@@ -606,7 +606,7 @@ bool handleMixedPrefixCliche(const NGHolder &h, RoseGraph &g, RoseVertex v,
         if (source(e_old, g) == ar) {
             setEdgeBounds(g, e_old, ri.repeatMin + width, ri.repeatMax + width);
         } else {
-            RoseEdge e_new = add_edge(ar, v, g);
+            RoseEdge e_new = add_edge(ar, v, g).first;
             setEdgeBounds(g, e_new, ri.repeatMin + width, ri.repeatMax + width);
             to_delete->emplace_back(e_old);
         }
index 0a19480a472e4d21c34666118273cf11ae6d6e86..c7cc78ba92e8eb8996abe77da4bd777788c3b87f 100644 (file)
@@ -129,7 +129,7 @@ RoseDedupeAuxImpl::RoseDedupeAuxImpl(const RoseBuildImpl &build_in)
         // Several vertices may share a suffix, so we collect the set of
         // suffixes first to avoid repeating work.
         if (g[v].suffix) {
-            suffixes.insert(g[v].suffix);
+            suffixes.insert(suffix_id(g[v].suffix));
         }
     }
 
index 94fab54fabb4bd6bd5995684223e00f73a85cb33..a3b5edd8634e7302ecd1ee9eaba5b34fbf08fc18 100644 (file)
@@ -77,7 +77,7 @@ static
 bool eligibleForAlwaysOnGroup(const RoseBuildImpl &build, u32 id) {
     auto eligble = [&](RoseVertex v) {
         return build.isRootSuccessor(v)
-        && (!build.g[v].left || !isAnchored(build.g[v].left));
+        && (!build.g[v].left || !isAnchored(left_id(build.g[v].left)));
     };
 
     if (any_of_in(build.literal_info[id].vertices, eligble)) {
@@ -208,7 +208,7 @@ void allocateGroupForEvent(RoseBuildImpl &build, u32 group_always_on,
 
     bool new_group = !groupCount[group_always_on];
     for (RoseVertex v : info.vertices) {
-        if (build.g[v].left && !isAnchored(build.g[v].left)) {
+        if (build.g[v].left && !isAnchored(left_id(build.g[v].left))) {
             new_group = false;
         }
     }
index d0ed84dfa2cf061b6e22e51a2c7f8b84349379ec..3aa530fbdf47f8af701aa6c9eb1deae455c49758 100644 (file)
@@ -80,7 +80,7 @@ class SmallWriteBuild;
 class SomSlotManager;
 
 struct suffix_id {
-    suffix_id(const RoseSuffixInfo &in)
+    explicit suffix_id(const RoseSuffixInfo &in)
         : g(in.graph.get()), c(in.castle.get()), d(in.rdfa.get()),
           h(in.haig.get()), t(in.tamarama.get()),
           dfa_min_width(in.dfa_min_width),
@@ -181,7 +181,7 @@ depth findMaxWidth(const suffix_id &s, u32 top);
 
 /** \brief represents an engine to the left of a rose role */
 struct left_id {
-    left_id(const LeftEngInfo &in)
+    explicit left_id(const LeftEngInfo &in)
         : g(in.graph.get()), c(in.castle.get()), d(in.dfa.get()),
           h(in.haig.get()), dfa_min_width(in.dfa_min_width),
           dfa_max_width(in.dfa_max_width) {
index f18f4a47152c2495ea93088ddb87bede7f360b43..01ff8d8849ccd23b4da0ce210835efad9ed14ea1 100644 (file)
@@ -2319,7 +2319,7 @@ class RoseInstrSetCombination
 public:
     u32 ckey;
 
-    RoseInstrSetCombination(u32 ckey_in) : ckey(ckey_in) {}
+    explicit RoseInstrSetCombination(u32 ckey_in) : ckey(ckey_in) {}
 
     bool operator==(const RoseInstrSetCombination &ri) const {
         return ckey == ri.ckey;
@@ -2361,7 +2361,7 @@ class RoseInstrSetExhaust
 public:
     u32 ekey;
 
-    RoseInstrSetExhaust(u32 ekey_in) : ekey(ekey_in) {}
+    explicit RoseInstrSetExhaust(u32 ekey_in) : ekey(ekey_in) {}
 
     bool operator==(const RoseInstrSetExhaust &ri) const {
         return ekey == ri.ekey;
index 88e8d4748c8606ce0fc21dbfa423fdaa26ea9683..c9dfdc6157182fae83c62fff47bb412051016b73 100644 (file)
@@ -280,13 +280,13 @@ void findForwardReach(const RoseGraph &g, const RoseVertex v,
             return;
         }
         rose_look.emplace_back(map<s32, CharReach>());
-        getRoseForwardReach(g[t].left, g[e].rose_top, rose_look.back());
+        getRoseForwardReach(left_id(g[t].left), g[e].rose_top, rose_look.back());
     }
 
     if (g[v].suffix) {
         DEBUG_PRINTF("suffix engine\n");
         rose_look.emplace_back(map<s32, CharReach>());
-        getSuffixForwardReach(g[v].suffix, g[v].suffix.top, rose_look.back());
+        getSuffixForwardReach(suffix_id(g[v].suffix), g[v].suffix.top, rose_look.back());
     }
 
     combineForwardMasks(rose_look, look);
index 3d68200f8fa3e6becaa0fbee541c559756a5f44a..acaf81ab7c3361648a47d47e478f495f365abc07 100644 (file)
@@ -477,10 +477,10 @@ bool isNoRunsVertex(const RoseBuildImpl &build, RoseVertex u) {
         DEBUG_PRINTF("u=%zu is not a root role\n", g[u].index);
         return false;
     }
+    auto edge_result = edge(build.root, u, g);
+    RoseEdge e = edge_result.first;
 
-    RoseEdge e = edge(build.root, u, g);
-
-    if (!e) {
+    if (!edge_result.second) {
         DEBUG_PRINTF("u=%zu is not a root role\n", g[u].index);
         return false;
     }
@@ -635,7 +635,7 @@ u64a literalMinReportOffset(const RoseBuildImpl &build,
         }
 
         if (g[v].suffix) {
-            depth suffix_width = findMinWidth(g[v].suffix, g[v].suffix.top);
+            depth suffix_width = findMinWidth(suffix_id(g[v].suffix), g[v].suffix.top);
             assert(suffix_width.is_reachable());
             DEBUG_PRINTF("suffix with width %s\n", suffix_width.str().c_str());
             min_offset = min(min_offset, vert_offset + suffix_width);
@@ -886,7 +886,7 @@ void buildAccel(const RoseBuildImpl &build,
 bytecode_ptr<HWLM>
 buildHWLMMatcher(const RoseBuildImpl &build, const LitProto *litProto) {
     if (!litProto) {
-        return nullptr;
+        return bytecode_ptr<HWLM>(nullptr);
     }
     auto hwlm = hwlmBuild(*litProto->hwlmProto, build.cc,
                           build.getInitialGroups());
index 12843b9ab022716ee7a09cafd17a60fc5727ea80..919e5d860cd5e5ca655b2fac660b2a5c9d617eba 100644 (file)
@@ -145,7 +145,7 @@ namespace {
 /** Key used to group sets of leftfixes by the dedupeLeftfixes path. */
 struct RoseGroup {
     RoseGroup(const RoseBuildImpl &build, RoseVertex v)
-        : left_hash(hashLeftfix(build.g[v].left)),
+        : left_hash(hashLeftfix(left_id(build.g[v].left))),
           lag(build.g[v].left.lag), eod_table(build.isInETable(v)) {
         const RoseGraph &g = build.g;
         assert(in_degree(v, g) == 1);
@@ -262,8 +262,8 @@ bool dedupeLeftfixes(RoseBuildImpl &tbi) {
             // Scan the rest of the list for dupes.
             for (auto kt = std::next(jt); kt != jte; ++kt) {
                 if (g[v].left == g[*kt].left
-                    || !is_equal(g[v].left, g[v].left.leftfix_report,
-                                 g[*kt].left, g[*kt].left.leftfix_report)) {
+                    || !is_equal(left_id(g[v].left), g[v].left.leftfix_report,
+                                 left_id(g[*kt].left), g[*kt].left.leftfix_report)) {
                     continue;
                 }
 
@@ -547,8 +547,8 @@ bool checkPrefix(const rose_literal_id &ul, const u32 ulag,
 static
 bool hasSameEngineType(const RoseVertexProps &u_prop,
                        const RoseVertexProps &v_prop) {
-    const left_id u_left = u_prop.left;
-    const left_id v_left = v_prop.left;
+    const left_id u_left = left_id(u_prop.left);
+    const left_id v_left = left_id(v_prop.left);
 
     return !u_left.haig() == !v_left.haig()
         && !u_left.dfa() == !v_left.dfa()
@@ -1346,7 +1346,7 @@ insertion_ordered_map<left_id, vector<RoseVertex>> get_eng_verts(const RoseGraph
             continue;
         }
         assert(contains(all_reports(left), left.leftfix_report));
-        eng_verts[left].emplace_back(v);
+        eng_verts[left_id(left)].emplace_back(v);
     }
 
     return eng_verts;
@@ -2033,7 +2033,7 @@ void mergeCastleLeftfixes(RoseBuildImpl &build) {
             continue;
         }
 
-        eng_verts[g[v].left].emplace_back(v);
+        eng_verts[left_id(g[v].left)].emplace_back(v);
     }
 
     map<CharReach, vector<left_id>> by_reach;
@@ -2198,7 +2198,7 @@ void mergeAcyclicSuffixes(RoseBuildImpl &tbi) {
             continue;
         }
 
-        suffixes.insert(g[v].suffix, v);
+        suffixes.insert(suffix_id(g[v].suffix), v);
     }
 
     deque<SuffixBouquet> suff_groups;
@@ -2260,7 +2260,7 @@ void mergeSmallSuffixes(RoseBuildImpl &tbi) {
             continue;
         }
 
-        suffixes.insert(g[v].suffix, v);
+        suffixes.insert(suffix_id(g[v].suffix), v);
     }
 
     deque<SuffixBouquet> suff_groups;
index 861855b54eeeaeebf82ea67cd467de4d71b5a018..ab18770d06afbcd93278f041b64cc07fddd8d2dc 100644 (file)
@@ -1919,7 +1919,7 @@ void makeRoleSuffix(const RoseBuildImpl &build,
         return;
     }
     assert(contains(suffixes, g[v].suffix));
-    u32 queue = suffixes.at(g[v].suffix);
+    u32 queue = suffixes.at(suffix_id(g[v].suffix));
     u32 event;
     assert(contains(engine_info_by_queue, queue));
     const auto eng_info = engine_info_by_queue.at(queue);
@@ -2178,7 +2178,7 @@ void makeGroupSquashInstruction(const RoseBuildImpl &build, u32 lit_id,
 
 namespace {
 struct ProgKey {
-    ProgKey(const RoseProgram &p) : prog(&p) {}
+    explicit ProgKey(const RoseProgram &p) : prog(&p) {}
 
     bool operator==(const ProgKey &b) const {
         return RoseProgramEquivalence()(*prog, *b.prog);
@@ -2200,7 +2200,7 @@ RoseProgram assembleProgramBlocks(vector<RoseProgram> &&blocks_in) {
 
     ue2_unordered_set<ProgKey> seen;
     for (auto &block : blocks_in) {
-        if (contains(seen, block)) {
+        if (contains(seen, ProgKey(block))) {
             continue;
         }
 
index 9e210c54be94aa130695550266da298d56f9c680..edbbb0bb2192c7e8ef6a78e28222036454abae5b 100644 (file)
@@ -159,13 +159,13 @@ private:
 };
 
 struct RoseAliasingInfo {
-    RoseAliasingInfo(const RoseBuildImpl &build) {
+    explicit RoseAliasingInfo(const RoseBuildImpl &build) {
         const auto &g = build.g;
 
         // Populate reverse leftfix map.
         for (auto v : vertices_range(g)) {
             if (g[v].left) {
-                rev_leftfix[g[v].left].insert(v);
+                rev_leftfix[left_id(g[v].left)].insert(v);
             }
         }
 
@@ -259,8 +259,10 @@ bool samePredecessors(RoseVertex a, RoseVertex b, const RoseGraph &g) {
         }
 
         for (const auto &e_a : in_edges_range(a, g)) {
-            RoseEdge e = edge(source(e_a, g), b, g);
-            if (!e || g[e].rose_top != g[e_a].rose_top) {
+            auto edge_result = edge(source(e_a, g), b, g);
+            RoseEdge e = edge_result.first;
+            
+            if (!edge_result.second || g[e].rose_top != g[e_a].rose_top) {
                 DEBUG_PRINTF("bad tops\n");
                 return false;
             }
@@ -274,7 +276,9 @@ static
 bool hasCommonSuccWithBadBounds(RoseVertex a, RoseVertex b,
                                 const RoseGraph &g) {
     for (const auto &e_a : out_edges_range(a, g)) {
-        if (RoseEdge e = edge(b, target(e_a, g), g)) {
+        auto edge_result = edge(b, target(e_a, g), g);
+        RoseEdge e = edge_result.first;
+        if (edge_result.second) {
             if (g[e_a].maxBound < g[e].minBound
                 || g[e].maxBound < g[e_a].minBound) {
                 return true;
@@ -293,7 +297,9 @@ static
 bool hasCommonPredWithBadBounds(RoseVertex a, RoseVertex b,
                                 const RoseGraph &g) {
     for (const auto &e_a : in_edges_range(a, g)) {
-        if (RoseEdge e = edge(source(e_a, g), b, g)) {
+        auto edge_result = edge(source(e_a, g), b, g);
+        RoseEdge e = edge_result.first;
+        if (edge_result.second) {
             if (g[e_a].maxBound < g[e].minBound
                 || g[e].maxBound < g[e_a].minBound) {
                 return true;
@@ -700,7 +706,9 @@ bool hasCommonPredWithDiffRoses(RoseVertex a, RoseVertex b,
     const bool equal_roses = hasEqualLeftfixes(a, b, g);
 
     for (const auto &e_a : in_edges_range(a, g)) {
-        if (RoseEdge e = edge(source(e_a, g), b, g)) {
+        auto edge_result = edge(source(e_a, g), b, g);
+        RoseEdge e = edge_result.first;
+        if (edge_result.second) {
             DEBUG_PRINTF("common pred, e_r=%d r_t %u,%u\n",
                          (int)equal_roses, g[e].rose_top, g[e_a].rose_top);
             if (!equal_roses) {
@@ -908,8 +916,8 @@ bool mergeSameCastle(RoseBuildImpl &build, RoseVertex a, RoseVertex b,
     }
 
     assert(contains(rai.rev_leftfix[b_left], b));
-    rai.rev_leftfix[b_left].erase(b);
-    rai.rev_leftfix[a_left].insert(b);
+    rai.rev_leftfix[left_id(b_left)].erase(b);
+    rai.rev_leftfix[left_id(a_left)].insert(b);
 
     a_left.leftfix_report = new_report;
     b_left.leftfix_report = new_report;
@@ -918,7 +926,7 @@ bool mergeSameCastle(RoseBuildImpl &build, RoseVertex a, RoseVertex b,
     updateEdgeTops(g, a, a_top_map);
     updateEdgeTops(g, b, b_top_map);
 
-    pruneUnusedTops(castle, g, rai.rev_leftfix[a_left]);
+    pruneUnusedTops(castle, g, rai.rev_leftfix[left_id(a_left)]);
     return true;
 }
 
@@ -1026,9 +1034,9 @@ bool attemptRoseCastleMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a,
         b_left.castle = new_castle;
 
         assert(a_left == b_left);
-        rai.rev_leftfix[a_left].insert(a);
-        rai.rev_leftfix[a_left].insert(b);
-        pruneUnusedTops(*new_castle, g, rai.rev_leftfix[a_left]);
+        rai.rev_leftfix[left_id(a_left)].insert(a);
+        rai.rev_leftfix[left_id(a_left)].insert(b);
+        pruneUnusedTops(*new_castle, g, rai.rev_leftfix[left_id(a_left)]);
         return true;
     }
 
@@ -1079,7 +1087,9 @@ bool attemptRoseCastleMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a,
         // We should be protected from merging common preds with tops leading
         // to completely different repeats by earlier checks, but just in
         // case...
-        if (RoseEdge a_edge = edge(source(e, g), a, g)) {
+        auto edge_result = edge(source(e, g), a, g);
+        RoseEdge a_edge = edge_result.first;
+        if (edge_result.second) {
             u32 a_top = g[a_edge].rose_top;
             const PureRepeat &a_pr = m_castle->repeats[a_top]; // new report
             if (pr != a_pr) {
@@ -1112,9 +1122,9 @@ bool attemptRoseCastleMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a,
     b_left.leftfix_report = new_report;
 
     assert(a_left == b_left);
-    rai.rev_leftfix[a_left].insert(a);
-    rai.rev_leftfix[a_left].insert(b);
-    pruneUnusedTops(*m_castle, g, rai.rev_leftfix[a_left]);
+    rai.rev_leftfix[left_id(a_left)].insert(a);
+    rai.rev_leftfix[left_id(a_left)].insert(b);
+    pruneUnusedTops(*m_castle, g, rai.rev_leftfix[left_id(a_left)]);
     return true;
 }
 
@@ -1237,9 +1247,9 @@ bool attemptRoseGraphMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a,
         a_left.graph = new_graph;
         b_left.graph = new_graph;
 
-        rai.rev_leftfix[a_left].insert(a);
-        rai.rev_leftfix[a_left].insert(b);
-        pruneUnusedTops(*new_graph, g, rai.rev_leftfix[a_left]);
+        rai.rev_leftfix[left_id(a_left)].insert(a);
+        rai.rev_leftfix[left_id(a_left)].insert(b);
+        pruneUnusedTops(*new_graph, g, rai.rev_leftfix[left_id(a_left)]);
         return true;
     }
 
@@ -1258,7 +1268,7 @@ bool attemptRoseGraphMerge(RoseBuildImpl &build, bool preds_same, RoseVertex a,
     DEBUG_PRINTF("attempting merge of roses on vertices %zu and %zu\n",
                  g[a].index, g[b].index);
 
-    set<RoseVertex> &b_verts = rai.rev_leftfix[b_left];
+    set<RoseVertex> &b_verts = rai.rev_leftfix[left_id(b_left)];
     set<RoseVertex> aa;
     aa.insert(a);
 
@@ -2136,7 +2146,9 @@ void mergeDupeLeaves(RoseBuildImpl &build) {
         for (const auto &e : in_edges_range(v, g)) {
             RoseVertex u = source(e, g);
             DEBUG_PRINTF("u index=%zu\n", g[u].index);
-            if (RoseEdge et = edge(u, t, g)) {
+            auto edge_result = edge(u, t, g);
+            RoseEdge et = edge_result.first;
+            if (edge_result.second) {
                 if (g[et].minBound <= g[e].minBound
                     && g[et].maxBound >= g[e].maxBound) {
                     DEBUG_PRINTF("remove more constrained edge\n");
index 327911eacde345731dc4db1c95f07ab160d54731..20c78181b222341365ef1cc0886b64b9657d7c6f 100644 (file)
@@ -95,7 +95,7 @@ u32 findMinWidth(const RoseBuildImpl &tbi, enum rose_literal_table table) {
         }
 
         if (g[v].suffix) {
-            depth suffix_width = findMinWidth(g[v].suffix, g[v].suffix.top);
+            depth suffix_width = findMinWidth(suffix_id(g[v].suffix), g[v].suffix.top);
             assert(suffix_width.is_reachable());
             DEBUG_PRINTF("%zu has suffix with top %u (width %s), can fire "
                          "report at %u\n",
@@ -145,10 +145,10 @@ u32 findMaxBAWidth(const RoseBuildImpl &tbi) {
         u64a w = g[v].max_offset;
 
         if (g[v].suffix) {
-            if (has_non_eod_accepts(g[v].suffix)) {
+            if (has_non_eod_accepts(suffix_id(g[v].suffix))) {
                 return ROSE_BOUND_INF;
             }
-            depth suffix_width = findMaxWidth(g[v].suffix, g[v].suffix.top);
+            depth suffix_width = findMaxWidth(suffix_id(g[v].suffix), g[v].suffix.top);
             DEBUG_PRINTF("suffix max width for top %u is %s\n", g[v].suffix.top,
                          suffix_width.str().c_str());
             assert(suffix_width.is_reachable());
@@ -222,11 +222,11 @@ u32 findMaxBAWidth(const RoseBuildImpl &tbi, enum rose_literal_table table) {
                                                       accept_eod node */
 
         if (g[v].suffix) {
-            if (has_non_eod_accepts(g[v].suffix)) {
+            if (has_non_eod_accepts(suffix_id(g[v].suffix))) {
                 DEBUG_PRINTF("has accept\n");
                 return ROSE_BOUND_INF;
             }
-            depth suffix_width = findMaxWidth(g[v].suffix);
+            depth suffix_width = findMaxWidth(suffix_id(g[v].suffix));
             DEBUG_PRINTF("suffix max width %s\n", suffix_width.str().c_str());
             assert(suffix_width.is_reachable());
             if (!suffix_width.is_finite()) {
index e1d2f1f31473db305c2f12a79ca584442871ce20..c72bbef28f2c55693b2b256e7ece4e7fb8ff9bb1 100644 (file)
@@ -789,7 +789,7 @@ bytecode_ptr<NFA> getDfa(raw_dfa &rdfa, const CompileContext &cc,
     bool only_accel_init = !has_non_literals;
     bool trust_daddy_states = !has_non_literals;
 
-    bytecode_ptr<NFA> dfa = nullptr;
+    bytecode_ptr<NFA> dfa = bytecode_ptr<NFA>(nullptr);
     if (cc.grey.allowSmallWriteSheng) {
         dfa = shengCompile(rdfa, cc, rm, only_accel_init, &accel_states);
         if (!dfa) {
@@ -819,27 +819,27 @@ bytecode_ptr<NFA> prepEngine(raw_dfa &rdfa, u32 roseQuality,
     auto nfa = getDfa(rdfa, cc, rm, has_non_literals, accel_states);
     if (!nfa) {
         DEBUG_PRINTF("DFA compile failed for smallwrite NFA\n");
-        return nullptr;
+        return bytecode_ptr<NFA>(nullptr);
     }
 
     if (is_slow(rdfa, accel_states, roseQuality)) {
         DEBUG_PRINTF("is slow\n");
         *small_region = cc.grey.smallWriteLargestBufferBad;
         if (*small_region <= *start_offset) {
-            return nullptr;
+            return bytecode_ptr<NFA>(nullptr);
         }
         if (clear_deeper_reports(rdfa, *small_region - *start_offset)) {
             minimize_hopcroft(rdfa, cc.grey);
             if (rdfa.start_anchored == DEAD_STATE) {
                 DEBUG_PRINTF("all patterns pruned out\n");
-                return nullptr;
+                return bytecode_ptr<NFA>(nullptr);
             }
 
             nfa = getDfa(rdfa, cc, rm, has_non_literals, accel_states);
             if (!nfa) {
                 DEBUG_PRINTF("DFA compile failed for smallwrite NFA\n");
                 assert(0); /* able to build orig dfa but not the trimmed? */
-                return nullptr;
+                return bytecode_ptr<NFA>(nullptr);
             }
         }
     } else {
@@ -850,7 +850,7 @@ bytecode_ptr<NFA> prepEngine(raw_dfa &rdfa, u32 roseQuality,
     if (nfa->length > cc.grey.limitSmallWriteOutfixSize
         || nfa->length > cc.grey.limitDFASize) {
         DEBUG_PRINTF("smallwrite outfix size too large\n");
-        return nullptr; /* this is just a soft failure - don't build smwr */
+        return bytecode_ptr<NFA>(nullptr); /* this is just a soft failure - don't build smwr */
     }
 
     nfa->queueIndex = 0; /* dummy, small write API does not use queue */
@@ -870,12 +870,12 @@ bytecode_ptr<SmallWriteEngine> SmallWriteBuildImpl::build(u32 roseQuality) {
     if (dfas.empty() && !has_literals) {
         DEBUG_PRINTF("no smallwrite engine\n");
         poisoned = true;
-        return nullptr;
+        return bytecode_ptr<SmallWriteEngine>(nullptr);
     }
 
     if (poisoned) {
         DEBUG_PRINTF("some pattern could not be made into a smallwrite dfa\n");
-        return nullptr;
+        return bytecode_ptr<SmallWriteEngine>(nullptr);
     }
 
     // We happen to know that if the rose is high quality, we're going to limit
@@ -903,12 +903,12 @@ bytecode_ptr<SmallWriteEngine> SmallWriteBuildImpl::build(u32 roseQuality) {
 
     if (dfas.empty()) {
         DEBUG_PRINTF("no dfa, pruned everything away\n");
-        return nullptr;
+        return bytecode_ptr<SmallWriteEngine>(nullptr);
     }
 
     if (!mergeDfas(dfas, rm, cc)) {
         dfas.clear();
-        return nullptr;
+        return bytecode_ptr<SmallWriteEngine>(nullptr);
     }
 
     assert(dfas.size() == 1);
@@ -925,7 +925,7 @@ bytecode_ptr<SmallWriteEngine> SmallWriteBuildImpl::build(u32 roseQuality) {
         DEBUG_PRINTF("some smallwrite outfix could not be prepped\n");
         /* just skip the smallwrite optimization */
         poisoned = true;
-        return nullptr;
+        return bytecode_ptr<SmallWriteEngine>(nullptr);
     }
 
     u32 size = sizeof(SmallWriteEngine) + nfa->length;
index 49b4a824d10d639e7310d16e6e450238f37e757e..c5dea4c59901648e96be20aee6d58548326852eb 100644 (file)
@@ -68,7 +68,7 @@ public:
     AlignedAllocator() noexcept {}
 
     template <class U, std::size_t N2>
-    AlignedAllocator(const AlignedAllocator<U, N2> &) noexcept {}
+    explicit AlignedAllocator(const AlignedAllocator<U, N2> &) noexcept {}
 
     template <class U> struct rebind {
         using other = AlignedAllocator<U, N>;
index 4a3fbd6ed50aeb352309daa5e3bf7584f9bb03a3..1f29dfce066b60bfcf0669695703db370fb61592 100644 (file)
@@ -64,7 +64,7 @@ public:
         assert(none());
     }
 
-    bitfield(const boost::dynamic_bitset<> &a) : bits{{0}} {
+    explicit bitfield(const boost::dynamic_bitset<> &a) : bits{{0}} {
         assert(a.size() == requested_size);
         assert(none());
         for (auto i = a.find_first(); i != a.npos; i = a.find_next(i)) {
index f1f2e5ef8ec292aa6817b8308f3b6db75760a1cf..ab2b9171c5c149fe14b3c62532e20abce9f8ea80 100644 (file)
@@ -66,7 +66,7 @@ public:
         }
     }
 
-    bytecode_ptr(std::nullptr_t) {}
+    explicit bytecode_ptr(std::nullptr_t) {}
 
     T *get() const { return ptr.get(); }
 
index 41452eb42ac7bdbbe53a409e5d3ea6e3dfc2da83..9ba7e23210eaf41ee581e068db6bc967ceffbadb 100644 (file)
@@ -195,10 +195,10 @@ public:
 
     // Constructors.
 
-    flat_set(const Compare &compare = Compare(),
+    explicit flat_set(const Compare &compare = Compare(),
              const Allocator &alloc = Allocator())
         : base_type(compare, alloc) {}
-
+    
     template <class InputIt>
     flat_set(InputIt first, InputIt last, const Compare &compare = Compare(),
              const Allocator &alloc = Allocator())
@@ -425,7 +425,7 @@ public:
 
     // Constructors.
 
-    flat_map(const Compare &compare = Compare(),
+    explicit flat_map(const Compare &compare = Compare(),
              const Allocator &alloc = Allocator())
         : base_type(compare, alloc) {}
 
@@ -615,7 +615,7 @@ public:
         friend class flat_map;
     protected:
         Compare c;
-        value_compare(Compare c_in) : c(c_in) {}
+        explicit value_compare(Compare c_in) : c(c_in) {}
     public:
         bool operator()(const value_type &lhs, const value_type &rhs) {
             return c(lhs.first, rhs.first);
index 65bc29c30b7668cdda3b84555315a411739505c1..fecb0c685e38b5cc18addc1d41391e5434939dd2 100644 (file)
@@ -56,7 +56,7 @@ struct hash_output_it {
     using reference = void;
     using iterator_category = std::output_iterator_tag;
 
-    hash_output_it(size_t *hash_out = nullptr) : out(hash_out) {}
+    explicit hash_output_it(size_t *hash_out = nullptr) : out(hash_out) {}
     hash_output_it &operator++() {
         return *this;
     }
@@ -65,7 +65,7 @@ struct hash_output_it {
     }
 
     struct deref_proxy {
-        deref_proxy(size_t *hash_out) : out(hash_out) {}
+        explicit deref_proxy(size_t *hash_out) : out(hash_out) {}
 
         template<typename T>
         void operator=(const T &val) const {
@@ -76,7 +76,7 @@ struct hash_output_it {
         size_t *out; /* output location of the owning iterator */
     };
 
-    deref_proxy operator*() { return {out}; }
+    deref_proxy operator*() { return deref_proxy(out); }
 
 private:
     size_t *out; /* location to output the hashes to */
index aa9718d73a656902c73b23c9be5247efd017a35f..d615d36a0eeeae8697d8c6cb63f615630886ab9d 100644 (file)
@@ -210,7 +210,7 @@ public:
      * edge() and add_edge(). As we have null_edges and we always allow
      * parallel edges, the bool component of the return from these functions is
      * not required. */
-    edge_descriptor(const std::pair<edge_descriptor, bool> &tup)
+    explicit edge_descriptor(const std::pair<edge_descriptor, bool> &tup)
         : p(tup.first.p), serial(tup.first.serial) {
         assert(tup.second == (bool)tup.first);
     }
@@ -432,7 +432,7 @@ public:
         vertex_descriptor> {
         using super = typename adjacency_iterator::iterator_adaptor_;
     public:
-        adjacency_iterator(out_edge_iterator a) : super(std::move(a)) { }
+        explicit adjacency_iterator(out_edge_iterator a) : super(std::move(a)) { }
         adjacency_iterator() { }
 
         vertex_descriptor dereference() const {
@@ -448,7 +448,7 @@ public:
         vertex_descriptor> {
         using super = typename inv_adjacency_iterator::iterator_adaptor_;
     public:
-        inv_adjacency_iterator(in_edge_iterator a) : super(std::move(a)) { }
+        explicit inv_adjacency_iterator(in_edge_iterator a) : super(std::move(a)) { }
         inv_adjacency_iterator() { }
 
         vertex_descriptor dereference() const {
@@ -791,7 +791,7 @@ public:
 
         typedef typename boost::lvalue_property_map_tag category;
 
-        prop_map(value_type P_of::*m_in) : member(m_in) { }
+        explicit prop_map(value_type P_of::*m_in) : member(m_in) { }
 
         reference operator[](key_type k) const {
             return k.raw()->props.*member;
index 2c585ae5f9778cc1b0c788eb5dffc349d296ee50..0b782569f848c5c9e49d164111975899799f01cc 100644 (file)
@@ -98,7 +98,7 @@ protected:
         ParsedExpression parsed(0, pattern.c_str(), flags, 0);
         auto built_expr = buildGraph(rm, cc, parsed);
         const auto &g = built_expr.g;
-        ASSERT_TRUE(g != nullptr);
+        ASSERT_TRUE(static_cast<bool>(g));
         clearReports(*g);
 
         rm.setProgramOffset(0, MATCH_REPORT);
@@ -106,7 +106,7 @@ protected:
         /* LBR triggered by dot */
         vector<vector<CharReach>> triggers = {{CharReach::dot()}};
         nfa = constructLBR(*g, triggers, cc, rm);
-        ASSERT_TRUE(nfa != nullptr);
+        ASSERT_TRUE(static_cast<bool>(nfa));
 
         full_state = make_bytecode_ptr<char>(nfa->scratchStateSize, 64);
         stream_state = make_bytecode_ptr<char>(nfa->streamStateSize);
index c1149216dee71bc13ee70f8be3633a0381c4b7ff..c3bfd75f8a6d12b37f9dfae3786c2cbaccc1b844 100644 (file)
@@ -66,7 +66,7 @@ size_t choosePosition(const SeqT &corpus, CorpusProperties &props) {
 
 class CorpusEditor {
 public:
-    CorpusEditor(CorpusProperties &p) : props(p) {}
+    explicit CorpusEditor(CorpusProperties &p) : props(p) {}
 
     // Apply edits to a corpus
     void applyEdits(string &corpus);
@@ -171,7 +171,7 @@ u8 CorpusEditor::chooseByte() {
 
 class CorpusEditorUtf8 {
 public:
-    CorpusEditorUtf8(CorpusProperties &p) : props(p) {}
+    explicit CorpusEditorUtf8(CorpusProperties &p) : props(p) {}
 
     // Apply edits to a corpus.
     void applyEdits(vector<unichar> &corpus);