From cbd115f7fef451be3650d847eccbcef0e8bf398a Mon Sep 17 00:00:00 2001 From: Matthew Barr Date: Mon, 25 Jul 2016 15:33:40 +1000 Subject: [PATCH] Don't shadow names --- CMakeLists.txt | 2 +- src/fdr/fdr_streaming_compile.cpp | 6 +-- src/fdr/teddy_compile.cpp | 4 +- src/nfa/goughcompile.cpp | 4 +- src/nfa/multiaccel_compilehelper.cpp | 8 +-- src/nfagraph/ng_violet.cpp | 8 +-- src/parser/Parser.rl | 14 ++--- src/rose/rose_build_add.cpp | 1 - src/rose/rose_build_bytecode.cpp | 6 +-- src/rose/rose_build_compile.cpp | 4 +- src/rose/rose_build_matchers.cpp | 4 +- unit/internal/shufti.cpp | 80 ++++++++++++++-------------- 12 files changed, 70 insertions(+), 71 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e748e955..e1f27562 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,7 +174,7 @@ else() # set compiler flags - more are tested and added later set(EXTRA_C_FLAGS "-std=c99 -Wall -Wextra -Wshadow -Wcast-qual -fno-strict-aliasing") - set(EXTRA_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wno-shadow -Wswitch -Wreturn-type -Wcast-qual -Wno-deprecated -Wnon-virtual-dtor -fno-strict-aliasing") + set(EXTRA_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wshadow -Wswitch -Wreturn-type -Wcast-qual -Wno-deprecated -Wnon-virtual-dtor -fno-strict-aliasing") if (NOT RELEASE_BUILD) # -Werror is most useful during development, don't potentially break # release builds diff --git a/src/fdr/fdr_streaming_compile.cpp b/src/fdr/fdr_streaming_compile.cpp index f3001743..f84e3ad6 100644 --- a/src/fdr/fdr_streaming_compile.cpp +++ b/src/fdr/fdr_streaming_compile.cpp @@ -195,18 +195,18 @@ struct OffsetIDFromEndOrder { static void fillHashes(const vector &long_lits, size_t max_len, - FDRSHashEntry *tab, size_t numEntries, MODES m, + FDRSHashEntry *tab, size_t numEntries, MODES mode, map &litToOffsetVal) { const u32 nbits = lg2(numEntries); map > > bucketToLitOffPairs; map bucketToBitfield; for (const auto &lit : long_lits) { - if ((m == CASELESS) != lit.nocase) { + if ((mode == CASELESS) != lit.nocase) { continue; } for (u32 j = 1; j < lit.s.size() - max_len + 1; j++) { - u32 h = hashLit(lit, j, max_len, m); + u32 h = hashLit(lit, j, max_len, mode); u32 h_ent = h & ((1U << nbits) - 1); u32 h_low = (h >> nbits) & 63; bucketToLitOffPairs[h_ent].emplace_back(lit.id, j); diff --git a/src/fdr/teddy_compile.cpp b/src/fdr/teddy_compile.cpp index 729c9c1f..15b9665b 100644 --- a/src/fdr/teddy_compile.cpp +++ b/src/fdr/teddy_compile.cpp @@ -266,9 +266,9 @@ bool TeddyCompiler::pack(map &accel_info) - : mcclellan_build_strat(r, rm), rdfa(r), gg(g), + : mcclellan_build_strat(r, rm_in), rdfa(r), gg(g), accel_gough_info(accel_info) {} unique_ptr gatherReports(vector &reports /* out */, vector &reports_eod /* out */, diff --git a/src/nfa/multiaccel_compilehelper.cpp b/src/nfa/multiaccel_compilehelper.cpp index f1cf2a4c..4c1f8101 100644 --- a/src/nfa/multiaccel_compilehelper.cpp +++ b/src/nfa/multiaccel_compilehelper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Intel Corporation + * Copyright (c) 2015-2016, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -347,9 +347,9 @@ void match(accel_data &d, const CharReach &ref_cr, const CharReach &cur_cr) { } } -MultiaccelCompileHelper::MultiaccelCompileHelper(const CharReach &ref_cr, u32 off, - unsigned max_len) : - cr(ref_cr), offset(off), max_len(max_len) { +MultiaccelCompileHelper::MultiaccelCompileHelper(const CharReach &ref_cr, + u32 off, unsigned max_length) + : cr(ref_cr), offset(off), max_len(max_length) { int accel_num = (int) MultibyteAccelInfo::MAT_MAX; accels.resize(accel_num); diff --git a/src/nfagraph/ng_violet.cpp b/src/nfagraph/ng_violet.cpp index 27f58d0a..e806d5c7 100644 --- a/src/nfagraph/ng_violet.cpp +++ b/src/nfagraph/ng_violet.cpp @@ -1880,15 +1880,15 @@ bool improvePrefix(NGHolder &h, RoseInGraph &vg, const vector &ee, trimmed.clear(); for (auto &elem : trimmed_vec) { shared_ptr &hp = elem.first; - NGHolder &h = *hp; + NGHolder &eh = *hp; vector base_states; insert(&base_states, base_states.end(), - inv_adjacent_vertices(h.accept, h)); - clear_in_edges(h.accept, h); + inv_adjacent_vertices(eh.accept, eh)); + clear_in_edges(eh.accept, eh); for (auto v : base_states) { - h[v].reports.clear(); /* clear report from old accepts */ + eh[v].reports.clear(); /* clear report from old accepts */ } for (const auto &edge_delay : elem.second) { diff --git a/src/parser/Parser.rl b/src/parser/Parser.rl index 65cd7c1a..9bd4d96d 100644 --- a/src/parser/Parser.rl +++ b/src/parser/Parser.rl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Intel Corporation + * Copyright (c) 2015-2016, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -1447,12 +1447,12 @@ unichar readUtf8CodePoint4c(const u8 *ts) { // Otherwise, we interpret the first three digits as an // octal escape, and the remaining characters stand for // themselves as literals. - const u8 *p = ts; + const u8 *s = ts; unsigned int accum = 0; unsigned int oct_digits = 0; - assert(*p == '\\'); // token starts at backslash - for (++p; p < te && oct_digits < 3; ++oct_digits, ++p) { - u8 digit = *p - '0'; + assert(*s == '\\'); // token starts at backslash + for (++s; s < te && oct_digits < 3; ++oct_digits, ++s) { + u8 digit = *s - '0'; if (digit < 8) { accum = digit + accum * 8; } else { @@ -1465,8 +1465,8 @@ unichar readUtf8CodePoint4c(const u8 *ts) { } // And then the rest of the digits, if any, are literal. - for (; p < te; ++p) { - addLiteral(currentSeq, *p, mode); + for (; s < te; ++s) { + addLiteral(currentSeq, *s, mode); } } }; diff --git a/src/rose/rose_build_add.cpp b/src/rose/rose_build_add.cpp index 18968e10..0f0e8d18 100644 --- a/src/rose/rose_build_add.cpp +++ b/src/rose/rose_build_add.cpp @@ -709,7 +709,6 @@ void makeEodEventLeftfix(RoseBuildImpl &build, RoseVertex u, g[v].literals.insert(eod_event); build.literal_info[eod_event].vertices.insert(v); - map > report_remap; g[v].left.graph = eod_leftfix; g[v].left.leftfix_report = report_mapping.second; g[v].left.lag = 0; diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index 6eb42d4c..085aca79 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -4906,11 +4906,11 @@ void addEodAnchorProgram(RoseBuildImpl &build, build_context &bc, assert(contains(bc.roleStateIndices, u)); u32 predStateIdx = bc.roleStateIndices.at(u); - auto program = makeEodAnchorProgram(build, bc, e, multiple_preds); - if (program.empty()) { + auto prog = makeEodAnchorProgram(build, bc, e, multiple_preds); + if (prog.empty()) { continue; } - predProgramLists[predStateIdx].push_back(program); + predProgramLists[predStateIdx].push_back(prog); } } diff --git a/src/rose/rose_build_compile.cpp b/src/rose/rose_build_compile.cpp index d327193f..8545ca70 100644 --- a/src/rose/rose_build_compile.cpp +++ b/src/rose/rose_build_compile.cpp @@ -511,8 +511,8 @@ bool RoseBuildImpl::isDirectReport(u32 id) const { } // Use the program to handle cases that aren't external reports. - for (const ReportID &id : g[v].reports) { - if (!isExternalReport(rm.getReport(id))) { + for (const ReportID &rid : g[v].reports) { + if (!isExternalReport(rm.getReport(rid))) { return false; } } diff --git a/src/rose/rose_build_matchers.cpp b/src/rose/rose_build_matchers.cpp index 7b20bd1c..2eb70f60 100644 --- a/src/rose/rose_build_matchers.cpp +++ b/src/rose/rose_build_matchers.cpp @@ -416,8 +416,8 @@ bool isDirectHighlander(const RoseBuildImpl &build, const u32 id, return false; } - auto is_simple_exhaustible = [&build](ReportID id) { - const Report &report = build.rm.getReport(id); + auto is_simple_exhaustible = [&build](ReportID rid) { + const Report &report = build.rm.getReport(rid); return isSimpleExhaustible(report); }; diff --git a/unit/internal/shufti.cpp b/unit/internal/shufti.cpp index b8d77d37..81495a9c 100644 --- a/unit/internal/shufti.cpp +++ b/unit/internal/shufti.cpp @@ -283,9 +283,9 @@ TEST(DoubleShufti, BuildMask1) { lits.insert(make_pair('a', 'B')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, &lo2m, &hi2m); - ASSERT_TRUE(rv); + ASSERT_TRUE(ret); u8 *lo1 = (u8 *)&lo1m; u8 *lo2 = (u8 *)&lo2m; @@ -326,9 +326,9 @@ TEST(DoubleShufti, BuildMask2) { lits.insert(make_pair('a','z')); lits.insert(make_pair('B','z')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, &lo2m, &hi2m); - ASSERT_TRUE(rv); + ASSERT_TRUE(ret); u8 *lo1 = (u8 *)&lo1m; u8 *lo2 = (u8 *)&lo2m; @@ -354,9 +354,9 @@ TEST(DoubleShufti, BuildMask4) { lits.insert(make_pair('A','z')); lits.insert(make_pair('b','z')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, &lo2m, &hi2m); - ASSERT_TRUE(rv); + ASSERT_TRUE(ret); u8 *lo1 = (u8 *)&lo1m; u8 *lo2 = (u8 *)&lo2m; @@ -383,9 +383,9 @@ TEST(DoubleShufti, BuildMask5) { CharReach bytes; bytes.set('X'); - bool rv = shuftiBuildDoubleMasks(bytes, lits, &lo1m, &hi1m, + bool ret = shuftiBuildDoubleMasks(bytes, lits, &lo1m, &hi1m, &lo2m, &hi2m); - ASSERT_TRUE(rv); + ASSERT_TRUE(ret); u8 *lo1 = (u8 *)&lo1m; u8 *lo2 = (u8 *)&lo2m; @@ -421,9 +421,9 @@ TEST(DoubleShufti, BuildMask6) { lits.insert(make_pair('A','x')); lits.insert(make_pair('b','x')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1m, &hi1m, &lo2m, &hi2m); - ASSERT_TRUE(rv); + ASSERT_TRUE(ret); u8 *lo1 = (u8 *)&lo1m; u8 *lo2 = (u8 *)&lo2m; @@ -485,9 +485,9 @@ TEST(DoubleShufti, ExecNoMatch1) { lits.insert(make_pair('a','b')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + ASSERT_TRUE(ret); char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; @@ -506,8 +506,8 @@ TEST(DoubleShufti, ExecNoMatch1b) { lits.insert(make_pair('b','a')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; @@ -527,8 +527,8 @@ TEST(DoubleShufti, ExecNoMatch2) { lits.insert(make_pair('a','b')); lits.insert(make_pair('B','b')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; @@ -548,8 +548,8 @@ TEST(DoubleShufti, ExecNoMatch2b) { lits.insert(make_pair('b','a')); lits.insert(make_pair('b','B')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; @@ -568,8 +568,8 @@ TEST(DoubleShufti, ExecNoMatch3) { lits.insert(make_pair('V','e')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; @@ -588,8 +588,8 @@ TEST(DoubleShufti, ExecNoMatch3b) { lits.insert(make_pair('e','V')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; @@ -608,8 +608,8 @@ TEST(DoubleShufti, ExecMatch1) { lits.insert(make_pair('a','b')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); /* 0123456789012345678901234567890 */ char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbb"; @@ -629,8 +629,8 @@ TEST(DoubleShufti, ExecMatch2) { lits.insert(make_pair('a','a')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); /* 0123456789012345678901234567890 */ char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb"; @@ -651,8 +651,8 @@ TEST(DoubleShufti, ExecMatch3) { lits.insert(make_pair('B','a')); lits.insert(make_pair('a','a')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); /* 0123456789012345678901234567890 */ char t1[] = "bbbbbbbbbbbbbbbbbBaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb"; @@ -675,8 +675,8 @@ TEST(DoubleShufti, ExecMatch4) { lits.insert(make_pair('C','a')); lits.insert(make_pair('c','a')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); /* 0123456789012345678901234567890 */ char t1[] = "bbbbbbbbbbbbbbbbbAaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb"; @@ -717,8 +717,8 @@ TEST(DoubleShufti, ExecMatch4b) { lits.insert(make_pair('a','C')); lits.insert(make_pair('a','c')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); /* 0123456789012345678901234567890 */ char t1[] = "bbbbbbbbbbbbbbbbbaAaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb"; @@ -756,8 +756,8 @@ TEST(DoubleShufti, ExecMatch5) { lits.insert(make_pair('a','A')); - bool rv = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(CharReach(), lits, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; @@ -780,8 +780,8 @@ TEST(DoubleShufti, ExecMatchMixed1) { // just one one-byte literal onebyte.set('a'); - bool rv = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; @@ -804,8 +804,8 @@ TEST(DoubleShufti, ExecMatchMixed2) { onebyte.set('a'); twobyte.insert(make_pair('x', 'y')); - bool rv = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; char t2[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; @@ -838,8 +838,8 @@ TEST(DoubleShufti, ExecMatchMixed3) { onebyte.set('a'); twobyte.insert(make_pair('x', 'y')); - bool rv = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2); - ASSERT_TRUE(rv); + bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, &lo1, &hi1, &lo2, &hi2); + ASSERT_TRUE(ret); const int len = 420; char t1[len + 1];