Small Refactorizations:
- Removed #include "symboldatabase.h" from library.h - Moved variable to inner scope in tokenize.cpp - Removed unnecessary variable in tokenize.cpp
This commit is contained in:
parent
cd84d78e92
commit
3d2e26daeb
|
@ -713,3 +713,23 @@ bool Library::isNotLibraryFunction(const Token *ftok) const
|
|||
}
|
||||
return args != callargs;
|
||||
}
|
||||
|
||||
bool Library::isnoreturn(const Token *ftok) const
|
||||
{
|
||||
if (ftok->function() && ftok->function()->isAttributeNoreturn())
|
||||
return true;
|
||||
if (isNotLibraryFunction(ftok))
|
||||
return false;
|
||||
std::map<std::string, bool>::const_iterator it = _noreturn.find(ftok->str());
|
||||
return (it != _noreturn.end() && it->second);
|
||||
}
|
||||
|
||||
bool Library::isnotnoreturn(const Token *ftok) const
|
||||
{
|
||||
if (ftok->function() && ftok->function()->isAttributeNoreturn())
|
||||
return false;
|
||||
if (isNotLibraryFunction(ftok))
|
||||
return false;
|
||||
std::map<std::string, bool>::const_iterator it = _noreturn.find(ftok->str());
|
||||
return (it != _noreturn.end() && !it->second);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "path.h"
|
||||
#include "mathlib.h"
|
||||
#include "token.h"
|
||||
#include "symboldatabase.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
@ -129,23 +128,8 @@ public:
|
|||
// returns true if ftok is not a library function
|
||||
bool isNotLibraryFunction(const Token *ftok) const;
|
||||
|
||||
bool isnoreturn(const Token *ftok) const {
|
||||
if (ftok->function() && ftok->function()->isAttributeNoreturn())
|
||||
return true;
|
||||
if (isNotLibraryFunction(ftok))
|
||||
return false;
|
||||
std::map<std::string, bool>::const_iterator it = _noreturn.find(ftok->str());
|
||||
return (it != _noreturn.end() && it->second);
|
||||
}
|
||||
|
||||
bool isnotnoreturn(const Token *ftok) const {
|
||||
if (ftok->function() && ftok->function()->isAttributeNoreturn())
|
||||
return false;
|
||||
if (isNotLibraryFunction(ftok))
|
||||
return false;
|
||||
std::map<std::string, bool>::const_iterator it = _noreturn.find(ftok->str());
|
||||
return (it != _noreturn.end() && !it->second);
|
||||
}
|
||||
bool isnoreturn(const Token *ftok) const;
|
||||
bool isnotnoreturn(const Token *ftok) const;
|
||||
|
||||
bool isScopeNoReturn(const Token *end, std::string *unknownFunc) const;
|
||||
|
||||
|
|
|
@ -6572,7 +6572,6 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
if (varid == 0)
|
||||
continue;
|
||||
|
||||
const std::string structname;
|
||||
const Token * const valueToken = tok2->tokAt(4);
|
||||
std::string value(valueToken->str());
|
||||
if (tok2->str() == "sprintf") {
|
||||
|
@ -6584,7 +6583,7 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
const unsigned int valueVarId(0);
|
||||
const bool valueIsPointer(false);
|
||||
Token *tok3 = tok2->tokAt(6);
|
||||
ret |= simplifyKnownVariablesSimplify(&tok2, tok3, varid, structname, value, valueVarId, valueIsPointer, valueToken, indentlevel);
|
||||
ret |= simplifyKnownVariablesSimplify(&tok2, tok3, varid, emptyString, value, valueVarId, valueIsPointer, valueToken, indentlevel);
|
||||
|
||||
// there could be a hang here if tok2 was moved back by the function call above for some reason
|
||||
if (_settings->terminated())
|
||||
|
@ -8508,8 +8507,8 @@ bool Tokenizer::isTwoNumber(const std::string &s)
|
|||
void Tokenizer::simplifyMathFunctions()
|
||||
{
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
bool simplifcationMade = false;
|
||||
if (tok->isName() && tok->strAt(1) == "(") { // precondition for function
|
||||
bool simplifcationMade = false;
|
||||
if (Token::Match(tok, "atol ( %str% )")) { //@todo Add support for atoll()
|
||||
if (tok->previous() &&
|
||||
Token::simpleMatch(tok->tokAt(-2), "std ::")) {
|
||||
|
@ -8739,11 +8738,11 @@ void Tokenizer::simplifyMathFunctions()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Jump back to begin of statement if a simplification was performed
|
||||
if (simplifcationMade) {
|
||||
while (tok->previous() && tok->str() != ";") {
|
||||
tok = tok->previous();
|
||||
// Jump back to begin of statement if a simplification was performed
|
||||
if (simplifcationMade) {
|
||||
while (tok->previous() && tok->str() != ";") {
|
||||
tok = tok->previous();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue