Commit 487447a5 authored by Paul's avatar Paul
Browse files

Some more improvements to checkers

parent 9e405e27
...@@ -202,7 +202,7 @@ def LambdaAttribute(cfg, data): ...@@ -202,7 +202,7 @@ def LambdaAttribute(cfg, data):
for token in cfg.tokenlist: for token in cfg.tokenlist:
if token.str != ']': if token.str != ']':
continue continue
if not match(token, "] __device__|__host__ {|{}}"): if not match(token, "] __device__|__host__ {|("):
continue continue
cppcheck.reportError( cppcheck.reportError(
token, "style", token, "style",
...@@ -238,6 +238,8 @@ def MutableVariable(cfg, data): ...@@ -238,6 +238,8 @@ def MutableVariable(cfg, data):
@cppcheck.checker @cppcheck.checker
def NestedBlocks(cfg, data): def NestedBlocks(cfg, data):
for token in cfg.tokenlist: for token in cfg.tokenlist:
if not token.str in ['if', 'while', 'for', 'switch']:
continue
block = match(token, "if|while|for|switch (*) { {*}@block }").block block = match(token, "if|while|for|switch (*) { {*}@block }").block
if not block: if not block:
block = match(token, "; { {*}@block break ; }").block block = match(token, "; { {*}@block break ; }").block
...@@ -249,6 +251,8 @@ def NestedBlocks(cfg, data): ...@@ -249,6 +251,8 @@ def NestedBlocks(cfg, data):
@cppcheck.checker @cppcheck.checker
def RedundantCast(cfg, data): def RedundantCast(cfg, data):
for token in cfg.tokenlist: for token in cfg.tokenlist:
if not token.variable:
continue
m = match(token, m = match(token,
"%var%@decl ; %var%@assign = static_cast <*>@cast (*) ;") "%var%@decl ; %var%@assign = static_cast <*>@cast (*) ;")
if not m: if not m:
...@@ -289,6 +293,8 @@ def RedundantIfStatement(cfg, data): ...@@ -289,6 +293,8 @@ def RedundantIfStatement(cfg, data):
@cppcheck.checker @cppcheck.checker
def RedundantLocalVariable(cfg, data): def RedundantLocalVariable(cfg, data):
for token in cfg.tokenlist: for token in cfg.tokenlist:
if not token.variable:
continue
m = match(token, m = match(token,
"%var%@decl ; %var%@assign = **; return %var%@returned ;") "%var%@decl ; %var%@assign = **; return %var%@returned ;")
if not m: if not m:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment