diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index cd66629f1..a1ae08eae 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -427,6 +427,15 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Token *tok) void CheckMemoryLeakInFunction::parse_noreturn() { + noreturn.insert("exit"); + noreturn.insert("_exit"); + noreturn.insert("_Exit"); + noreturn.insert("abort"); + noreturn.insert("err"); + noreturn.insert("verr"); + noreturn.insert("errx"); + noreturn.insert("verrx"); + for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { if (tok->str() == "{") @@ -1053,27 +1062,6 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::liststrAt(0)); - // exit.. - if (Token::Match(tok->previous(), "[{};] exit|_exit|_Exit ( %any% ) ;")) - { - addtoken("exit"); - tok = tok->tokAt(3); - } - else if (Token::simpleMatch(tok, "abort ( ) ;")) - { - addtoken("exit"); - tok = tok->tokAt(2); - } - else if (Token::Match(tok, "err|verr|errx|verrx (")) - { - addtoken("exit"); - while (tok->next() && tok->next()->str() != ";") - { - tok = tok->next(); - } - } - - // Assignment.. if (varid) { diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 4eb1ddb51..88dc284d4 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -290,6 +290,7 @@ private: // getcode.. CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, 0, 0); + checkMemoryLeak.parse_noreturn(); std::list callstack; callstack.push_back(0); CheckMemoryLeak::AllocType allocType, deallocType;