parent
8dbe6994a2
commit
0467ab1339
|
@ -632,7 +632,7 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
|
||||||
|
|
||||||
// Handle scopes that might be noreturn
|
// Handle scopes that might be noreturn
|
||||||
if (allocation.status == VarInfo::NOALLOC && Token::simpleMatch(tok, ") ; }")) {
|
if (allocation.status == VarInfo::NOALLOC && Token::simpleMatch(tok, ") ; }")) {
|
||||||
const std::string &functionName(tok->link()->previous()->str());
|
const std::string functionName(mSettings->library.getFunctionName(tok->link()->previous()));
|
||||||
bool unknown = false;
|
bool unknown = false;
|
||||||
if (mTokenizer->isScopeNoReturn(tok->tokAt(2), &unknown)) {
|
if (mTokenizer->isScopeNoReturn(tok->tokAt(2), &unknown)) {
|
||||||
if (!unknown)
|
if (!unknown)
|
||||||
|
@ -847,7 +847,7 @@ void CheckLeakAutoVar::changeAllocStatus(VarInfo *varInfo, const VarInfo::AllocI
|
||||||
void CheckLeakAutoVar::functionCall(const Token *tokName, const Token *tokOpeningPar, VarInfo *varInfo, const VarInfo::AllocInfo& allocation, const Library::AllocFunc* af)
|
void CheckLeakAutoVar::functionCall(const Token *tokName, const Token *tokOpeningPar, VarInfo *varInfo, const VarInfo::AllocInfo& allocation, const Library::AllocFunc* af)
|
||||||
{
|
{
|
||||||
// Ignore function call?
|
// Ignore function call?
|
||||||
if (mSettings->library.isLeakIgnore(tokName->str()))
|
if (mSettings->library.isLeakIgnore(mSettings->library.getFunctionName(tokName)))
|
||||||
return;
|
return;
|
||||||
if (mSettings->library.getReallocFuncInfo(tokName))
|
if (mSettings->library.getReallocFuncInfo(tokName))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -214,6 +214,7 @@ private:
|
||||||
TEST_CASE(smartPtrInContainer); // #8262
|
TEST_CASE(smartPtrInContainer); // #8262
|
||||||
|
|
||||||
TEST_CASE(functionCallCastConfig); // #9652
|
TEST_CASE(functionCallCastConfig); // #9652
|
||||||
|
TEST_CASE(functionCallLeakIgnoreConfig); // #7923
|
||||||
}
|
}
|
||||||
|
|
||||||
#define check(...) check_(__FILE__, __LINE__, __VA_ARGS__)
|
#define check(...) check_(__FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
@ -2360,6 +2361,27 @@ private:
|
||||||
"}", settingsFunctionCall);
|
"}", settingsFunctionCall);
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: Function free_func() should have <use>/<leak-ignore> configuration\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: Function free_func() should have <use>/<leak-ignore> configuration\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void functionCallLeakIgnoreConfig() { // #7923
|
||||||
|
Settings settingsLeakIgnore = settings;
|
||||||
|
|
||||||
|
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
|
"<def format=\"2\">\n"
|
||||||
|
" <function name=\"SomeClass::someMethod\">\n"
|
||||||
|
" <leak-ignore/>\n"
|
||||||
|
" <noreturn>false</noreturn>\n"
|
||||||
|
" <arg nr=\"1\" direction=\"in\"/>\n"
|
||||||
|
" </function>\n"
|
||||||
|
"</def>\n";
|
||||||
|
tinyxml2::XMLDocument doc;
|
||||||
|
doc.Parse(xmldata, sizeof(xmldata));
|
||||||
|
settingsLeakIgnore.library.load(doc);
|
||||||
|
check("void f() {\n"
|
||||||
|
" double* a = new double[1024];\n"
|
||||||
|
" SomeClass::someMethod(a);\n"
|
||||||
|
"}\n", settingsLeakIgnore);
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: a\n", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestLeakAutoVar)
|
REGISTER_TEST(TestLeakAutoVar)
|
||||||
|
|
Loading…
Reference in New Issue