memory leaks: improved handling of --vcl
This commit is contained in:
parent
a7b0c30884
commit
44a5cecd99
|
@ -1441,6 +1441,10 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_ParseClass(const Token *
|
||||||
// Declaring member variable.. check allocations and deallocations
|
// Declaring member variable.. check allocations and deallocations
|
||||||
if (Token::Match(tok->next(), "%type% * %var% ;"))
|
if (Token::Match(tok->next(), "%type% * %var% ;"))
|
||||||
{
|
{
|
||||||
|
// No false positives for vcl classes..
|
||||||
|
if (_settings._vcl && tok->next()->str()[0] == 'T')
|
||||||
|
continue;
|
||||||
|
|
||||||
if (tok->isName() || Token::Match(tok, "[;}]"))
|
if (tok->isName() || Token::Match(tok, "[;}]"))
|
||||||
{
|
{
|
||||||
if (_settings._showAll || !isclass(tok->tokAt(1)))
|
if (_settings._showAll || !isclass(tok->tokAt(1)))
|
||||||
|
|
|
@ -195,6 +195,7 @@ private:
|
||||||
|
|
||||||
// VCL..
|
// VCL..
|
||||||
TEST_CASE(vcl1);
|
TEST_CASE(vcl1);
|
||||||
|
TEST_CASE(vcl2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1891,14 +1892,8 @@ private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void checkvcl(const char code[])
|
||||||
void vcl1()
|
|
||||||
{
|
{
|
||||||
const char code[] = "void Form1::foo()\n"
|
|
||||||
"{\n"
|
|
||||||
" TEdit *Edit1 = new TEdit(this);\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
Tokenizer tokenizer;
|
Tokenizer tokenizer;
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
|
@ -1916,10 +1911,36 @@ private:
|
||||||
settings._vcl = true;
|
settings._vcl = true;
|
||||||
CheckMemoryLeakClass checkMemoryLeak(&tokenizer, settings, this);
|
CheckMemoryLeakClass checkMemoryLeak(&tokenizer, settings, this);
|
||||||
checkMemoryLeak.CheckMemoryLeak();
|
checkMemoryLeak.CheckMemoryLeak();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void vcl1()
|
||||||
|
{
|
||||||
|
checkvcl("void Form1::foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" TEdit *Edit1 = new TEdit(this);\n"
|
||||||
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void vcl2()
|
||||||
|
{
|
||||||
|
checkvcl("class Fred\n"
|
||||||
|
"{\n"
|
||||||
|
"private:\n"
|
||||||
|
" TButton *button;\n"
|
||||||
|
"public:\n"
|
||||||
|
" Fred();\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"Fred::Fred()\n"
|
||||||
|
"{\n"
|
||||||
|
" button = new TButton(this);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestMemleak)
|
REGISTER_TEST(TestMemleak)
|
||||||
|
|
Loading…
Reference in New Issue