#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
// 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);
}
}
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;
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);
}
}
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);
}
}
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);
}
}
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);
}
}
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
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;
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;
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);
}
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());
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
case '\r': // stray carriage-return
break;
default:
- cerr << "Unsupported flag \'" << c << "\'" << endl;
+ cerr << "Unsupported flag \'" << c << "\'\n";
exit(-1);
}
}
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);
}
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);
}
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()
/* 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;
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);
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);
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);
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);
}
}
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",
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",
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);
}
}
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);
}
}
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);
}
}
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);
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);
}
}
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);
}
}
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);
}
}
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);
}
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) {
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);
}
/* 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;
}
}
}
/* 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;
}
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)) {
}
/* 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;
}
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);
}
DEBUG_PRINTF("worse\n");
continue;
}
- priority_path.emplace_back(std::move(as));
+ priority_path.emplace_back(as);
}
sort(priority_path.begin(), priority_path.end());
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);
}
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;
}
}
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
};
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);
}
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;
};
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);
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));
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;
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 {
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 &&
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 {
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 {
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 {
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 {
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 {
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 {
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
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) {}
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) {}
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) {}
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) {}
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;
};
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);
}
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;
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());
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;
/* 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);
/* 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);
}
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;
// 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)))
return p;
}
- void swap(bytecode_ptr &other) {
+ void swap(bytecode_ptr &other) noexcept {
using std::swap;
swap(ptr, other.ptr);
swap(bytes, other.bytes);
data().clear();
}
- void swap(flat_base &a) {
+ void swap(flat_base &a) noexcept {
using std::swap;
swap(comp(), a.comp());
swap(data(), a.data());
}
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.
}
// 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);
}
};
}
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.
}
// 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);
}
};
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);
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);
}
};
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);
}
};
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),
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;
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) {
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);
}
return INVALID_UNICODE;
}
- void swap(CodePointSet &other) { impl.swap(other.impl); }
+ void swap(CodePointSet &other) noexcept { impl.swap(other.impl); }
private:
implT impl;
}
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;
}
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;
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 {
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
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);
}
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);
}
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);
}
}
if (g_exprMap.empty()) {
- cout << "Warning: no signatures to scan. Exiting." << endl;
+ cout << "Warning: no signatures to scan. Exiting.\n";
exit(0);
}
if (!g_exprMap.empty() && !build_sigs) {
cout << "SUMMARY: " << countFailures << " of "
- << g_exprMap.size() << " failed." << endl;
+ << g_exprMap.size() << " failed.\n";
}
return 0;
}
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));
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));
}
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);
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()) {
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;
}
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];
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";
}
}
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);
}
// 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)) {
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)) {
try {
loadExpressionsFromFile(fname, exprMap);
} catch (runtime_error &e) {
- cerr << e.what() << ": '" << fname << "'" << endl;
+ cerr << e.what() << ": '" << fname << "'\n";
exit(1);
}
}
} else {
cerr << "Unsupported file type "
<< hex << showbase << (st.st_mode & S_IFMT)
- << " for path: '" << inPath << "'" << endl;
+ << " for path: '" << inPath << "'\n";
exit(1);
}
}
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);
}
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);
struct CorpusGenerationFailure {
explicit CorpusGenerationFailure(const std::string& s) :
- message(std::move(s)) {}
+ message(s) {}
std::string message;
};