Replace 'unsigned' with 'nonneg'

This commit is contained in:
Daniel Marjamäki 2019-07-22 11:25:51 +02:00
parent 7ed3db7b32
commit a81c39af09
2 changed files with 32 additions and 32 deletions

View File

@ -1876,13 +1876,13 @@ Function::Function(const Tokenizer *mTokenizer, const Token *tok, const Scope *s
}
}
bool Function::argsMatch(const Scope *scope, const Token *first, const Token *second, const std::string &path, unsigned int path_length)
bool Function::argsMatch(const Scope *scope, const Token *first, const Token *second, const std::string &path, nonneg int path_length)
{
const bool isCPP = scope->check->isCPP();
if (!isCPP) // C does not support overloads
return true;
unsigned int arg_path_length = path_length;
int arg_path_length = path_length;
while (first->str() == second->str() &&
first->isLong() == second->isLong() &&
@ -3269,7 +3269,7 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
return nullptr;
}
const Variable* Function::getArgumentVar(std::size_t num) const
const Variable* Function::getArgumentVar(nonneg int num) const
{
for (std::list<Variable>::const_iterator i = argumentList.begin(); i != argumentList.end(); ++i) {
if (i->index() == num)
@ -3990,7 +3990,7 @@ bool Scope::hasInlineOrLambdaFunction() const
return false;
}
void Scope::findFunctionInBase(const std::string & name, size_t args, std::vector<const Function *> & matches) const
void Scope::findFunctionInBase(const std::string & name, nonneg int args, std::vector<const Function *> & matches) const
{
if (isClassOrStruct() && definedType && !definedType->derivedFrom.empty()) {
const std::vector<Type::BaseInfo> &derivedFrom = definedType->derivedFrom;
@ -4793,7 +4793,7 @@ const Scope * SymbolDatabase::findNamespace(const Token * tok, const Scope * sco
//---------------------------------------------------------------------------
Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *ns, const std::string & path, unsigned int path_length)
Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *ns, const std::string & path, nonneg int path_length)
{
const Function * function = nullptr;
const bool destructor = func->strAt(-1) == "~";
@ -4860,9 +4860,9 @@ bool SymbolDatabase::isReservedName(const std::string& iName) const
return c_keywords.find(iName) != c_keywords.cend();
}
unsigned int SymbolDatabase::sizeOfType(const Token *type) const
nonneg int SymbolDatabase::sizeOfType(const Token *type) const
{
unsigned int size = mTokenizer->sizeOfType(type);
int size = mTokenizer->sizeOfType(type);
if (size == 0 && type->type() && type->type()->isEnumType() && type->type()->classScope) {
size = mSettings->sizeof_int;

View File

@ -221,7 +221,7 @@ class CPPCHECKLIB Variable {
public:
Variable(const Token *name_, const Token *start_, const Token *end_,
std::size_t index_, AccessControl access_, const Type *type_,
nonneg int index_, AccessControl access_, const Type *type_,
const Scope *scope_, const Settings* settings)
: mNameToken(name_),
mTypeStartToken(start_),
@ -294,7 +294,7 @@ public:
* Get declaration ID (varId used for variable in its declaration).
* @return declaration ID
*/
unsigned int declarationId() const {
nonneg int declarationId() const {
// name may not exist for function arguments
if (mNameToken)
return mNameToken->varId();
@ -306,7 +306,7 @@ public:
* Get index of variable in declared order.
* @return variable index
*/
std::size_t index() const {
nonneg int index() const {
return mIndex;
}
@ -520,7 +520,7 @@ public:
* Get array dimension length.
* @return length of dimension
*/
MathLib::bigint dimension(std::size_t index_) const {
MathLib::bigint dimension(nonneg int index_) const {
return mDimensions[index_].num;
}
@ -528,7 +528,7 @@ public:
* Get array dimension known.
* @return length of dimension known
*/
bool dimensionKnown(std::size_t index_) const {
bool dimensionKnown(nonneg int index_) const {
return mDimensions[index_].known;
}
@ -638,7 +638,7 @@ private:
const Token *mTypeEndToken;
/** @brief order declared */
std::size_t mIndex;
nonneg int mIndex;
/** @brief what section is this variable declared in? */
AccessControl mAccess; // public/protected/private
@ -715,14 +715,14 @@ public:
return tokenDef->str();
}
std::size_t argCount() const {
nonneg int argCount() const {
return argumentList.size();
}
std::size_t minArgCount() const {
nonneg int minArgCount() const {
return argumentList.size() - initArgCount;
}
const Variable* getArgumentVar(std::size_t num) const;
unsigned int initializedArgCount() const {
const Variable* getArgumentVar(nonneg int num) const;
nonneg int initializedArgCount() const {
return initArgCount;
}
void addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope);
@ -850,13 +850,13 @@ public:
const Scope *functionScope; ///< scope of function body
const Scope* nestedIn; ///< Scope the function is declared in
std::list<Variable> argumentList; ///< argument list
unsigned int initArgCount; ///< number of args with default values
nonneg int initArgCount; ///< number of args with default values
Type type; ///< constructor, destructor, ...
AccessControl access; ///< public/protected/private
const Token *noexceptArg; ///< noexcept token
const Token *throwArg; ///< throw token
static bool argsMatch(const Scope *scope, const Token *first, const Token *second, const std::string &path, unsigned int path_length);
static bool argsMatch(const Scope *scope, const Token *first, const Token *second, const std::string &path, nonneg int path_length);
static bool returnsReference(const Function *function);
@ -964,8 +964,8 @@ public:
std::list<Variable> varlist;
const Scope *nestedIn;
std::list<Scope *> nestedList;
unsigned int numConstructors;
unsigned int numCopyOrMoveConstructors;
nonneg int numConstructors;
nonneg int numCopyOrMoveConstructors;
std::list<UsingInfo> usingList;
ScopeType type;
Type* definedType;
@ -982,7 +982,7 @@ public:
std::vector<Enumerator> enumeratorList;
const Enumerator * findEnumerator(const std::string & name) const {
for (std::size_t i = 0, end = enumeratorList.size(); i < end; ++i) {
for (int i = 0, end = enumeratorList.size(); i < end; ++i) {
if (enumeratorList[i].name->str() == name)
return &enumeratorList[i];
}
@ -1107,7 +1107,7 @@ private:
*/
bool isVariableDeclaration(const Token* const tok, const Token*& vartok, const Token*& typetok) const;
void findFunctionInBase(const std::string & name, size_t args, std::vector<const Function *> & matches) const;
void findFunctionInBase(const std::string & name, nonneg int args, std::vector<const Function *> & matches) const;
};
@ -1116,9 +1116,9 @@ class CPPCHECKLIB ValueType {
public:
enum Sign { UNKNOWN_SIGN, SIGNED, UNSIGNED } sign;
enum Type { UNKNOWN_TYPE, NONSTD, RECORD, CONTAINER, ITERATOR, VOID, BOOL, CHAR, SHORT, WCHAR_T, INT, LONG, LONGLONG, UNKNOWN_INT, FLOAT, DOUBLE, LONGDOUBLE } type;
unsigned int bits; ///< bitfield bitcount
unsigned int pointer; ///< 0=>not pointer, 1=>*, 2=>**, 3=>***, etc
unsigned int constness; ///< bit 0=data, bit 1=*, bit 2=**
nonneg int bits; ///< bitfield bitcount
nonneg int pointer; ///< 0=>not pointer, 1=>*, 2=>**, 3=>***, etc
nonneg int constness; ///< bit 0=data, bit 1=*, bit 2=**
const Scope *typeScope; ///< if the type definition is seen this point out the type scope
const ::Type *smartPointerType; ///< Smart pointer type
const Library::Container *container; ///< If the type is a container defined in a cfg file, this is the used container
@ -1127,9 +1127,9 @@ public:
ValueType() : sign(UNKNOWN_SIGN), type(UNKNOWN_TYPE), bits(0), pointer(0U), constness(0U), typeScope(nullptr), smartPointerType(nullptr), container(nullptr), containerTypeToken(nullptr) {}
ValueType(const ValueType &vt) : sign(vt.sign), type(vt.type), bits(vt.bits), pointer(vt.pointer), constness(vt.constness), typeScope(vt.typeScope), smartPointerType(vt.smartPointerType), container(vt.container), containerTypeToken(vt.containerTypeToken), originalTypeName(vt.originalTypeName) {}
ValueType(enum Sign s, enum Type t, unsigned int p) : sign(s), type(t), bits(0), pointer(p), constness(0U), typeScope(nullptr), smartPointerType(nullptr), container(nullptr), containerTypeToken(nullptr) {}
ValueType(enum Sign s, enum Type t, unsigned int p, unsigned int c) : sign(s), type(t), bits(0), pointer(p), constness(c), typeScope(nullptr), smartPointerType(nullptr), container(nullptr), containerTypeToken(nullptr) {}
ValueType(enum Sign s, enum Type t, unsigned int p, unsigned int c, const std::string &otn) : sign(s), type(t), bits(0), pointer(p), constness(c), typeScope(nullptr), smartPointerType(nullptr), container(nullptr), containerTypeToken(nullptr), originalTypeName(otn) {}
ValueType(enum Sign s, enum Type t, nonneg int p) : sign(s), type(t), bits(0), pointer(p), constness(0U), typeScope(nullptr), smartPointerType(nullptr), container(nullptr), containerTypeToken(nullptr) {}
ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c) : sign(s), type(t), bits(0), pointer(p), constness(c), typeScope(nullptr), smartPointerType(nullptr), container(nullptr), containerTypeToken(nullptr) {}
ValueType(enum Sign s, enum Type t, nonneg int p, nonneg int c, const std::string &otn) : sign(s), type(t), bits(0), pointer(p), constness(c), typeScope(nullptr), smartPointerType(nullptr), container(nullptr), containerTypeToken(nullptr), originalTypeName(otn) {}
ValueType &operator=(const ValueType &other) = delete;
static ValueType parseDecl(const Token *type, const Settings *settings);
@ -1202,7 +1202,7 @@ public:
return const_cast<Scope *>(this->findScope(tok, const_cast<const Scope *>(startScope)));
}
const Variable *getVariableFromVarId(std::size_t varId) const {
const Variable *getVariableFromVarId(nonneg int varId) const {
return mVariableList.at(varId);
}
@ -1240,7 +1240,7 @@ public:
* @param type Token which will contain e.g. "int", "*", or string.
* @return sizeof for given type, or 0 if it can't be calculated.
*/
unsigned int sizeOfType(const Token *type) const;
nonneg int sizeOfType(const Token *type) const;
/** Set array dimensions when valueflow analysis is completed */
void setArrayDimensionsUsingValueFlow();
@ -1272,7 +1272,7 @@ private:
bool isFunction(const Token *tok, const Scope* outerScope, const Token **funcStart, const Token **argStart, const Token** declEnd) const;
const Type *findTypeInNested(const Token *startTok, const Scope *startScope) const;
const Scope *findNamespace(const Token * tok, const Scope * scope) const;
Function *findFunctionInScope(const Token *func, const Scope *ns, const std::string & path, unsigned int path_length);
Function *findFunctionInScope(const Token *func, const Scope *ns, const std::string & path, nonneg int path_length);
const Type *findVariableTypeInBase(const Scope *scope, const Token *typeTok) const;
typedef std::map<unsigned int, unsigned int> MemberIdMap;