1
0

Fixed style and removed false positives

Relaxed the rules for < followed by an && and removed rule for < following an &&
This commit is contained in:
tycho 2015-03-11 10:39:49 +00:00
parent ff785188f9
commit 8646e95b6f
2 changed files with 12 additions and 7 deletions

View File

@ -101,9 +101,9 @@ local g_ViolationPatterns =
{"&&[^(]+!=", "Add parenthesis around comparison"},
{"!=[^)]+||", "Add parenthesis around comparison"},
{"||[^(]+!=", "Add parenthesis around comparison"},
{"<[^)T][^)]*&&", "Add parenthesis around comparison"}, -- Must take special care of templates: "template <T> fn(Args && ...)"
{"&&[^(]+<", "Add parenthesis around comparison"},
{"<[^)T][^)]*||", "Add parenthesis around comparison"}, -- Must take special care of templates: "template <T> fn(Args && ...)"
{"<[^)>]*&&", "Add parenthesis around comparison"}, -- Must take special care of templates: "template <T> fn(Args && ...)"
-- Cannot check a < following a && due to functions of the form x fn(y&& a, z<b> c)
{"<[^)>]*||", "Add parenthesis around comparison"}, -- Must take special care of templates: "template <T> fn(Args && ...)"
{"||[^(]+<", "Add parenthesis around comparison"},
-- Cannot check ">" because of "obj->m_Flag &&". Check at least ">=":
{">=[^)]+&&", "Add parenthesis around comparison"},

View File

@ -73,13 +73,18 @@ public:
// Code adapted from http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
template<int ...>
struct seq { };
struct seq
{
};
template<int N, int ...S>
struct gens : gens<N-1, N-1, S...> { };
struct gens : gens<N-1, N-1, S...>
{
};
template<int ...S>
struct gens<0, S...> {
struct gens<0, S...>
{
typedef seq<S...> type;
};