manual: Document suppressions

This commit is contained in:
Daniel Marjamäki 2018-04-11 12:50:02 +02:00
parent b596b0d549
commit 7176632bc6
1 changed files with 31 additions and 1 deletions

View File

@ -816,7 +816,7 @@ Rule text
these.</para> these.</para>
<section> <section>
<title>Suppressing a certain error type</title> <title>Plain text suppressions</title>
<para>You can suppress certain types of errors. The format for such a <para>You can suppress certain types of errors. The format for such a
suppression is one of:</para> suppression is one of:</para>
@ -869,6 +869,25 @@ uninitvar</programlisting>
</section> </section>
</section> </section>
<section>
<title>XML suppressions</title>
<para>You can specify suppressions in a XML file. Example file:</para>
<programlisting>&lt;?xml version="1.0"?&gt;
&lt;suppressions&gt;
&lt;suppression&gt;
&lt;id&gt;uninitvar&lt;/id&gt;
&lt;fileName&gt;src/file1.c&lt;/fileName&gt;
&lt;lineNumber&gt;10&lt;/lineNumber&gt;
&lt;symbolName&gt;var&lt;/symbolName&gt;
&lt;/suppression&gt;
&lt;/suppressions&gt;</programlisting>
<para>The xml format is extensible and may be extended with further
attributes in the future.</para>
</section>
<section> <section>
<title>Inline suppressions</title> <title>Inline suppressions</title>
@ -902,6 +921,17 @@ Checking test.c...
No error is reported when invoking cppcheck this way:</para> No error is reported when invoking cppcheck this way:</para>
<programlisting>cppcheck --inline-suppr test.c</programlisting> <programlisting>cppcheck --inline-suppr test.c</programlisting>
<para>you can specify that the inline suppression only applies to a
specific symbol:</para>
<programlisting>// cppcheck-suppress arrayIndexOutOfBounds symbolName=arr</programlisting>
<para> You can write comments for the suppress, however is recommended
to use ; or // to specify where they start:</para>
<programlisting>// cppcheck-suppress arrayIndexOutOfBounds ; some comment
// cppcheck-suppress arrayIndexOutOfBounds // some comment</programlisting>
</section> </section>
</chapter> </chapter>