Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
e36567a3
Commit
e36567a3
authored
Sep 30, 2018
by
Paul
Browse files
Merge branch 'cppchecks'
parents
1682b223
7dc3d1bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
210 additions
and
6 deletions
+210
-6
cppcheck.rules
cppcheck.rules
+207
-0
src/opt/memory_coloring_impl.hpp
src/opt/memory_coloring_impl.hpp
+2
-2
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+1
-4
No files found.
cppcheck.rules
View file @
e36567a3
...
@@ -90,3 +90,210 @@
...
@@ -90,3 +90,210 @@
<summary>
Double negative is always positive
</summary>
<summary>
Double negative is always positive
</summary>
</message>
</message>
</rule>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[if \( \w+ (\||&) \w+ \)]]>
</pattern>
<message>
<id>
BitwiseOperatorInConditional
</id>
<severity>
style
</severity>
<summary>
Bitwise operator found in if statement.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[if \( [^)]+ \) { if \( [^)]+ \) ({[^{}]*(?1)*[^{}]*}) }]]>
</pattern>
<message>
<id>
CollapsibleIfStatements
</id>
<severity>
style
</severity>
<summary>
These two if statements can be collapsed into one.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[catch \( [^())]+ \) { }]]>
</pattern>
<message>
<id>
EmptyCatchStatement
</id>
<severity>
style
</severity>
<summary>
An empty catch statement.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[do { } while \(]]>
</pattern>
<message>
<id>
EmptyDoWhileStatement
</id>
<severity>
style
</severity>
<summary>
Empty do-while.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[else { }]]>
</pattern>
<message>
<id>
EmptyElseBlock
</id>
<severity>
style
</severity>
<summary>
Empty else statement can be safely removed.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[for \( [^()]+ \) { }]]>
</pattern>
<message>
<id>
EmptyForStatement
</id>
<severity>
style
</severity>
<summary>
Empty for statement.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[if \( [^()]+ \) { }]]>
</pattern>
<message>
<id>
EmptyIfStatement
</id>
<severity>
style
</severity>
<summary>
Empty if statement.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[switch \( [^()]+ \) { }]]>
</pattern>
<message>
<id>
EmptySwitchStatement
</id>
<severity>
style
</severity>
<summary>
Empty switch statement.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[while \( [^()]+ \) { }]]>
</pattern>
<message>
<id>
EmptyWhileStatement
</id>
<severity>
style
</severity>
<summary>
Empty while statement.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[ for \( ; [^;]+ ; \)]]>
</pattern>
<message>
<id>
ForLoopShouldBeWhileLoop
</id>
<severity>
style
</severity>
<summary>
For loop should be written as a while loop.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
goto
</pattern>
<message>
<id>
GotoStatement
</id>
<severity>
style
</severity>
<summary>
Goto considered harmful.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[if \( \w+ != \w+ \) ({[^{}]*(?1)*[^{}]*}) else { (?!if)]]>
</pattern>
<message>
<id>
InvertedLogic
</id>
<severity>
style
</severity>
<summary>
It is cleaner to invert the logic.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[if \( ! \w+ \) ({[^{}]*(?1)*[^{}]*}) else { (?!if)]]>
</pattern>
<message>
<id>
InvertedLogic
</id>
<severity>
style
</severity>
<summary>
It is cleaner to invert the logic.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[\w+ != \w+ \?]]>
</pattern>
<message>
<id>
InvertedLogic
</id>
<severity>
style
</severity>
<summary>
It is cleaner to invert the logic.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[! \w+ \?]]>
</pattern>
<message>
<id>
InvertedLogic
</id>
<severity>
style
</severity>
<summary>
It is cleaner to invert the logic.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[\? (true|false) : (true|false)]]>
</pattern>
<message>
<id>
RedundantConditionalOperator
</id>
<severity>
style
</severity>
<summary>
Conditional operator is redundant.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[if \( [^()]+ \) { return (true|false) ; } else { return (true|false) ; }]]>
</pattern>
<message>
<id>
RedundantIfStatement
</id>
<severity>
style
</severity>
<summary>
The if statement is redundant.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[if \( [^()]+ \) { [^{}]* (return|throw|break|continue) [^;]* ; } else {]]>
</pattern>
<message>
<id>
UnnecessaryElseStatement
</id>
<severity>
style
</severity>
<summary>
Else statement is not necessary.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = \w+ \[ \1 \] ; }]]>
</pattern>
<message>
<id>
useStlAlgorithm
</id>
<severity>
style
</severity>
<summary>
Considering using std::copy instead.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = \w+ ; }]]>
</pattern>
<message>
<id>
useStlAlgorithm
</id>
<severity>
style
</severity>
<summary>
Considering using std::fill instead.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (\w+ :: )*\w+ \( \) ; }]]>
</pattern>
<message>
<id>
useStlAlgorithm
</id>
<severity>
style
</severity>
<summary>
Considering using std::generate instead.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (\w+ :: )*\w+ \( \w+ \[ \1 \] \) ; }]]>
</pattern>
<message>
<id>
useStlAlgorithm
</id>
<severity>
style
</severity>
<summary>
Considering using std::transform instead.
</summary>
</message>
</rule>
<rule>
<tokenlist>
normal
</tokenlist>
<pattern>
<![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (\w+ :: )*\w+ \( \w+ \[ \1 \] , \w+ \[ \1 \] \) ; }]]>
</pattern>
<message>
<id>
useStlAlgorithm
</id>
<severity>
style
</severity>
<summary>
Considering using std::transform instead.
</summary>
</message>
</rule>
src/opt/memory_coloring_impl.hpp
View file @
e36567a3
...
@@ -138,11 +138,11 @@ struct memory_coloring_impl
...
@@ -138,11 +138,11 @@ struct memory_coloring_impl
int
len2
=
i2
->
get_end
()
-
i2
->
get_begin
();
int
len2
=
i2
->
get_end
()
-
i2
->
get_begin
();
if
(
len1
!=
len2
)
if
(
len1
!=
len2
)
{
{
return
(
len1
<
len2
)
?
true
:
false
;
return
(
len1
<
len2
);
}
}
else
if
(
i1
->
result
.
bytes
()
!=
i2
->
result
.
bytes
())
else
if
(
i1
->
result
.
bytes
()
!=
i2
->
result
.
bytes
())
{
{
return
(
i1
->
result
.
bytes
()
<
i2
->
result
.
bytes
())
?
true
:
false
;
return
(
i1
->
result
.
bytes
()
<
i2
->
result
.
bytes
());
}
}
else
else
{
{
...
...
test/gpu/miopen.cpp
View file @
e36567a3
...
@@ -35,10 +35,7 @@ std::future<typename std::result_of<Function()>::type> detach_async(Function&& f
...
@@ -35,10 +35,7 @@ std::future<typename std::result_of<Function()>::type> detach_async(Function&& f
std
::
thread
(
std
::
move
(
task
)).
detach
();
std
::
thread
(
std
::
move
(
task
)).
detach
();
return
std
::
move
(
fut
);
return
std
::
move
(
fut
);
}
}
else
return
std
::
async
(
std
::
launch
::
deferred
,
std
::
forward
<
Function
>
(
f
));
{
return
std
::
async
(
std
::
launch
::
deferred
,
std
::
forward
<
Function
>
(
f
));
}
}
}
struct
auto_print
struct
auto_print
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment