Avoid 'unsigned' in astutils
This commit is contained in:
parent
316537a837
commit
5d853bcb58
|
@ -227,7 +227,7 @@ bool precedes(const Token * tok1, const Token * tok2)
|
||||||
return tok1->index() < tok2->index();
|
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()) {
|
for (const Token *tok = startTok; tok != endTok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "= & %varid% ;", varid))
|
if (Token::Match(tok, "= & %varid% ;", varid))
|
||||||
|
@ -248,7 +248,7 @@ static bool isAliased(const Token * startTok, const Token * endTok, unsigned int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool exprDependsOnThis(const Token *expr, unsigned int depth)
|
static bool exprDependsOnThis(const Token *expr, int depth)
|
||||||
{
|
{
|
||||||
if (!expr)
|
if (!expr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -804,7 +804,7 @@ bool isReturnScope(const Token * const endToken)
|
||||||
return false;
|
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)
|
if (!tok)
|
||||||
return false;
|
return false;
|
||||||
|
@ -846,7 +846,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
// goto start of function call and get argnr
|
// goto start of function call and get argnr
|
||||||
unsigned int argnr = 0;
|
int argnr = 0;
|
||||||
while (tok && !Token::Match(tok, "[;{}]")) {
|
while (tok && !Token::Match(tok, "[;{}]")) {
|
||||||
if (tok->str() == ",")
|
if (tok->str() == ",")
|
||||||
++argnr;
|
++argnr;
|
||||||
|
@ -870,7 +870,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings,
|
||||||
// Constructor call
|
// Constructor call
|
||||||
if (tok->variable() && tok->variable()->nameToken() == tok) {
|
if (tok->variable() && tok->variable()->nameToken() == tok) {
|
||||||
// Find constructor..
|
// Find constructor..
|
||||||
const unsigned int argCount = numberOfArguments(tok);
|
const int argCount = numberOfArguments(tok);
|
||||||
const Scope *typeScope = tok->variable()->typeScope();
|
const Scope *typeScope = tok->variable()->typeScope();
|
||||||
if (typeScope) {
|
if (typeScope) {
|
||||||
for (const Function &function : typeScope->functionList) {
|
for (const Function &function : typeScope->functionList) {
|
||||||
|
@ -930,7 +930,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings,
|
||||||
return arg && !arg->isConst() && arg->isReference();
|
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()) {
|
for (const Token *tok = start; tok != end; tok = tok->next()) {
|
||||||
if (tok->varId() != varid) {
|
if (tok->varId() != varid) {
|
||||||
|
@ -1017,7 +1017,7 @@ int numberOfArguments(const Token *start)
|
||||||
return arguments;
|
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;
|
++depth;
|
||||||
if (!tok || depth >= 100)
|
if (!tok || depth >= 100)
|
||||||
|
@ -1172,7 +1172,7 @@ static bool hasFunctionCall(const Token *tok)
|
||||||
return hasFunctionCall(tok->astOperand1()) || hasFunctionCall(tok->astOperand2());
|
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
|
// Parse the given tokens
|
||||||
for (const Token *tok = startToken; tok != endToken; tok = tok->next()) {
|
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)
|
FwdAnalysis::Result FwdAnalysis::check(const Token *expr, const Token *startToken, const Token *endToken)
|
||||||
{
|
{
|
||||||
// all variable ids in expr.
|
// all variable ids in expr.
|
||||||
std::set<unsigned int> exprVarIds;
|
std::set<int> exprVarIds;
|
||||||
bool local = true;
|
bool local = true;
|
||||||
bool unknownVarId = false;
|
bool unknownVarId = false;
|
||||||
visitAstNodes(expr,
|
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")) {
|
if (Token::Match(tok, "%name% (") && !Token::Match(tok, "if|while|for")) {
|
||||||
// Is argument passed by reference?
|
// Is argument passed by reference?
|
||||||
const std::vector<const Token*> args = getArguments(tok);
|
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%|.|::"))
|
if (!Token::Match(args[argnr], "%name%|.|::"))
|
||||||
continue;
|
continue;
|
||||||
if (tok->function() && tok->function()->getArgumentVar(argnr) && !tok->function()->getArgumentVar(argnr)->isReference() && !tok->function()->isConst())
|
if (tok->function() && tok->function()->getArgumentVar(argnr) && !tok->function()->getArgumentVar(argnr)->isReference() && !tok->function()->isConst())
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool isReturnScope(const Token *endToken);
|
||||||
* @param settings program settings
|
* @param settings program settings
|
||||||
* @param inconclusive pointer to output variable which indicates that the answer of the question is inconclusive
|
* @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?
|
/** Is variable changed by function call?
|
||||||
* In case the answer of the question is inconclusive, e.g. because the function declaration is not known
|
* 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);
|
bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings, bool *inconclusive);
|
||||||
|
|
||||||
/** Is variable changed in block of code? */
|
/** 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);
|
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 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?
|
// Is expression a l-value global data?
|
||||||
bool isGlobalData(const Token *expr) const;
|
bool isGlobalData(const Token *expr) const;
|
||||||
|
|
Loading…
Reference in New Issue