errmsg: use the error message dealloc-use
This commit is contained in:
parent
7299d3e5b1
commit
3c7e40fe13
|
@ -1171,9 +1171,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c
|
||||||
}
|
}
|
||||||
if ((result = Token::findmatch(tok, "dealloc [;{}] use|use_ ;")) != NULL)
|
if ((result = Token::findmatch(tok, "dealloc [;{}] use|use_ ;")) != NULL)
|
||||||
{
|
{
|
||||||
std::ostringstream errmsg;
|
ErrorMessage::deallocuse(_errorLogger, _tokenizer, result->tokAt(2), varname);
|
||||||
errmsg << _tokenizer->fileLine(result->tokAt(2)) << ": Using \"" << varname << "\" after it has been deallocated / released";
|
|
||||||
_errorLogger->reportErr(errmsg.str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace "&use" with "use". Replace "use_" with ";"
|
// Replace "&use" with "use". Replace "use_" with ";"
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
check(filedata);
|
check(filedata);
|
||||||
|
|
||||||
// Compare results..
|
// Compare results..
|
||||||
ASSERT_EQUALS("[file.cpp:5]: Using \"foo\" after it has been deallocated / released\n", errout.str());
|
ASSERT_EQUALS("[file.cpp:5]: (error) Using 'foo' after it is deallocated / released\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void linenumbers2()
|
void linenumbers2()
|
||||||
|
|
|
@ -1669,7 +1669,7 @@ private:
|
||||||
" delete [] s;\n"
|
" delete [] s;\n"
|
||||||
" p = s;\n"
|
" p = s;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS(std::string("[test.cpp:5]: Using \"s\" after it has been deallocated / released\n"), errout.str());
|
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 's' after it is deallocated / released\n"), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void dealloc_use_2()
|
void dealloc_use_2()
|
||||||
|
@ -1714,7 +1714,7 @@ private:
|
||||||
" free(str);\n"
|
" free(str);\n"
|
||||||
" char c = str[10];\n"
|
" char c = str[10];\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS(std::string("[test.cpp:5]: Using \"str\" after it has been deallocated / released\n"), errout.str());
|
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n"), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void dealloc_use_6()
|
void dealloc_use_6()
|
||||||
|
@ -1736,7 +1736,7 @@ private:
|
||||||
" delete [] str;\n"
|
" delete [] str;\n"
|
||||||
" str[10] = 0;\n"
|
" str[10] = 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS(std::string("[test.cpp:5]: Using \"str\" after it has been deallocated / released\n"), errout.str());
|
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n"), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue