Fix platform-dependent test result, formatting and crash in whole program analysis
This commit is contained in:
parent
4a47b8b3ae
commit
2c73518e29
|
@ -97,8 +97,9 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void analyseWholeProgram(const std::list<FileInfo*> &fileInfo, ErrorLogger &errorLogger) {
|
||||
virtual void analyseWholeProgram(const std::list<FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) {
|
||||
(void)fileInfo;
|
||||
(void)settings;
|
||||
(void)errorLogger;
|
||||
}
|
||||
|
||||
|
|
|
@ -1797,7 +1797,7 @@ Check::FileInfo* CheckBufferOverrun::getFileInfo(const Tokenizer *tokenizer, con
|
|||
return fileInfo;
|
||||
}
|
||||
|
||||
void CheckBufferOverrun::analyseWholeProgram(const std::list<Check::FileInfo*> &fileInfo, ErrorLogger &errorLogger)
|
||||
void CheckBufferOverrun::analyseWholeProgram(const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger)
|
||||
{
|
||||
// Merge all fileInfo
|
||||
MyFileInfo all;
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const;
|
||||
|
||||
/** @brief Analyse all file infos for all TU */
|
||||
void analyseWholeProgram(const std::list<Check::FileInfo*> &fileInfo, ErrorLogger &errorLogger);
|
||||
void analyseWholeProgram(const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -1379,8 +1379,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
|
||||
void CheckMemoryLeakInFunction::simplifycode(Token *tok) const
|
||||
{
|
||||
if (_tokenizer->isCPP())
|
||||
{
|
||||
if (_tokenizer->isCPP()) {
|
||||
// Replace "throw" that is not in a try block with "return"
|
||||
int indentlevel = 0;
|
||||
int trylevel = -1;
|
||||
|
|
|
@ -268,5 +268,5 @@ Check::FileInfo *CheckUnusedFunctions::getFileInfo(const Tokenizer *tokenizer, c
|
|||
void CheckUnusedFunctions::analyseWholeProgram(const std::list<Check::FileInfo*> &fileInfo, ErrorLogger &errorLogger)
|
||||
{
|
||||
(void)fileInfo;
|
||||
instance.check(&errorLogger);
|
||||
check(&errorLogger);
|
||||
}
|
||||
|
|
|
@ -690,7 +690,7 @@ void CppCheck::analyseWholeProgram()
|
|||
{
|
||||
// Analyse the tokens
|
||||
for (std::list<Check *>::const_iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||
(*it)->analyseWholeProgram(fileInfo, *this);
|
||||
(*it)->analyseWholeProgram(fileInfo, _settings, *this);
|
||||
}
|
||||
|
||||
bool CppCheck::unusedFunctionCheckIsEnabled() const
|
||||
|
|
|
@ -9909,8 +9909,7 @@ void Tokenizer::simplifyBorland()
|
|||
tok = tok->link();
|
||||
if (!tok)
|
||||
break;
|
||||
}
|
||||
else if (Token::Match(tok, "class %name% :|{")) {
|
||||
} else if (Token::Match(tok, "class %name% :|{")) {
|
||||
while (tok && tok->str() != "{" && tok->str() != ";")
|
||||
tok = tok->next();
|
||||
if (!tok)
|
||||
|
|
|
@ -57,13 +57,13 @@ private:
|
|||
TEST_CASE(ignore_declaration); // ignore declaration
|
||||
}
|
||||
|
||||
void check(const char code[]) {
|
||||
void check(const char code[], Settings::PlatformType platform = Settings::Unspecified) {
|
||||
// Clear the error buffer..
|
||||
errout.str("");
|
||||
|
||||
Settings settings;
|
||||
settings.addEnabled("style");
|
||||
|
||||
settings.platform(platform);
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
std::istringstream istr(code);
|
||||
|
@ -228,10 +228,10 @@ private:
|
|||
check("int main() { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int _tmain() { }");
|
||||
check("int _tmain() { }", Settings::Win32A);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int WinMain() { }");
|
||||
check("int WinMain() { }", Settings::Win32A);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue