Class checking: Minor refactoring when analysing memset on class
This commit is contained in:
parent
9943262da0
commit
da7e75f69e
|
@ -758,7 +758,7 @@ void CheckClass::noMemset()
|
|||
break;
|
||||
}
|
||||
|
||||
if (Token::Match(tstruct, "std :: %type% < %type% > %var% ;"))
|
||||
if (Token::Match(tstruct, "std :: %type% < %type% *| > %var% ;"))
|
||||
{
|
||||
memsetStructError(tok, tok->str(), tstruct->strAt(2));
|
||||
break;
|
||||
|
|
|
@ -1492,6 +1492,16 @@ private:
|
|||
" memset(a, 0, sizeof(A));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str());
|
||||
|
||||
checkNoMemset("struct A\n"
|
||||
"{ std::vector<int *> ints; }\n"
|
||||
"\n"
|
||||
"void f()\n"
|
||||
"{\n"
|
||||
" A a;\n"
|
||||
" memset(a, 0, sizeof(A));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue