]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Bug fix/clang-tidy-performance (#300)
authorgtsoul-tech <56584633+gtsoul-tech@users.noreply.github.com>
Thu, 20 Jun 2024 11:57:19 +0000 (14:57 +0300)
committerGitHub <noreply@github.com>
Thu, 20 Jun 2024 11:57:19 +0000 (14:57 +0300)
Various clang-tidy-performance fixes:
* noexcept
* performance-noexcept-swap
* performance
* performance-move-const-arg
* performance-unnecessary-value-param
* performance-inefficient-vector-operation
* performance-no-int-to-ptr
* add performance
* performance-inefficient-string-concatenation
* clang-analyzer-deadcode.DeadStores
* performance-inefficient-vector-operation
* clang-analyzer-core.NullDereference
* clang-analyzer-core.UndefinedBinaryOperatorResult
* clang-analyzer-core.CallAndMessage

---------

Co-authored-by: gtsoul-tech <gtsoulkanakis@gmail.com>
40 files changed:
.clang-tidy
examples/patbench.cc
examples/pcapscan.cc
src/fdr/fdr.c
src/nfa/goughcompile_dump.cpp
src/nfa/limex_compile.cpp
src/nfa/sheng_impl.h
src/nfa/sheng_impl4.h
src/nfa/truffle_simd.hpp
src/nfa/vermicelli_sve.h
src/nfagraph/ng_limex_accel.cpp
src/nfagraph/ng_literal_analysis.cpp
src/nfagraph/ng_mcclellan.cpp
src/parser/parse_error.h
src/rose/program_runtime.c
src/rose/rose_build_bytecode.cpp
src/rose/rose_build_instructions.h
src/rose/rose_build_lookaround.cpp
src/rose/rose_build_matchers.cpp
src/rose/rose_build_matchers.h
src/rose/rose_build_program.cpp
src/rose/rose_build_program.h
src/rose/rose_in_graph.h
src/som/slot_manager_internal.h
src/ue2common.h
src/util/bytecode_ptr.h
src/util/flat_containers.h
src/util/insertion_ordered.h
src/util/ue2_graph.h
src/util/ue2string.h
src/util/unicode_set.h
tools/hsbench/huge.cpp
tools/hscheck/main.cpp
tools/hsdump/main.cpp
unit/hyperscan/bad_patterns.cpp
unit/hyperscan/test_util.h
util/cross_compile.cpp
util/database_util.cpp
util/expressions.cpp
util/ng_corpus_generator.h

index 79ec90657c1af4045ecbc4c2f9aa32c852748013..4cadbbb44ec5db9c725c27ec1585d6799b3dbd23 100644 (file)
@@ -1,9 +1,11 @@
 #unit/gtest/gtest-all.cc,build/src/parser/Parser.cpp,build/src/parser/control_verbs.cpp
 #Dont change first comment ignores specific files from clang-tidy
 
-Checks:              'clang-analyzer-*,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling'
+
+Checks:              'clang-analyzer-*,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,performance-*,-performance-unnecessary-value-param,-performance-avoid-endl'
 WarningsAsErrors:    ''
 HeaderFilterRegex:   '.*'
+SystemHeaders: false
 FormatStyle:         none
 InheritParentConfig: true
-User:                user
+User:                user
\ No newline at end of file
index 1a7e941549fcde6d13ee4911feebe1a99f35d128..4576bfe08634335b39fa2584f437b18835852bfe 100644 (file)
@@ -301,7 +301,7 @@ public:
         // database.
         hs_error_t err = hs_alloc_scratch(db, &scratch);
         if (err != HS_SUCCESS) {
-            cerr << "ERROR: could not allocate scratch space. Exiting." << endl;
+            cerr << "ERROR: could not allocate scratch space. Exiting.\n";
             exit(-1);
         }
     }
@@ -313,8 +313,7 @@ public:
         size_t scratch_size;
         hs_error_t err = hs_scratch_size(scratch, &scratch_size);
         if (err != HS_SUCCESS) {
-            cerr << "ERROR: could not query scratch space size. Exiting."
-                 << endl;
+            cerr << "ERROR: could not query scratch space size. Exiting.\n";
             exit(-1);
         }
         return scratch_size;
@@ -379,7 +378,7 @@ public:
         for (auto &stream : streams) {
             hs_error_t err = hs_open_stream(db, 0, &stream);
             if (err != HS_SUCCESS) {
-                cerr << "ERROR: Unable to open stream. Exiting." << endl;
+                cerr << "ERROR: Unable to open stream. Exiting.\n";
                 exit(-1);
             }
         }
@@ -392,7 +391,7 @@ public:
             hs_error_t err =
                 hs_close_stream(stream, scratch, onMatch, &matchCount);
             if (err != HS_SUCCESS) {
-                cerr << "ERROR: Unable to close stream. Exiting." << endl;
+                cerr << "ERROR: Unable to close stream. Exiting.\n";
                 exit(-1);
             }
         }
@@ -407,7 +406,7 @@ public:
                                             pkt.c_str(), pkt.length(), 0,
                                             scratch, onMatch, &matchCount);
             if (err != HS_SUCCESS) {
-                cerr << "ERROR: Unable to scan packet. Exiting." << endl;
+                cerr << "ERROR: Unable to scan packet. Exiting.\n";
                 exit(-1);
             }
         }
@@ -421,7 +420,7 @@ public:
             hs_error_t err = hs_scan(db, pkt.c_str(), pkt.length(), 0,
                                      scratch, onMatch, &matchCount);
             if (err != HS_SUCCESS) {
-                cerr << "ERROR: Unable to scan packet. Exiting." << endl;
+                cerr << "ERROR: Unable to scan packet. Exiting.\n";
                 exit(-1);
             }
         }
@@ -509,29 +508,29 @@ public:
 
 static
 void usage(const char *) {
-    cerr << "Usage:" << endl << endl;
-    cerr << "  patbench [-n repeats] [ -G generations] [ -C criterion ]" << endl
+    cerr << "Usage:\n\n";
+    cerr << "  patbench [-n repeats] [ -G generations] [ -C criterion ]\n"
          << "           [ -F factor_group_size ] [ -N | -S ] "
-         << "<pattern file> <pcap file>" << endl << endl
+         << "<pattern file> <pcap file>\n\n"
          << "    -n repeats sets the number of times the PCAP is repeatedly "
-            "scanned" << endl << "       with the pattern." << endl
+            "scanned\n" << "       with the pattern.\n"
          << "    -G generations sets the number of generations that the "
-            "algorithm is" << endl << "       run for." << endl
+            "algorithm is\n" << "       run for.\n"
          << "    -N sets non-streaming mode, -S sets streaming mode (default)."
          << endl << "    -F sets the factor group size (must be >0); this "
-                    "allows the detection" << endl
-         << "       of multiple interacting factors." << endl << "" << endl
-         << "    -C sets the 'criterion', which can be either:" << endl
+                    "allows the detection\n"
+         << "       of multiple interacting factors.\n" << "\n"
+         << "    -C sets the 'criterion', which can be either:\n"
          << "         t  throughput (the default) - this requires a pcap file"
-         << endl << "         r  scratch size" << endl
-         << "         s  stream state size" << endl
-         << "         c  compile time" << endl << "         b  bytecode size"
+         << endl << "         r  scratch size\n"
+         << "         s  stream state size\n"
+         << "         c  compile time\n" << "         b  bytecode size"
          << endl << endl
          << "We recommend the use of a utility like 'taskset' on "
-            "multiprocessor hosts to" << endl
+            "multiprocessor hosts to\n"
          << "lock execution to a single processor: this will remove processor "
-            "migration" << endl
-         << "by the scheduler as a source of noise in the results." << endl;
+            "migration\n"
+         << "by the scheduler as a source of noise in the results.\n";
 }
 
 static
@@ -574,7 +573,7 @@ double eval_set(Benchmark &bench, const Sigdata &sigs, unsigned int mode,
         size_t dbSize;
         hs_error_t err = hs_database_size(bench.getDatabase(), &dbSize);
         if (err != HS_SUCCESS) {
-            cerr << "ERROR: could not retrieve bytecode size" << endl;
+            cerr << "ERROR: could not retrieve bytecode size\n";
             exit(1);
         }
         return dbSize;
@@ -585,7 +584,7 @@ double eval_set(Benchmark &bench, const Sigdata &sigs, unsigned int mode,
         size_t streamStateSize;
         hs_error_t err = hs_stream_size(bench.getDatabase(), &streamStateSize);
         if (err != HS_SUCCESS) {
-            cerr << "ERROR: could not retrieve stream state size" << endl;
+            cerr << "ERROR: could not retrieve stream state size\n";
             exit(1);
         }
         return streamStateSize;
@@ -684,14 +683,13 @@ int main(int argc, char **argv) {
     Benchmark bench;
     if (criterion == CRITERION_THROUGHPUT) {
         if (!bench.readStreams(pcapFile)) {
-            cerr << "Unable to read packets from PCAP file. Exiting." << endl;
+            cerr << "Unable to read packets from PCAP file. Exiting.\n";
             exit(-1);
         }
     }
 
     if ((criterion == CRITERION_STREAM_STATE) && (mode != HS_MODE_STREAM)) {
-        cerr << "Cannot evaluate stream state for block mode compile. Exiting."
-             << endl;
+        cerr << "Cannot evaluate stream state for block mode compile. Exiting.\n";
         exit(-1);
     }
 
@@ -729,7 +727,7 @@ int main(int argc, char **argv) {
     unsigned generations = min(gen_max, (sigs.size() - 1) / factor_max);
 
     cout << "Cutting signatures cumulatively for " << generations
-         << " generations" << endl;
+         << " generations\n";
     for (unsigned gen = 0; gen < generations; ++gen) {
         cout << "Generation " << gen << " ";
         set<unsigned> s(work_sigs.begin(), work_sigs.end());
@@ -773,7 +771,7 @@ int main(int argc, char **argv) {
         cout << "Performance: ";
         print_criterion(criterion, best);
         cout << " (" << std::fixed << std::setprecision(3) << (best / score_base)
-             << "x) after cutting:" << endl;
+             << "x) after cutting:\n";
         cout.flags(out_f);
 
         // s now has factor_max signatures
@@ -852,7 +850,7 @@ static unsigned parseFlags(const string &flagsStr) {
         case '\r': // stray carriage-return
             break;
         default:
-            cerr << "Unsupported flag \'" << c << "\'" << endl;
+            cerr << "Unsupported flag \'" << c << "\'\n";
             exit(-1);
         }
     }
@@ -864,7 +862,7 @@ static void parseFile(const char *filename, vector<string> &patterns,
                       vector<string> &originals) {
     ifstream inFile(filename);
     if (!inFile.good()) {
-        cerr << "ERROR: Can't open pattern file \"" << filename << "\"" << endl;
+        cerr << "ERROR: Can't open pattern file \"" << filename << "\"\n";
         exit(-1);
     }
 
@@ -894,7 +892,7 @@ static void parseFile(const char *filename, vector<string> &patterns,
 
         size_t flagsStart = expr.find_last_of('/');
         if (flagsStart == string::npos) {
-            cerr << "ERROR: no trailing '/' char" << endl;
+            cerr << "ERROR: no trailing '/' char\n";
             exit(-1);
         }
 
index f4feb573f687ab91d3a4345fffc9bc57c0d6cbf6..7dcc8dc47040a5cb4717b457d020befc600a9331 100644 (file)
@@ -433,7 +433,7 @@ static void databasesFromFile(const char *filename,
     vector<const char*> cstrPatterns;
     for (const auto &pattern : patterns) {
         // cppcheck-suppress useStlAlgorithm
-        cstrPatterns.push_back(pattern.c_str());
+        cstrPatterns.push_back(pattern.c_str()); //NOLINT (performance-inefficient-vector-operation)
     }
 
     cout << "Compiling Hyperscan databases with " << patterns.size()
index 302487a31cb78dd556e1ca0c27320a7b7d41c9aa..7aa22ef5b1605cf57bf26ae6ac84fb2bfd6203ce 100644 (file)
@@ -308,7 +308,7 @@ void do_confirm_fdr(u64a *conf, u8 offset, hwlmcb_rv_t *control,
     /* ptr is currently referring to a location in the zone's buffer, we also
      * need a pointer in the original, main buffer for the final string compare.
      */
-    const u8 *ptr_main = (const u8 *)((uintptr_t)ptr + z->zone_pointer_adjust);
+    const u8 *ptr_main = (const u8 *)((uintptr_t)ptr + z->zone_pointer_adjust); //NOLINT (performance-no-int-to-ptr)
 
     const u8 *confLoc = ptr;
 
index 649310c6e9949ec0f41249b3c6e5505d06dc4375..8fca295a0be01a0e503d052eb2a11932096013f0 100644 (file)
@@ -146,7 +146,7 @@ void dump_var_mapping(const GoughGraph &g, const string &base,
             vector<u32> used_id;
             for (const GoughSSAVar *var : used) {
                 // cppcheck-suppress useStlAlgorithm
-                used_id.emplace_back(var->slot);
+                used_id.emplace_back(var->slot);    //NOLINT (performance-inefficient-vector-operation)
             }
             for (const u32 &id : used_id) {
                 fprintf(f, " %u", id);
@@ -169,7 +169,7 @@ void dump_var_mapping(const GoughGraph &g, const string &base,
             vector<u32> used_id;
             for (const GoughSSAVar *var : used) {
                 // cppcheck-suppress useStlAlgorithm
-                used_id.emplace_back(var->slot);
+                used_id.emplace_back(var->slot);    //NOLINT (performance-inefficient-vector-operation)
             }
             for (const u32 &id : used_id) {
                 fprintf(f, " %u", id);
index 304116a80c52d69c1b3dc04a2de950e0a00ad195..39214bd8f165d38a1c9087733d16974e4d9456de 100644 (file)
@@ -628,7 +628,7 @@ void fillAccelInfo(build_info &bi) {
     vector<NFAVertex> astates;
     for (const auto &m : accel_map) {
         // cppcheck-suppress useStlAlgorithm
-        astates.emplace_back(m.first);
+        astates.emplace_back(m.first);  //NOLINT (performance-inefficient-vector-operation)
     }
 
     NFAStateSet useful(num_states);
@@ -1071,7 +1071,7 @@ void buildAcceptsList(const build_info &args, ReportListCache &reports_cache,
             a.reports = addReports(h[v].reports, reports, reports_cache);
         }
         a.squash = addSquashMask(args, v, squash);
-        accepts.emplace_back(std::move(a));
+        accepts.emplace_back(a);
     }
 }
 
index 8b22d81067c5013346df81d7cdfb9043a8f271ae..0204b872d7328f0937380a806c3c8d7a6ccabc2d 100644 (file)
@@ -143,7 +143,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
 
         if (unlikely(ACCEPT_FUNC32(tmp))) {
             DEBUG_PRINTF("Accept state %u reached\n", tmp & SHENG32_STATE_MASK);
-            u64a match_offset = base_offset + (cur_buf - buf) + 1;
+            u64a match_offset = base_offset + (cur_buf - buf) + 1;  //NOLINT (clang-analyzer-deadcode.DeadStores)
             DEBUG_PRINTF("Match @ %llu\n", match_offset);
             if (STOP_AT_MATCH) {
                 DEBUG_PRINTF("Stopping at match @ %lli\n",
@@ -222,7 +222,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
 
         if (unlikely(ACCEPT_FUNC64(tmp))) {
             DEBUG_PRINTF("Accept state %u reached\n", tmp & SHENG64_STATE_MASK);
-            u64a match_offset = base_offset + (cur_buf - buf) + 1;
+            u64a match_offset = base_offset + (cur_buf - buf) + 1;  //NOLINT (clang-analyzer-deadcode.DeadStores)
             DEBUG_PRINTF("Match @ %llu\n", match_offset);
             if (STOP_AT_MATCH) {
                 DEBUG_PRINTF("Stopping at match @ %lli\n",
index d2b3dc35d8e6d4a18c701fa2235ecefdf7588d8a..40642a60f9fff8eee53bf80a373524c77639711a 100644 (file)
@@ -392,7 +392,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
 
         if (unlikely(INTERESTING_FUNC32(a1, a2, a3, a4))) {
             if (ACCEPT_FUNC32(a1)) {
-                u64a match_offset = base_offset + b1 - buf;
+                u64a match_offset = base_offset + b1 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a1 & SHENG32_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
@@ -417,7 +417,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
                 }
             }
             if (ACCEPT_FUNC32(a2)) {
-                u64a match_offset = base_offset + b2 - buf;
+                u64a match_offset = base_offset + b2 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a2 & SHENG32_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
@@ -442,7 +442,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
                 }
             }
             if (ACCEPT_FUNC32(a3)) {
-                u64a match_offset = base_offset + b3 - buf;
+                u64a match_offset = base_offset + b3 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a3 & SHENG32_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
@@ -467,7 +467,7 @@ char SHENG32_IMPL(u8 *state, NfaCallback cb, void *ctxt,
                 }
             }
             if (ACCEPT_FUNC32(a4)) {
-                u64a match_offset = base_offset + b4 - buf;
+                u64a match_offset = base_offset + b4 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a4 & SHENG32_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
@@ -642,7 +642,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
 
         if (unlikely(INTERESTING_FUNC64(a1, a2, a3, a4))) {
             if (ACCEPT_FUNC64(a1)) {
-                u64a match_offset = base_offset + b1 - buf;
+                u64a match_offset = base_offset + b1 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a1 & SHENG64_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
@@ -667,7 +667,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
                 }
             }
             if (ACCEPT_FUNC64(a2)) {
-                u64a match_offset = base_offset + b2 - buf;
+                u64a match_offset = base_offset + b2 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a2 & SHENG64_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
@@ -692,7 +692,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
                 }
             }
             if (ACCEPT_FUNC64(a3)) {
-                u64a match_offset = base_offset + b3 - buf;
+                u64a match_offset = base_offset + b3 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a3 & SHENG64_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
@@ -717,7 +717,7 @@ char SHENG64_IMPL(u8 *state, NfaCallback cb, void *ctxt,
                 }
             }
             if (ACCEPT_FUNC64(a4)) {
-                u64a match_offset = base_offset + b4 - buf;
+                u64a match_offset = base_offset + b4 - buf; //NOLINT (clang-analyzer-deadcode.DeadStores)
                 DEBUG_PRINTF("Accept state %u reached\n",
                              a4 & SHENG64_STATE_MASK);
                 DEBUG_PRINTF("Match @ %llu\n", match_offset);
index 61609a392b7afc31d87abebe8021b4b5776e1d88..2e8ecb9abecfa8ca3088c3e4b9a3c2902591eaa4 100644 (file)
@@ -104,9 +104,9 @@ const u8 *scanBlock(svuint8_t shuf_mask_lo_highclear, svuint8_t shuf_mask_lo_hig
     }
     uint64_t index;
     if (forward) {
-        index = first_non_zero(vector_size_int_8, result_mask);
+        index = first_non_zero(vector_size_int_8, result_mask); //NOLINT (clang-analyzer-core.CallAndMessage)
     } else {
-        index = last_non_zero(vector_size_int_8, result_mask);
+        index = last_non_zero(vector_size_int_8, result_mask); //NOLINT (clang-analyzer-core.CallAndMessage)
     }
 
     if (index < vector_size_int_8) {
@@ -311,7 +311,7 @@ const u8 *truffleExecReal(const m128 &shuf_mask_lo_highclear, m128 shuf_mask_lo_
         SuperVector<S> chars = SuperVector<S>::Zeroes();
         const u8* end_buf;
         if (buf_end - buf < S) {
-          memcpy(&chars.u, buf, buf_end - buf);
+          memcpy(&chars.u, buf, buf_end - buf); //NOLINT (clang-analyzer-core.NonNullParamChecker)
           end_buf = buf;
         } else {
           chars = SuperVector<S>::loadu(buf_end - S);
index 13f843417d2ab3ee6a0351efdf9cce8a0ae1ca03..184be1bfa96e99c8aa2911c37c5b1adec525b155 100644 (file)
@@ -379,7 +379,7 @@ const u8 *vermicelliDoubleExec(char c1, char c2, bool nocase, const u8 *buf,
     }
     /* check for partial match at end */
     u8 mask = nocase ? CASE_CLEAR : 0xff;
-    if ((buf_end[-1] & mask) == (u8)c1) {
+    if ((buf_end[-1] & mask) == (u8)c1) {   //NOLINT (clang-analyzer-core.NullDereference)
         DEBUG_PRINTF("partial!!!\n");
         return buf_end - 1;
     }
@@ -486,7 +486,7 @@ const u8 *vermicelliDoubleMasked16Exec(const m128 mask, char c1, char m1,
         }
     }
     /* check for partial match at end */
-    if ((buf_end[-1] & m1) == (u8)c1) {
+    if ((buf_end[-1] & m1) == (u8)c1) { //NOLINT (clang-analyzer-core.NullDereference)
         DEBUG_PRINTF("partial!!!\n");
         return buf_end - 1;
     }
@@ -523,7 +523,7 @@ const u8 *dvermSearchAlignedMasked(m128 chars1, m128 chars2,
         m128 v2 = eq128(chars2, and128(data, mask2));
         u32 z = movemask128(and128(v1, rshiftbyte_m128(v2, 1)));
 
-        if ((buf[15] & m1) == c1 && (buf[16] & m2) == c2) {
+        if ((buf[15] & m1) == c1 && (buf[16] & m2) == c2) {     //NOLINT (clang-analyzer-core.NullDereference)
             z |= (1 << 15);
         }
         if (unlikely(z)) {
@@ -579,7 +579,7 @@ const u8 *vermicelliDoubleMaskedExec(char c1, char c2, char m1, char m2,
     }
 
     /* check for partial match at end */
-    if ((buf_end[-1] & m1) == (u8)c1) {
+    if ((buf_end[-1] & m1) == (u8)c1) { //NOLINT (clang-analyzer-core.NullDereference)
         DEBUG_PRINTF("partial!!!\n");
         return buf_end - 1;
     }
index 21e7fa0588fc4465e65439f7960d9087f1aed9a8..226f748a029e48f01a193900483f942dc91d109f 100644 (file)
@@ -190,7 +190,7 @@ void findPaths(const NGHolder &g, NFAVertex v,
 namespace {
 struct SAccelScheme {
     SAccelScheme(CharReach cr_in, u32 offset_in)
-        : cr(std::move(cr_in)), offset(offset_in) {
+        : cr(cr_in), offset(offset_in) {
         assert(offset <= MAX_ACCEL_DEPTH);
     }
 
@@ -254,7 +254,7 @@ void findBestInternal(vector<vector<CharReach>>::const_iterator pb,
             DEBUG_PRINTF("worse\n");
             continue;
         }
-        priority_path.emplace_back(std::move(as));
+        priority_path.emplace_back(as);
     }
 
     sort(priority_path.begin(), priority_path.end());
@@ -300,7 +300,7 @@ SAccelScheme findBest(const vector<vector<CharReach>> &paths,
 namespace {
 struct DAccelScheme {
     DAccelScheme(CharReach cr_in, u32 offset_in)
-        : double_cr(std::move(cr_in)), double_offset(offset_in) {
+        : double_cr(cr_in), double_offset(offset_in) {
         assert(double_offset <= MAX_ACCEL_DEPTH);
     }
 
@@ -570,7 +570,7 @@ AccelScheme findBestAccelScheme(vector<vector<CharReach>> paths,
         DAccelScheme da = findBestDoubleAccelScheme(paths, terminating);
         if (da.double_byte.size() <= DOUBLE_SHUFTI_LIMIT) {
             rv.double_byte = std::move(da.double_byte);
-            rv.double_cr = std::move(da.double_cr);
+            rv.double_cr = da.double_cr;
             rv.double_offset = da.double_offset;
         }
     }
index 178f5aa35d8680559fa63dda02f9f75207eaacef..119bd33fd15cf5780d2271ac745c72494275244b 100644 (file)
@@ -68,7 +68,7 @@ namespace {
 
 struct LitGraphVertexProps {
     LitGraphVertexProps() = default;
-    explicit LitGraphVertexProps(ue2_literal::elem c_in) : c(std::move(c_in)) {}
+    explicit LitGraphVertexProps(ue2_literal::elem c_in) : c(c_in) {}
     ue2_literal::elem c; // string element (char + bool)
     size_t index = 0; // managed by ue2_graph
 };
index 3b6c076001078539f295ed073c457ffc9d81766c..98c1e3545ec8f851acbb52edc5b23b2565925198 100644 (file)
@@ -380,7 +380,7 @@ public:
             u32 vert_id = graph[v].index;
             squash.set(vert_id);
             squash_mask[vert_id]
-                = Automaton_Traits::copy_states(std::move(sq.second),
+                = Automaton_Traits::copy_states(sq.second,
                                                 numStates);
         }
 
index 4556ed5e048704297031b41567568f3568529691..9bd17f6cc84d1666e86bd104e47255976355e0d9 100644 (file)
@@ -44,7 +44,7 @@ class ParseError : public CompileError {
 public:
     // Note: 'why' should describe why the error occurred and end with a
     // full stop, but no line break.
-    explicit ParseError(std::string why) : CompileError(std::move(why)) {}
+    explicit ParseError(const std::string& why) : CompileError(why) {}
 
     ~ParseError() override;
 };
index bedc8264887e712cd1f5ba20215e6302c2b03338..1273f79978200e8f37029532bf31d0f7b929e734 100644 (file)
@@ -788,7 +788,7 @@ int roseCheckMask32(const struct core_info *ci, const u8 *and_mask,
     DEBUG_PRINTF("h_len %d c_len %d\n", h_len, c_len);
     // we use valid_data_mask to blind bytes before history/in the future.
     u32 valid_data_mask;
-    valid_data_mask = (~0u) << (h_shift + c_shift) >> (c_shift);
+    valid_data_mask = (~0u) << (h_shift + c_shift) >> (c_shift); //NOLINT (clang-analyzer-core.UndefinedBinaryOperatorResult)
 
     m256 and_mask_m256 = loadu256(and_mask);
     m256 cmp_mask_m256 = loadu256(cmp_mask);
index 9c7bb6fddc2ae06d2e031d81cc08abfdb93ed59f..c2316f9f0416ff3c57e178640ef2e2f4a4a673d0 100644 (file)
@@ -1954,7 +1954,7 @@ bool buildSuffixes(const RoseBuildImpl &tbi, build_context &bc,
     vector<pair<u32, suffix_id>> ordered;
     for (const auto &e : bc.suffixes) {
         // cppcheck-suppress useStlAlgorithm
-        ordered.emplace_back(e.second, e.first);
+        ordered.emplace_back(e.second, e.first); //NOLINT (performance-inefficient-vector-operation)
     }
     sort(begin(ordered), end(ordered));
 
index 01ff8d8849ccd23b4da0ce210835efad9ed14ea1..2c1c7c6aac8cbdfe5bcfcdc86f071022681b527b 100644 (file)
@@ -393,7 +393,7 @@ public:
 
     RoseInstrCheckSingleLookaround(s8 offset_in, CharReach reach_in,
                                    const RoseInstruction *target_in)
-        : offset(offset_in), reach(std::move(reach_in)), target(target_in) {}
+        : offset(offset_in), reach(reach_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckSingleLookaround &ri) const {
         return offset == ri.offset && reach == ri.reach && target == ri.target;
@@ -495,7 +495,7 @@ public:
     RoseInstrCheckMask32(std::array<u8, 32> and_mask_in,
                          std::array<u8, 32> cmp_mask_in, u32 neg_mask_in,
                          s32 offset_in, const RoseInstruction *target_in)
-        : and_mask(std::move(and_mask_in)), cmp_mask(std::move(cmp_mask_in)),
+        : and_mask(and_mask_in), cmp_mask(cmp_mask_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckMask32 &ri) const {
@@ -533,7 +533,7 @@ public:
     RoseInstrCheckMask64(std::array<u8, 64> and_mask_in,
                          std::array<u8, 64> cmp_mask_in, u64a neg_mask_in,
                          s32 offset_in, const RoseInstruction *target_in)
-        : and_mask(std::move(and_mask_in)), cmp_mask(std::move(cmp_mask_in)),
+        : and_mask(and_mask_in), cmp_mask(cmp_mask_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
     bool operator==(const RoseInstrCheckMask64 &ri) const {
         return and_mask == ri.and_mask && cmp_mask == ri.cmp_mask &&
@@ -608,8 +608,8 @@ public:
                              std::array<u8, 16> bucket_select_mask_in,
                              u32 neg_mask_in, s32 offset_in,
                              const RoseInstruction *target_in)
-        : nib_mask(std::move(nib_mask_in)),
-          bucket_select_mask(std::move(bucket_select_mask_in)),
+        : nib_mask(nib_mask_in),
+          bucket_select_mask(bucket_select_mask_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckShufti16x8 &ri) const {
@@ -652,8 +652,8 @@ public:
                              std::array<u8, 32> bucket_select_mask_in,
                              u32 neg_mask_in, s32 offset_in,
                              const RoseInstruction *target_in)
-        : hi_mask(std::move(hi_mask_in)), lo_mask(std::move(lo_mask_in)),
-          bucket_select_mask(std::move(bucket_select_mask_in)),
+        : hi_mask(hi_mask_in), lo_mask(lo_mask_in),
+          bucket_select_mask(bucket_select_mask_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckShufti32x8 &ri) const {
@@ -697,8 +697,8 @@ public:
                               std::array<u8, 32> bucket_select_mask_in,
                               u32 neg_mask_in, s32 offset_in,
                               const RoseInstruction *target_in)
-        : hi_mask(std::move(hi_mask_in)), lo_mask(std::move(lo_mask_in)),
-          bucket_select_mask(std::move(bucket_select_mask_in)),
+        : hi_mask(hi_mask_in), lo_mask(lo_mask_in),
+          bucket_select_mask(bucket_select_mask_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckShufti16x16 &ri) const {
@@ -744,9 +744,9 @@ public:
                               std::array<u8, 32> bucket_select_mask_lo_in,
                               u32 neg_mask_in, s32 offset_in,
                               const RoseInstruction *target_in)
-        : hi_mask(std::move(hi_mask_in)), lo_mask(std::move(lo_mask_in)),
-          bucket_select_mask_hi(std::move(bucket_select_mask_hi_in)),
-          bucket_select_mask_lo(std::move(bucket_select_mask_lo_in)),
+        : hi_mask(hi_mask_in), lo_mask(lo_mask_in),
+          bucket_select_mask_hi(bucket_select_mask_hi_in),
+          bucket_select_mask_lo(bucket_select_mask_lo_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckShufti32x16 &ri) const {
@@ -792,8 +792,8 @@ public:
                              std::array<u8, 64> bucket_select_mask_in,
                              u64a neg_mask_in, s32 offset_in,
                              const RoseInstruction *target_in)
-        : hi_mask(std::move(hi_mask_in)), lo_mask(std::move(lo_mask_in)),
-          bucket_select_mask(std::move(bucket_select_mask_in)),
+        : hi_mask(hi_mask_in), lo_mask(lo_mask_in),
+          bucket_select_mask(bucket_select_mask_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckShufti64x8 &ri) const {
@@ -843,10 +843,10 @@ public:
                               std::array<u8, 64> bucket_select_mask_lo_in,
                               u64a neg_mask_in, s32 offset_in,
                               const RoseInstruction *target_in)
-        : hi_mask_1(std::move(hi_mask_1_in)), hi_mask_2(std::move(hi_mask_2_in)),
-          lo_mask_1(std::move(lo_mask_1_in)), lo_mask_2(std::move(lo_mask_2_in)),
-          bucket_select_mask_hi(std::move(bucket_select_mask_hi_in)),
-          bucket_select_mask_lo(std::move(bucket_select_mask_lo_in)),
+        : hi_mask_1(hi_mask_1_in), hi_mask_2(hi_mask_2_in),
+          lo_mask_1(lo_mask_1_in), lo_mask_2(lo_mask_2_in),
+          bucket_select_mask_hi(bucket_select_mask_hi_in),
+          bucket_select_mask_lo(bucket_select_mask_lo_in),
           neg_mask(neg_mask_in), offset(offset_in), target(target_in) {}
 
     bool operator==(const RoseInstrCheckShufti64x16 &ri) const {
@@ -1978,7 +1978,7 @@ public:
                                  std::array<u8, 16> start_mask_in,
                                  const RoseInstruction *target_in)
         : multi_look(std::move(ml)), last_start(last_start_in),
-          start_mask(std::move(start_mask_in)), target(target_in) {}
+          start_mask(start_mask_in), target(target_in) {}
 
     bool operator==(const RoseInstrMultipathLookaround &ri) const {
         return multi_look == ri.multi_look && last_start == ri.last_start
@@ -2023,9 +2023,9 @@ public:
                                       u16 neg_mask_in, s32 base_offset_in,
                                       s32 last_start_in,
                                       const RoseInstruction *target_in)
-        : nib_mask(std::move(nib_mask_in)),
-          bucket_select_mask(std::move(bucket_select_mask_in)),
-          data_select_mask(std::move(data_select_mask_in)),
+        : nib_mask(nib_mask_in),
+          bucket_select_mask(bucket_select_mask_in),
+          data_select_mask(data_select_mask_in),
           hi_bits_mask(hi_bits_mask_in), lo_bits_mask(lo_bits_mask_in),
           neg_mask(neg_mask_in), base_offset(base_offset_in),
           last_start(last_start_in), target(target_in) {}
@@ -2086,9 +2086,9 @@ public:
                                       u32 neg_mask_in, s32 base_offset_in,
                                       s32 last_start_in,
                                       const RoseInstruction *target_in)
-        : hi_mask(std::move(hi_mask_in)), lo_mask(std::move(lo_mask_in)),
-          bucket_select_mask(std::move(bucket_select_mask_in)),
-          data_select_mask(std::move(data_select_mask_in)),
+        : hi_mask(hi_mask_in), lo_mask(lo_mask_in),
+          bucket_select_mask(bucket_select_mask_in),
+          data_select_mask(data_select_mask_in),
           hi_bits_mask(hi_bits_mask_in), lo_bits_mask(lo_bits_mask_in),
           neg_mask(neg_mask_in), base_offset(base_offset_in),
           last_start(last_start_in), target(target_in) {}
@@ -2151,10 +2151,10 @@ public:
                                        u32 neg_mask_in, s32 base_offset_in,
                                        s32 last_start_in,
                                        const RoseInstruction *target_in)
-        : hi_mask(std::move(hi_mask_in)), lo_mask(std::move(lo_mask_in)),
-          bucket_select_mask_hi(std::move(bucket_select_mask_hi_in)),
-          bucket_select_mask_lo(std::move(bucket_select_mask_lo_in)),
-          data_select_mask(std::move(data_select_mask_in)),
+        : hi_mask(hi_mask_in), lo_mask(lo_mask_in),
+          bucket_select_mask_hi(bucket_select_mask_hi_in),
+          bucket_select_mask_lo(bucket_select_mask_lo_in),
+          data_select_mask(data_select_mask_in),
           hi_bits_mask(hi_bits_mask_in), lo_bits_mask(lo_bits_mask_in),
           neg_mask(neg_mask_in), base_offset(base_offset_in),
           last_start(last_start_in), target(target_in) {}
@@ -2217,9 +2217,9 @@ public:
                                     u64a neg_mask_in, s32 base_offset_in,
                                     s32 last_start_in,
                                     const RoseInstruction *target_in)
-        : hi_mask(std::move(hi_mask_in)), lo_mask(std::move(lo_mask_in)),
-          bucket_select_mask(std::move(bucket_select_mask_in)),
-          data_select_mask(std::move(data_select_mask_in)),
+        : hi_mask(hi_mask_in), lo_mask(lo_mask_in),
+          bucket_select_mask(bucket_select_mask_in),
+          data_select_mask(data_select_mask_in),
           hi_bits_mask(hi_bits_mask_in), lo_bits_mask(lo_bits_mask_in),
           neg_mask(neg_mask_in), base_offset(base_offset_in),
           last_start(last_start_in), target(target_in) {}
index 7c203be5cbffdc55712afb33688b599c80305445..fd7913e2b9bdf99c0619b56de35e0071218e988e 100644 (file)
@@ -466,7 +466,7 @@ void findFloodReach(const RoseBuildImpl &tbi, const RoseVertex v,
 namespace {
 struct LookProto {
     LookProto(s32 offset_in, CharReach reach_in)
-        : offset(offset_in), reach(std::move(reach_in)) {}
+        : offset(offset_in), reach(reach_in) {}
     s32 offset;
     CharReach reach;
 };
index a14eae2d18df3930ecba809a03ac2990645dde7f..a980d14f736282193aef0bc420b5dd54932ef113 100644 (file)
@@ -739,7 +739,7 @@ void addFragmentLiteral(const RoseBuildImpl &build, MatcherProto &mp,
 
     const auto &groups = f.groups;
 
-    mp.lits.emplace_back(std::move(s_final), nocase, noruns, f.fragment_id,
+    mp.lits.emplace_back(s_final, nocase, noruns, f.fragment_id,
                          groups, msk, lcmp);
 }
 
index 37a96c7ad9784ae70ca43a2792c1cc28f6d5cb6d..d4fc3421865698816389cd664c911bd6df948d8f 100644 (file)
@@ -52,11 +52,11 @@ static constexpr u32 INVALID_FRAG_ID = ~0U;
 struct LitFragment {
     LitFragment(u32 fragment_id_in, ue2_literal s_in,
                 rose_group groups_in, u32 lit_id)
-    : fragment_id(fragment_id_in), s(s_in), groups(groups_in),
+    : fragment_id(fragment_id_in), s(std::move(s_in)), groups(groups_in),
       lit_ids({lit_id}) {}
     LitFragment(u32 fragment_id_in, ue2_literal s_in,
                 rose_group groups_in, std::vector<u32> lit_ids_in)
-    : fragment_id(fragment_id_in), s(s_in), groups(groups_in),
+    : fragment_id(fragment_id_in), s(std::move(s_in)), groups(groups_in),
       lit_ids(std::move(lit_ids_in)) {}
     u32 fragment_id;
 
index a157ad27ea6e818b23a5c3e3f2609f61a57866d3..11c7aba364a0cd0e0515f6514c3aff95211069d7 100644 (file)
@@ -100,8 +100,8 @@ RoseProgram::RoseProgram() {
 
 RoseProgram::~RoseProgram() = default;
 
-RoseProgram::RoseProgram(RoseProgram &&) = default;
-RoseProgram &RoseProgram::operator=(RoseProgram &&) = default;
+RoseProgram::RoseProgram(RoseProgram &&) noexcept = default;
+RoseProgram &RoseProgram::operator=(RoseProgram &&) noexcept = default;
 
 bool RoseProgram::empty() const {
     assert(!prog.empty());
index 1882279ddef0460639d71be5676a2754b83fde11..b8323dc810c420415a42725880a0e8083ffd711b 100644 (file)
@@ -57,9 +57,9 @@ public:
     RoseProgram();
     ~RoseProgram();
     RoseProgram(const RoseProgram &) = delete;
-    RoseProgram(RoseProgram &&);
+    RoseProgram(RoseProgram &&) noexcept;
     RoseProgram &operator=(const RoseProgram &) = delete;
-    RoseProgram &operator=(RoseProgram &&);
+    RoseProgram &operator=(RoseProgram &&) noexcept;
 
     bool empty() const;
 
index da0ea08da139c09832f997197505c73c0e682d20..1cfcf3054d731dfd002bfa64db1a09aa7679def4 100644 (file)
@@ -143,7 +143,7 @@ struct RoseInEdgeProps {
     /* haig rosefixes (prefix/infix) require their corresponding holders */
     RoseInEdgeProps(std::shared_ptr<NGHolder> g, std::shared_ptr<raw_som_dfa> h,
                     u32 lag)
-        : minBound(0), maxBound(ROSE_BOUND_INF), graph(g), haig(h),
+        : minBound(0), maxBound(ROSE_BOUND_INF), graph(std::move(g)), haig(std::move(h)),
           graph_lag(lag) {
         assert(graph);
         assert(haig);
@@ -151,12 +151,12 @@ struct RoseInEdgeProps {
 
     /* haig suffixes do not require their corresponding holders */
     explicit RoseInEdgeProps(std::shared_ptr<raw_som_dfa> h)
-        : minBound(0), maxBound(ROSE_BOUND_INF), haig(h), graph_lag(0) {
+        : minBound(0), maxBound(ROSE_BOUND_INF), haig(std::move(h)), graph_lag(0) {
         assert(haig);
     }
 
     RoseInEdgeProps(std::shared_ptr<NGHolder> g, u32 lag)
-        : minBound(0), maxBound(ROSE_BOUND_INF), graph(g), graph_lag(lag) {
+        : minBound(0), maxBound(ROSE_BOUND_INF), graph(std::move(g)), graph_lag(lag) {
         assert(graph);
     }
 
index 7e1fecc7e65adc81a58621a21e372a8302539cb8..8f63da5508b946b2c82a0732285504961a3145fe 100644 (file)
@@ -46,7 +46,7 @@ struct InitialResetEntry {
                       std::shared_ptr<const NGHolder> body_in,
                       const std::unordered_map<NFAVertex, u32> &body_regions_in,
                       u32 sent_region_in, u32 first_bad_region_in)
-        : sent(sent_in), body(body_in), body_regions(body_regions_in),
+        : sent(sent_in), body(std::move(body_in)), body_regions(body_regions_in),
           sent_region(sent_region_in), first_bad_region(first_bad_region_in) {}
 
     std::shared_ptr<const NGHolder> sent;
index b8300dc7575e9e64a503164216ffc3a8ae9a2227..525fb26c6bc96c9c3f8742cb9e58829ce707d90d 100644 (file)
@@ -112,8 +112,8 @@ typedef u32 ReportID;
 
 // Align ptr to next N-byte boundary
 #if defined(HAVE_TYPEOF)
-#define ROUNDUP_PTR(ptr, n)   (__typeof__(ptr))(ROUNDUP_N((uintptr_t)(ptr), (n)))
-#define ROUNDDOWN_PTR(ptr, n) (__typeof__(ptr))(ROUNDDOWN_N((uintptr_t)(ptr), (n)))
+#define ROUNDUP_PTR(ptr, n)   (__typeof__(ptr))(ROUNDUP_N((uintptr_t)(ptr), (n))) //NOLINT (performance-no-int-to-ptr)
+#define ROUNDDOWN_PTR(ptr, n) (__typeof__(ptr))(ROUNDDOWN_N((uintptr_t)(ptr), (n))) //NOLINT (performance-no-int-to-ptr)
 #else
 #define ROUNDUP_PTR(ptr, n)   (void*)(ROUNDUP_N((uintptr_t)(ptr), (n)))
 #define ROUNDDOWN_PTR(ptr, n) (void*)(ROUNDDOWN_N((uintptr_t)(ptr), (n)))
index ab2b9171c5c149fe14b3c62532e20abce9f8ea80..210b06367df468bf4b888239ef5cc6f885ce025b 100644 (file)
@@ -95,7 +95,7 @@ public:
         return p;
     }
 
-    void swap(bytecode_ptr &other) {
+    void swap(bytecode_ptr &other) noexcept {
         using std::swap;
         swap(ptr, other.ptr);
         swap(bytes, other.bytes);
index b3dce4fa966de8789338c46c7af4a4e67def990d..2463f9d1e8ed2d64e7ab59afa590cc53522f9061 100644 (file)
@@ -131,7 +131,7 @@ public:
         data().clear();
     }
 
-    void swap(flat_base &a) {
+    void swap(flat_base &a) noexcept {
         using std::swap;
         swap(comp(), a.comp());
         swap(data(), a.data());
@@ -215,9 +215,9 @@ public:
     }
 
     flat_set(const flat_set &) = default;
-    flat_set(flat_set &&) = default;
+    flat_set(flat_set &&) noexcept = default;
     flat_set &operator=(const flat_set &) = default;
-    flat_set &operator=(flat_set &&) = default;
+    flat_set &operator=(flat_set &&) noexcept = default;
 
     // Iterators.
 
@@ -353,7 +353,7 @@ public:
     }
 
     // Free swap function for ADL.
-    friend void swap(flat_set &a, flat_set &b) {
+    friend void swap(flat_set &a, flat_set &b) noexcept {
         a.swap(b);
     }
 };
@@ -445,9 +445,9 @@ public:
     }
 
     flat_map(const flat_map &) = default;
-    flat_map(flat_map &&) = default;
+    flat_map(flat_map &&) noexcept = default;
     flat_map &operator=(const flat_map &) = default;
-    flat_map &operator=(flat_map &&) = default;
+    flat_map &operator=(flat_map &&) noexcept = default;
 
     // Iterators.
 
@@ -637,7 +637,7 @@ public:
     }
 
     // Free swap function for ADL.
-    friend void swap(flat_map &a, flat_map &b) {
+    friend void swap(flat_map &a, flat_map &b) noexcept {
         a.swap(b);
     }
 };
index 8ba15dcd1dea52bdf0dbd60ef777bfd61abb3be9..0d36b124347a0cefe053c1aa77a707dc150a2cbf 100644 (file)
@@ -178,7 +178,7 @@ public:
         return data < a.data;
     }
 
-    void swap(element_store &a) {
+    void swap(element_store &a) noexcept {
         using std::swap;
         swap(data, a.data);
         swap(map, a.map);
@@ -278,11 +278,11 @@ public:
         return store < a.store;
     }
 
-    void swap(insertion_ordered_map &a) {
+    void swap(insertion_ordered_map &a) noexcept {
         store.swap(a.store);
     }
 
-    friend void swap(insertion_ordered_map &a, insertion_ordered_map &b) {
+    friend void swap(insertion_ordered_map &a, insertion_ordered_map &b) noexcept {
         a.swap(b);
     }
 };
@@ -355,11 +355,11 @@ public:
         return store < a.store;
     }
 
-    void swap(insertion_ordered_set &a) {
+    void swap(insertion_ordered_set &a) noexcept {
         store.swap(a.store);
     }
 
-    friend void swap(insertion_ordered_set &a, insertion_ordered_set &b) {
+    friend void swap(insertion_ordered_set &a, insertion_ordered_set &b) noexcept {
         a.swap(b);
     }
 };
index c3bf77550b7be4d141acffc2ecc84026a52c4994..c58bfd27e1f68ef7c766936d5aa8c09d21c213f1 100644 (file)
@@ -1003,7 +1003,7 @@ public:
 
     ue2_graph() = default;
 
-    ue2_graph(ue2_graph &&old)
+    ue2_graph(ue2_graph &&old) noexcept
     : next_vertex_index(old.next_vertex_index),
       next_edge_index(old.next_edge_index),
       graph_edge_count(old.graph_edge_count),
@@ -1012,7 +1012,7 @@ public:
         swap(vertices_list, old.vertices_list);
     }
 
-    ue2_graph &operator=(ue2_graph &&old) {
+    ue2_graph &operator=(ue2_graph &&old) noexcept {
         next_vertex_index = old.next_vertex_index;
         next_edge_index = old.next_edge_index;
         graph_edge_count = old.graph_edge_count;
index f436936d710b9a7301ba2784d43b2cfe60af3798..dfa2d9e369801a40b37c65c163e79ed6a1e57673 100644 (file)
@@ -147,7 +147,7 @@ public:
     ue2_literal(const ue2_literal &) = default;
     ue2_literal(ue2_literal &&) = default;
     ue2_literal &operator=(const ue2_literal &) = default;
-    ue2_literal &operator=(ue2_literal &&) = default;
+    ue2_literal &operator=(ue2_literal &&) noexcept = default;
 
     template<typename InputIt>
     ue2_literal(InputIt b, InputIt e) {
@@ -204,7 +204,7 @@ public:
 
     const std::string &get_string() const { return s; }
 
-    void swap(ue2_literal &other) {
+    void swap(ue2_literal &other) noexcept {
         s.swap(other.s);
         nocase.swap(other.nocase);
     }
index e2dd351a6260d2528e3d0aa45b2d025b362f0941..03f7efb3765351a47a1a35104b1828e200db7a46 100644 (file)
@@ -130,7 +130,7 @@ public:
         return INVALID_UNICODE;
     }
 
-    void swap(CodePointSet &other) { impl.swap(other.impl); }
+    void swap(CodePointSet &other) noexcept { impl.swap(other.impl); }
 
 private:
     implT impl;
index 331938df1ec9394e7467fc89e751f158bcb26e79..66a208787b0ff1ba4fd62d3dcab6448bf3b26152 100644 (file)
@@ -90,7 +90,7 @@ hs_database_t *get_huge(hs_database_t *db) {
     }
 
     shmaddr = shmat(hsdb_shmid, nullptr, SHM_RND);
-    if (shmaddr == (char *)-1) {
+    if (shmaddr == (char *)-1) {                //NOLINT (performance-no-int-to-ptr)
         perror("Shared memory attach failure");
         goto fini;
     }
index 918fe7854aff398fa76773059b0123ff5555945f..373ce38891cb70c50ddb98cb574bd78ef81494cf 100644 (file)
@@ -98,7 +98,7 @@ unsigned int countFailures = 0;
 class ParsedExpr {
 public:
     ParsedExpr(string regex_in, unsigned int flags_in, const hs_expr_ext& ext_in)
-        : regex(regex_in), flags(flags_in), ext(ext_in) {}
+        : regex(std::move(regex_in)), flags(flags_in), ext(ext_in) {}
     ~ParsedExpr() {}
     string regex;
     unsigned int flags;
@@ -308,7 +308,7 @@ void checkExpression(UNUSED void *threadarg) {
                 ch_free_compile_error(ch_compile_err);
             }
 #else
-            cerr << "Hybrid mode not available in this build." << endl;
+            cerr << "Hybrid mode not available in this build.\n";
             exit(1);
 #endif // HS_HYBRID
         } else {
@@ -468,26 +468,25 @@ void checkLogicalExpression(UNUSED void *threadarg) {
 static
 void usage() {
     cout << "Usage: hscheck [OPTIONS...]"  << endl << endl
-         << "  -e PATH         Path to expression directory." << endl
-         << "  -s FILE         Signature file to use." << endl
-         << "  -z NUM          Signature ID to use." << endl
-         << "  -E DISTANCE     Force edit distance to DISTANCE for all patterns." << endl
+         << "  -e PATH         Path to expression directory.\n"
+         << "  -s FILE         Signature file to use.\n"
+         << "  -z NUM          Signature ID to use.\n"
+         << "  -E DISTANCE     Force edit distance to DISTANCE for all patterns.\n"
 #ifndef RELEASE_BUILD
-         << "  -G OVERRIDES    Overrides for the grey." << endl
+         << "  -G OVERRIDES    Overrides for the grey.\n"
 #endif
-         << "  -V              Operate in vectored mode." << endl
-         << "  -N              Operate in block mode (default: streaming)." << endl
+         << "  -V              Operate in vectored mode.\n"
+         << "  -N              Operate in block mode (default: streaming).\n"
 #ifdef HS_HYBRID
-         << "  -H              Operate in hybrid mode." << endl
+         << "  -H              Operate in hybrid mode.\n"
 #endif
-         << "  -L              Pass HS_FLAG_SOM_LEFTMOST for all expressions (default: off)." << endl
-         << "  -8              Force UTF8 mode on all patterns." << endl
-         << "  -T NUM          Run with NUM threads." << endl
-         << "  -h              Display this help." << endl
-         << "  -B              Build signature set." << endl
-         << "  -C              Check logical combinations (default: off)." << endl
-         << "  --literal-on    Processing pure literals, no need to check." << endl
-         << endl;
+         << "  -L              Pass HS_FLAG_SOM_LEFTMOST for all expressions (default: off).\n"
+         << "  -8              Force UTF8 mode on all patterns.\n"
+         << "  -T NUM          Run with NUM threads.\n"
+         << "  -h              Display this help.\n"
+         << "  -B              Build signature set.\n"
+         << "  -C              Check logical combinations (default: off).\n"
+         << "  --literal-on    Processing pure literals, no need to check.\n\n";
 }
 
 static
@@ -599,7 +598,7 @@ void failLine(unsigned lineNum, const string &file,
               const string &line, const string &error) {
     cerr << "Parse error in file " << file
         << " on line " << lineNum << ": " << error
-        << endl << "Line is: '" << line << "'" << endl;
+        << endl << "Line is: '" << line << "'\n";
     exit(1);
 }
 
@@ -612,7 +611,7 @@ void loadSignatureBuildSigs(const string &inFile,
                        SignatureSet &signatures) {
     ifstream f(inFile.c_str());
     if (!f.good()) {
-        cerr << "Can't open file: '" << inFile << "'" << endl;
+        cerr << "Can't open file: '" << inFile << "'\n";
         exit(1);
     }
 
@@ -665,7 +664,7 @@ int HS_CDECL main(int argc, char **argv) {
     processArgs(argc, argv, g_grey);
 
     if (num_of_threads == 0) {
-        cout << "Error: Must have at least one thread." << endl;
+        cout << "Error: Must have at least one thread.\n";
         exit(1);
     }
 
@@ -687,7 +686,7 @@ int HS_CDECL main(int argc, char **argv) {
     }
 
     if (g_exprMap.empty()) {
-        cout << "Warning: no signatures to scan. Exiting." << endl;
+        cout << "Warning: no signatures to scan. Exiting.\n";
         exit(0);
     }
 
@@ -717,7 +716,7 @@ int HS_CDECL main(int argc, char **argv) {
 
     if (!g_exprMap.empty() && !build_sigs) {
         cout << "SUMMARY: " << countFailures << " of "
-             << g_exprMap.size() << " failed." << endl;
+             << g_exprMap.size() << " failed.\n";
     }
     return 0;
 }
index 0364b93ad49b8528ad9be2b6deb8623490411021..9ef335171dfb649c6e87002707c8aefc4bcc3bca 100644 (file)
@@ -337,7 +337,9 @@ void clearDir(const string &path) {
         if (name == "." || name == "..") {
             continue;
         }
-        string f = path + '/' + name;
+        string f = path;
+        f += '/';
+        f += name;
         if (unlink(f.c_str()) < 0) {
             printf("ERROR: couldn't remove file %s: %s\n", f.c_str(),
                    strerror(errno));
index 42e4772e799caea72b8fd3d55337d91cb2cf126f..750ccace1655e07ff2dad34cc22a214f10507761 100644 (file)
@@ -324,7 +324,7 @@ vector<BadPatternParam> getBadPatterns() {
         string regex;
         hs_expr_ext ext;
         if (!readExpression(expr, regex, &flags, &ext)) {
-            cerr << expr << " failed in readExpression" << endl;
+            cerr << expr << " failed in readExpression\n";
             abort();
         }
         rv.push_back(BadPatternParam(regex, flags, ext, error));
index 01fdca0b2c9251b1fb14c653207c3d4e73b36e10..87a8f1aaee23251d2e634c281255f76ed2ed64e8 100644 (file)
@@ -91,9 +91,9 @@ struct pattern {
     }
 
     pattern(std::string expression_in, unsigned int flags_in,
-            unsigned int id_in, hs_expr_ext ext_in)
+            unsigned int id_in,const hs_expr_ext& ext_in)
         : expression(std::move(expression_in)), flags(flags_in), id(id_in),
-          ext(std::move(ext_in)) {}
+          ext(ext_in) {}
 };
 
 std::ostream &operator<<(std::ostream &o, const pattern &p);
index 7431d55f9c8a80716f27ef7b740d46ec1719c37c..9f071905463d843f96335cc6a9d195d9b21b06a7 100644 (file)
@@ -55,7 +55,7 @@ unique_ptr<hs_platform_info> xcompileReadMode(const char *s) {
     assert(!err);
 
     string str(s);
-    string opt = str.substr(str.find(":")+1, str.npos);
+    string opt = str.substr(str.find(':')+1, str.npos);
     bool found_mode = false;
 
     if (!opt.empty()) {
index dbad75618e9e068d9174fb36b2f8f8625eb40fee..01c49d7b4ac7f2c9f8cef2e76351fee8d2eabf6a 100644 (file)
@@ -96,7 +96,7 @@ hs_database_t * loadDatabase(const char *filename, bool verbose) {
 
     bytes = reinterpret_cast<char *>(mmap(nullptr, len, PROT_READ, MAP_SHARED, fd, 0));
     if (bytes == MAP_FAILED) {
-        cout << "mmap failed" << endl;
+        cout << "mmap failed\n";
         close(fd);
         return nullptr;
     }
@@ -110,7 +110,7 @@ hs_database_t * loadDatabase(const char *filename, bool verbose) {
     is.seekg(0, ios::end);
     size_t len = is.tellg();
     if (verbose) {
-        cout << "Reading " << len << " bytes" << endl;
+        cout << "Reading " << len << " bytes\n";
     }
     is.seekg(0, ios::beg);
     bytes = new char[len];
@@ -130,7 +130,7 @@ hs_database_t * loadDatabase(const char *filename, bool verbose) {
             cout << "Serialized database info: " << info << endl;
             std::free(info);
         } else {
-            cout << "Unable to decode serialized database info." << endl;
+            cout << "Unable to decode serialized database info.\n";
         }
     }
 
index 74bf4ba21a87cc7a8a823c4b56bfcdb261e889aa..e15cc2a19edf0a0f98ff654a9c0255ee987ae18d 100644 (file)
@@ -53,7 +53,7 @@ void failLine(unsigned lineNum, const string &file,
               const string &line, const string &error) {
     cerr << "Parse error in file " << file
         << " on line " << lineNum << ": " << error
-        << endl << "Line is: '" << line << "'" << endl;
+        << endl << "Line is: '" << line << "'\n";
     exit(1);
 }
 
@@ -137,7 +137,7 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
     // Is our input path a file or a directory?
     struct stat st;
     if (stat(inPath.c_str(), &st) != 0) {
-        cerr << "Can't stat path: '" << inPath << "'" << endl;
+        cerr << "Can't stat path: '" << inPath << "'\n";
         exit(1);
     }
     if (S_ISREG(st.st_mode)) {
@@ -145,13 +145,13 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
         try {
             loadExpressionsFromFile(inPath, exprMap);
         } catch (runtime_error &e) {
-            cerr << e.what() << ": '" << inPath << "'" << endl;
+            cerr << e.what() << ": '" << inPath << "'\n";
             exit(1);
         }
     } else if (S_ISDIR(st.st_mode)) {
         DIR *d = opendir(inPath.c_str());
         if (d == nullptr) {
-            cerr << "Can't open directory: '" << inPath << "'" << endl;
+            cerr << "Can't open directory: '" << inPath << "'\n";
             exit(1);
         }
         for (struct dirent *ent = readdir(d); ent; ent = readdir(d)) {
@@ -174,7 +174,7 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
             try {
                 loadExpressionsFromFile(fname, exprMap);
             } catch (runtime_error &e) {
-                cerr << e.what() << ": '" << fname << "'" << endl;
+                cerr << e.what() << ": '" << fname << "'\n";
                 exit(1);
             }
         }
@@ -182,7 +182,7 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
     } else {
         cerr << "Unsupported file type "
            << hex << showbase << (st.st_mode & S_IFMT)
-           << " for path: '" << inPath << "'" << endl;
+           << " for path: '" << inPath << "'\n";
         exit(1);
     }
 }
@@ -191,7 +191,7 @@ void HS_CDECL loadSignatureList(const string &inFile,
                                 SignatureSet &signatures) {
     ifstream f(inFile.c_str());
     if (!f.good()) {
-        cerr << "Can't open file: '" << inFile << "'" << endl;
+        cerr << "Can't open file: '" << inFile << "'\n";
         exit(1);
     }
 
@@ -223,7 +223,7 @@ ExpressionMap limitToSignatures(const ExpressionMap &exprMap,
         auto match = exprMap.find(id);
         if (match == exprMap.end()) {
             cerr << "Unable to find signature " << id
-                    << " in expression set!" << endl;
+                    << " in expression set!\n";
             exit(1);
         }
         keepers.insert(*match);
index cd84a9abdca9aea3b328320032a85ca1a57df804..0d73cedb99978744c1df8c4da9550866666e3825 100644 (file)
@@ -48,7 +48,7 @@ class NGHolder;
 
 struct CorpusGenerationFailure {
     explicit CorpusGenerationFailure(const std::string& s) :
-        message(std::move(s)) {}
+        message(s) {}
     std::string message;
 };