Avoid 'unsigned' in astutils

This commit is contained in:
Daniel Marjamäki 2019-07-13 16:13:21 +02:00
parent 316537a837
commit 5d853bcb58
2 changed files with 13 additions and 13 deletions

View File

@ -227,7 +227,7 @@ bool precedes(const Token * tok1, const Token * tok2)
return tok1->index() < tok2->index();
}
static bool isAliased(const Token * startTok, const Token * endTok, unsigned int varid)
static bool isAliased(const Token * startTok, const Token * endTok, int varid)
{
for (const Token *tok = startTok; tok != endTok; tok = tok->next()) {
if (Token::Match(tok, "= & %varid% ;", varid))
@ -248,7 +248,7 @@ static bool isAliased(const Token * startTok, const Token * endTok, unsigned int
return false;
}
static bool exprDependsOnThis(const Token *expr, unsigned int depth)
static bool exprDependsOnThis(const Token *expr, int depth)
{
if (!expr)
return false;
@ -804,7 +804,7 @@ bool isReturnScope(const Token * const endToken)
return false;
}
bool isVariableChangedByFunctionCall(const Token *tok, unsigned int varid, const Settings *settings, bool *inconclusive)
bool isVariableChangedByFunctionCall(const Token *tok, int varid, const Settings *settings, bool *inconclusive)
{
if (!tok)
return false;
@ -846,7 +846,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings,
}
// goto start of function call and get argnr
unsigned int argnr = 0;
int argnr = 0;
while (tok && !Token::Match(tok, "[;{}]")) {
if (tok->str() == ",")
++argnr;
@ -870,7 +870,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings,
// Constructor call
if (tok->variable() && tok->variable()->nameToken() == tok) {
// Find constructor..
const unsigned int argCount = numberOfArguments(tok);
const int argCount = numberOfArguments(tok);
const Scope *typeScope = tok->variable()->typeScope();
if (typeScope) {
for (const Function &function : typeScope->functionList) {
@ -930,7 +930,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings,
return arg && !arg->isConst() && arg->isReference();
}
bool isVariableChanged(const Token *start, const Token *end, const unsigned int varid, bool globalvar, const Settings *settings, bool cpp)
bool isVariableChanged(const Token *start, const Token *end, const int varid, bool globalvar, const Settings *settings, bool cpp)
{
for (const Token *tok = start; tok != end; tok = tok->next()) {
if (tok->varId() != varid) {
@ -1017,7 +1017,7 @@ int numberOfArguments(const Token *start)
return arguments;
}
static void getArgumentsRecursive(const Token *tok, std::vector<const Token *> *arguments, unsigned int depth)
static void getArgumentsRecursive(const Token *tok, std::vector<const Token *> *arguments, int depth)
{
++depth;
if (!tok || depth >= 100)
@ -1172,7 +1172,7 @@ static bool hasFunctionCall(const Token *tok)
return hasFunctionCall(tok->astOperand1()) || hasFunctionCall(tok->astOperand2());
}
struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<unsigned int> &exprVarIds, bool local, bool inInnerClass)
struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<int> &exprVarIds, bool local, bool inInnerClass)
{
// Parse the given tokens
for (const Token *tok = startToken; tok != endToken; tok = tok->next()) {
@ -1429,7 +1429,7 @@ bool FwdAnalysis::isGlobalData(const Token *expr) const
FwdAnalysis::Result FwdAnalysis::check(const Token *expr, const Token *startToken, const Token *endToken)
{
// all variable ids in expr.
std::set<unsigned int> exprVarIds;
std::set<int> exprVarIds;
bool local = true;
bool unknownVarId = false;
visitAstNodes(expr,
@ -1526,7 +1526,7 @@ bool FwdAnalysis::possiblyAliased(const Token *expr, const Token *startToken) co
if (Token::Match(tok, "%name% (") && !Token::Match(tok, "if|while|for")) {
// Is argument passed by reference?
const std::vector<const Token*> args = getArguments(tok);
for (unsigned int argnr = 0; argnr < args.size(); ++argnr) {
for (int argnr = 0; argnr < args.size(); ++argnr) {
if (!Token::Match(args[argnr], "%name%|.|::"))
continue;
if (tok->function() && tok->function()->getArgumentVar(argnr) && !tok->function()->getArgumentVar(argnr)->isReference() && !tok->function()->isConst())

View File

@ -118,7 +118,7 @@ bool isReturnScope(const Token *endToken);
* @param settings program settings
* @param inconclusive pointer to output variable which indicates that the answer of the question is inconclusive
*/
bool isVariableChangedByFunctionCall(const Token *tok, unsigned int varid, const Settings *settings, bool *inconclusive);
bool isVariableChangedByFunctionCall(const Token *tok, int varid, const Settings *settings, bool *inconclusive);
/** Is variable changed by function call?
* In case the answer of the question is inconclusive, e.g. because the function declaration is not known
@ -131,7 +131,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, unsigned int varid, const
bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings, bool *inconclusive);
/** Is variable changed in block of code? */
bool isVariableChanged(const Token *start, const Token *end, const unsigned int varid, bool globalvar, const Settings *settings, bool cpp);
bool isVariableChanged(const Token *start, const Token *end, const int varid, bool globalvar, const Settings *settings, bool cpp);
bool isVariableChanged(const Variable * var, const Settings *settings, bool cpp);
@ -221,7 +221,7 @@ private:
};
struct Result check(const Token *expr, const Token *startToken, const Token *endToken);
struct Result checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<unsigned int> &exprVarIds, bool local, bool inInnerClass);
struct Result checkRecursive(const Token *expr, const Token *startToken, const Token *endToken, const std::set<int> &exprVarIds, bool local, bool inInnerClass);
// Is expression a l-value global data?
bool isGlobalData(const Token *expr) const;