manual: Document the cwe attribute
This commit is contained in:
parent
42e82eda96
commit
28985d1baa
|
@ -1535,14 +1535,10 @@ void CheckStl::readingEmptyStlContainer()
|
||||||
if (i->type != Scope::eFunction)
|
if (i->type != Scope::eFunction)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const Token* restartTok = nullptr;
|
|
||||||
for (const Token *tok = i->classStart->next(); tok != i->classEnd; tok = tok->next()) {
|
for (const Token *tok = i->classStart->next(); tok != i->classEnd; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "for|while")) { // Loops and end of scope clear the sets.
|
if (Token::Match(tok, "for|while|do|}")) { // Loops and end of scope clear the sets.
|
||||||
restartTok = tok->linkAt(1); // Check condition to catch looping over empty containers
|
|
||||||
} else if (tok == restartTok || Token::Match(tok, "do|}")) {
|
|
||||||
empty_map.clear();
|
empty_map.clear();
|
||||||
empty_nonmap.clear();
|
empty_nonmap.clear();
|
||||||
restartTok = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tok->varId())
|
if (!tok->varId())
|
||||||
|
|
|
@ -305,7 +305,7 @@ cppcheck -DA --force file.c</programlisting>
|
||||||
<cppcheck version="1.66">
|
<cppcheck version="1.66">
|
||||||
<errors>
|
<errors>
|
||||||
<error id="someError" severity="error" msg="short error text"
|
<error id="someError" severity="error" msg="short error text"
|
||||||
verbose="long error text" inconclusive="true">
|
verbose="long error text" inconclusive="true" cwe="312">
|
||||||
<location file="file.c" line="1"/>
|
<location file="file.c" line="1"/>
|
||||||
</error>
|
</error>
|
||||||
</errors>
|
</errors>
|
||||||
|
@ -361,6 +361,15 @@ cppcheck -DA --force file.c</programlisting>
|
||||||
inconclusive.</para>
|
inconclusive.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><sgmltag>cwe</sgmltag></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>CWE ID for message. This attribute is only used
|
||||||
|
when the CWE ID for the message is known.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -2664,13 +2664,6 @@ private:
|
||||||
" std::string strValue2 = CMap[1];\n"
|
" std::string strValue2 = CMap[1];\n"
|
||||||
"}\n", true);
|
"}\n", true);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Reading from empty STL container\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Reading from empty STL container\n", errout.str());
|
||||||
|
|
||||||
// #4306
|
|
||||||
check("void f(std::vector<int> v) {\n"
|
|
||||||
" v.clear();\n"
|
|
||||||
" for(int i = 0; i < v.size(); i++) { cout << v[i]; }\n"
|
|
||||||
"}", true);
|
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Reading from empty STL container\n", errout.str());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue