Rename _type to mType

This commit is contained in:
Daniel Marjamäki 2018-06-16 20:25:54 +02:00
parent fc6f17ed87
commit 78974e9267
8 changed files with 49 additions and 49 deletions

View File

@ -64,7 +64,7 @@ public:
bool allocateMemory = false) : bool allocateMemory = false) :
_var(var), _var(var),
_lastAccess(var ? var->nameToken() : nullptr), _lastAccess(var ? var->nameToken() : nullptr),
_type(type), mType(type),
_read(read), _read(read),
_write(write), _write(write),
_modified(modified), _modified(modified),
@ -88,7 +88,7 @@ public:
const Variable* _var; const Variable* _var;
const Token* _lastAccess; const Token* _lastAccess;
VariableType _type; VariableType mType;
bool _read; bool _read;
bool _write; bool _write;
bool _modified; // read/modify/write bool _modified; // read/modify/write
@ -200,7 +200,7 @@ void Variables::alias(unsigned int varid1, unsigned int varid2, bool replace)
var2->_aliases.insert(varid1); var2->_aliases.insert(varid1);
var1->_aliases.insert(varid2); var1->_aliases.insert(varid2);
if (var2->_type == Variables::pointer) { if (var2->mType == Variables::pointer) {
_varReadInScope.back().insert(varid2); _varReadInScope.back().insert(varid2);
var2->_read = true; var2->_read = true;
} }
@ -524,17 +524,17 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
const Variables::VariableUsage* var2 = variables.find(varid2); const Variables::VariableUsage* var2 = variables.find(varid2);
if (var2) { // local variable (alias or read it) if (var2) { // local variable (alias or read it)
if (var1->_type == Variables::pointer || var1->_type == Variables::pointerArray) { if (var1->mType == Variables::pointer || var1->mType == Variables::pointerArray) {
if (dereference) if (dereference)
variables.read(varid2, tok); variables.read(varid2, tok);
else { else {
if (addressOf || if (addressOf ||
var2->_type == Variables::array || var2->mType == Variables::array ||
var2->_type == Variables::pointer) { var2->mType == Variables::pointer) {
bool replace = true; bool replace = true;
// pointerArray => don't replace // pointerArray => don't replace
if (var1->_type == Variables::pointerArray) if (var1->mType == Variables::pointerArray)
replace = false; replace = false;
// check if variable declared in same scope // check if variable declared in same scope
@ -569,7 +569,7 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
variables.alias(varid1, varid2, replace); variables.alias(varid1, varid2, replace);
} else if (tok->strAt(1) == "?") { } else if (tok->strAt(1) == "?") {
if (var2->_type == Variables::reference) if (var2->mType == Variables::reference)
variables.readAliases(varid2, tok); variables.readAliases(varid2, tok);
else else
variables.read(varid2, tok); variables.read(varid2, tok);
@ -577,16 +577,16 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
variables.readAll(varid2, tok); variables.readAll(varid2, tok);
} }
} }
} else if (var1->_type == Variables::reference) { } else if (var1->mType == Variables::reference) {
variables.alias(varid1, varid2, true); variables.alias(varid1, varid2, true);
} else { } else {
if ((var2->_type == Variables::pointer || var2->_type == Variables::pointerArray) && tok->strAt(1) == "[") if ((var2->mType == Variables::pointer || var2->mType == Variables::pointerArray) && tok->strAt(1) == "[")
variables.readAliases(varid2, tok); variables.readAliases(varid2, tok);
variables.read(varid2, tok); variables.read(varid2, tok);
} }
} else { // not a local variable (or an unsupported local variable) } else { // not a local variable (or an unsupported local variable)
if (var1->_type == Variables::pointer && !dereference) { if (var1->mType == Variables::pointer && !dereference) {
// check if variable declaration is in this scope // check if variable declaration is in this scope
if (var1->_var->scope() == scope) { if (var1->_var->scope() == scope) {
// If variable is used in RHS then "use" variable // If variable is used in RHS then "use" variable
@ -629,8 +629,8 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
const Variables::VariableUsage *var2 = variables.find(varid2); const Variables::VariableUsage *var2 = variables.find(varid2);
// struct member aliased to local variable // struct member aliased to local variable
if (var2 && (var2->_type == Variables::array || if (var2 && (var2->mType == Variables::array ||
var2->_type == Variables::pointer)) { var2->mType == Variables::pointer)) {
// erase aliased variable and all variables that alias it // erase aliased variable and all variables that alias it
// to prevent false positives // to prevent false positives
variables.eraseAll(varid2); variables.eraseAll(varid2);
@ -642,8 +642,8 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
else if (Token::Match(tok, "%name% = %name% ;")) { else if (Token::Match(tok, "%name% = %name% ;")) {
const unsigned int varid2 = tok->tokAt(2)->varId(); const unsigned int varid2 = tok->tokAt(2)->varId();
const Variables::VariableUsage *var2 = variables.find(varid2); const Variables::VariableUsage *var2 = variables.find(varid2);
if (var2 && (var2->_type == Variables::array || if (var2 && (var2->mType == Variables::array ||
var2->_type == Variables::pointer)) { var2->mType == Variables::pointer)) {
variables.use(varid2,tok); variables.use(varid2,tok);
} }
} }
@ -999,7 +999,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
if (dereference) { if (dereference) {
Variables::VariableUsage *var = variables.find(varid1); Variables::VariableUsage *var = variables.find(varid1);
if (var && var->_type == Variables::array) if (var && var->mType == Variables::array)
variables.write(varid1, tok); variables.write(varid1, tok);
variables.writeAliases(varid1, tok); variables.writeAliases(varid1, tok);
variables.read(varid1, tok); variables.read(varid1, tok);
@ -1007,12 +1007,12 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
Variables::VariableUsage *var = variables.find(varid1); Variables::VariableUsage *var = variables.find(varid1);
if (var && (inwhile || start->strAt(-1) == ",")) { if (var && (inwhile || start->strAt(-1) == ",")) {
variables.use(varid1, tok); variables.use(varid1, tok);
} else if (var && var->_type == Variables::reference) { } else if (var && var->mType == Variables::reference) {
variables.writeAliases(varid1, tok); variables.writeAliases(varid1, tok);
variables.read(varid1, tok); variables.read(varid1, tok);
} }
// Consider allocating memory separately because allocating/freeing alone does not constitute using the variable // Consider allocating memory separately because allocating/freeing alone does not constitute using the variable
else if (var && var->_type == Variables::pointer && else if (var && var->mType == Variables::pointer &&
Token::Match(start, "%name% = new|malloc|calloc|kmalloc|kzalloc|kcalloc|strdup|strndup|vmalloc|g_new0|g_try_new|g_new|g_malloc|g_malloc0|g_try_malloc|g_try_malloc0|g_strdup|g_strndup|g_strdup_printf")) { Token::Match(start, "%name% = new|malloc|calloc|kmalloc|kzalloc|kcalloc|strdup|strndup|vmalloc|g_new0|g_try_new|g_new|g_malloc|g_malloc0|g_try_malloc|g_try_malloc0|g_strdup|g_strndup|g_strdup_printf")) {
bool allocate = true; bool allocate = true;
@ -1040,7 +1040,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
variables.read(varid1, tok); variables.read(varid1, tok);
variables.write(varid1, start); variables.write(varid1, start);
} else if (var && } else if (var &&
var->_type == Variables::pointer && var->mType == Variables::pointer &&
Token::Match(tok, "%name% ;") && Token::Match(tok, "%name% ;") &&
tok->varId() == 0 && tok->varId() == 0 &&
tok->hasKnownIntValue() && tok->hasKnownIntValue() &&
@ -1053,13 +1053,13 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
Variables::VariableUsage *var2 = variables.find(tok->varId()); Variables::VariableUsage *var2 = variables.find(tok->varId());
if (var2) { if (var2) {
if (var2->_type == Variables::reference) { if (var2->mType == Variables::reference) {
variables.writeAliases(tok->varId(), tok); variables.writeAliases(tok->varId(), tok);
variables.read(tok->varId(), tok); variables.read(tok->varId(), tok);
} else if (tok->varId() != varid1 && Token::Match(tok, "%name% .|[")) } else if (tok->varId() != varid1 && Token::Match(tok, "%name% .|["))
variables.read(tok->varId(), tok); variables.read(tok->varId(), tok);
else if (tok->varId() != varid1 && else if (tok->varId() != varid1 &&
var2->_type == Variables::standard && var2->mType == Variables::standard &&
tok->strAt(-1) != "&") tok->strAt(-1) != "&")
variables.use(tok->varId(), tok); variables.use(tok->varId(), tok);
} }
@ -1071,7 +1071,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
const unsigned int varId = tok->varId(); const unsigned int varId = tok->varId();
Variables::VariableUsage *var = variables.find(varId); Variables::VariableUsage *var = variables.find(varId);
if (var && var->_type != Variables::reference) { if (var && var->mType != Variables::reference) {
variables.read(varId,tok); variables.read(varId,tok);
} }
@ -1099,13 +1099,13 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
if (var) { if (var) {
// Consider allocating memory separately because allocating/freeing alone does not constitute using the variable // Consider allocating memory separately because allocating/freeing alone does not constitute using the variable
if (var->_type == Variables::pointer && if (var->mType == Variables::pointer &&
Token::Match(skipBrackets(tok->next()), "= new|malloc|calloc|kmalloc|kzalloc|kcalloc|strdup|strndup|vmalloc|g_new0|g_try_new|g_new|g_malloc|g_malloc0|g_try_malloc|g_try_malloc0|g_strdup|g_strndup|g_strdup_printf")) { Token::Match(skipBrackets(tok->next()), "= new|malloc|calloc|kmalloc|kzalloc|kcalloc|strdup|strndup|vmalloc|g_new0|g_try_new|g_new|g_malloc|g_malloc0|g_try_malloc|g_try_malloc0|g_strdup|g_strndup|g_strdup_printf")) {
variables.allocateMemory(varid, tok); variables.allocateMemory(varid, tok);
} else if (var->_type == Variables::pointer || var->_type == Variables::reference) { } else if (var->mType == Variables::pointer || var->mType == Variables::reference) {
variables.read(varid, tok); variables.read(varid, tok);
variables.writeAliases(varid, tok); variables.writeAliases(varid, tok);
} else if (var->_type == Variables::pointerArray) { } else if (var->mType == Variables::pointerArray) {
tok = doAssignment(variables, tok, deref, scope); tok = doAssignment(variables, tok, deref, scope);
} else } else
variables.writeAll(varid, tok); variables.writeAll(varid, tok);
@ -1246,9 +1246,9 @@ void CheckUnusedVar::checkFunctionVariableUsage()
continue; continue;
// skip things that are only partially implemented to prevent false positives // skip things that are only partially implemented to prevent false positives
if (usage._type == Variables::pointerPointer || if (usage.mType == Variables::pointerPointer ||
usage._type == Variables::pointerArray || usage.mType == Variables::pointerArray ||
usage._type == Variables::referenceArray) usage.mType == Variables::referenceArray)
continue; continue;
const std::string &varname = usage._var->name(); const std::string &varname = usage._var->name();

View File

@ -466,7 +466,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
if (value == nullptr) if (value == nullptr)
return Error(MISSING_ATTRIBUTE, "value"); return Error(MISSING_ATTRIBUTE, "value");
PlatformType type; PlatformType type;
type._type = value; type.mType = value;
std::set<std::string> platform; std::set<std::string> platform;
for (const tinyxml2::XMLElement *typenode = node->FirstChildElement(); typenode; typenode = typenode->NextSiblingElement()) { for (const tinyxml2::XMLElement *typenode = node->FirstChildElement(); typenode; typenode = typenode->NextSiblingElement()) {
const std::string typenodename = typenode->Name(); const std::string typenodename = typenode->Name();

View File

@ -395,12 +395,12 @@ public:
_pointer == type._pointer && _pointer == type._pointer &&
_ptr_ptr == type._ptr_ptr && _ptr_ptr == type._ptr_ptr &&
_const_ptr == type._const_ptr && _const_ptr == type._const_ptr &&
_type == type._type); mType == type.mType);
} }
bool operator != (const PlatformType & type) const { bool operator != (const PlatformType & type) const {
return !(*this == type); return !(*this == type);
} }
std::string _type; std::string mType;
bool _signed; bool _signed;
bool _unsigned; bool _unsigned;
bool _long; bool _long;

View File

@ -2646,7 +2646,7 @@ void SymbolDatabase::printVariable(const Variable *var, const char *indent) cons
std::cout << indent << " isRValueRef: " << var->isRValueReference() << std::endl; std::cout << indent << " isRValueRef: " << var->isRValueReference() << std::endl;
std::cout << indent << " hasDefault: " << var->hasDefault() << std::endl; std::cout << indent << " hasDefault: " << var->hasDefault() << std::endl;
std::cout << indent << " isStlType: " << var->isStlType() << std::endl; std::cout << indent << " isStlType: " << var->isStlType() << std::endl;
std::cout << indent << "_type: "; std::cout << indent << "mType: ";
if (var->type()) { if (var->type()) {
std::cout << var->type()->type() << " " << var->type()->name(); std::cout << var->type()->type() << " " << var->type()->name();
std::cout << " " << mTokenizer->list.fileLine(var->type()->classDef); std::cout << " " << mTokenizer->list.fileLine(var->type()->classDef);
@ -5479,13 +5479,13 @@ bool ValueType::fromLibraryType(const std::string &typestr, const Settings *sett
const Library::PlatformType *platformType = settings->library.platform_type(typestr, settings->platformString()); const Library::PlatformType *platformType = settings->library.platform_type(typestr, settings->platformString());
if (platformType) { if (platformType) {
if (platformType->_type == "char") if (platformType->mType == "char")
type = ValueType::Type::CHAR; type = ValueType::Type::CHAR;
else if (platformType->_type == "short") else if (platformType->mType == "short")
type = ValueType::Type::SHORT; type = ValueType::Type::SHORT;
else if (platformType->_type == "int") else if (platformType->mType == "int")
type = platformType->_long ? ValueType::Type::LONG : ValueType::Type::INT; type = platformType->_long ? ValueType::Type::LONG : ValueType::Type::INT;
else if (platformType->_type == "long") else if (platformType->mType == "long")
type = platformType->_long ? ValueType::Type::LONGLONG : ValueType::Type::LONG; type = platformType->_long ? ValueType::Type::LONGLONG : ValueType::Type::LONG;
if (platformType->_signed) if (platformType->_signed)
sign = ValueType::SIGNED; sign = ValueType::SIGNED;

View File

@ -229,7 +229,7 @@ public:
mAccess(access_), mAccess(access_),
mFlags(0), mFlags(0),
mConstness(0), mConstness(0),
_type(type_), mType(type_),
_scope(scope_) { _scope(scope_) {
evaluate(lib); evaluate(lib);
} }
@ -486,7 +486,7 @@ public:
* @return pointer to type if known, NULL if not known * @return pointer to type if known, NULL if not known
*/ */
const Type *type() const { const Type *type() const {
return _type; return mType;
} }
/** /**
@ -494,7 +494,7 @@ public:
* @return pointer to type scope if known, NULL if not known * @return pointer to type scope if known, NULL if not known
*/ */
const Scope *typeScope() const { const Scope *typeScope() const {
return _type ? _type->classScope : nullptr; return mType ? mType->classScope : nullptr;
} }
/** /**
@ -612,7 +612,7 @@ private:
* @param t type * @param t type
*/ */
void type(const Type * t) { void type(const Type * t) {
_type = t; mType = t;
} }
/** @brief variable name token */ /** @brief variable name token */
@ -637,7 +637,7 @@ private:
unsigned int mConstness; unsigned int mConstness;
/** @brief pointer to user defined type info (for known types) */ /** @brief pointer to user defined type info (for known types) */
const Type *_type; const Type *mType;
/** @brief pointer to scope this variable is in */ /** @brief pointer to scope this variable is in */
const Scope *_scope; const Scope *_scope;

View File

@ -1666,10 +1666,10 @@ void Token::setValueType(ValueType *vt)
void Token::type(const ::Type *t) void Token::type(const ::Type *t)
{ {
_type = t; mType = t;
if (t) { if (t) {
tokType(eType); tokType(eType);
isEnumType(_type->isEnumType()); isEnumType(mType->isEnumType());
} else if (mTokType == eType) } else if (mTokType == eType)
tokType(eName); tokType(eName);
} }

View File

@ -719,7 +719,7 @@ public:
* @return a pointer to the type associated with this token. * @return a pointer to the type associated with this token.
*/ */
const ::Type *type() const { const ::Type *type() const {
return mTokType == eType ? _type : nullptr; return mTokType == eType ? mType : nullptr;
} }
/** /**
@ -914,7 +914,7 @@ private:
union { union {
const Function *_function; const Function *_function;
const Variable *_variable; const Variable *_variable;
const ::Type* _type; const ::Type* mType;
const Enumerator *_enumerator; const Enumerator *_enumerator;
}; };

View File

@ -5957,20 +5957,20 @@ void Tokenizer::simplifyPlatformTypes()
if (platformtype->_const_ptr) { if (platformtype->_const_ptr) {
tok->str("const"); tok->str("const");
tok->insertToken("*"); tok->insertToken("*");
tok->insertToken(platformtype->_type); tok->insertToken(platformtype->mType);
typeToken = tok; typeToken = tok;
} else if (platformtype->_pointer) { } else if (platformtype->_pointer) {
tok->str(platformtype->_type); tok->str(platformtype->mType);
typeToken = tok; typeToken = tok;
tok->insertToken("*"); tok->insertToken("*");
} else if (platformtype->_ptr_ptr) { } else if (platformtype->_ptr_ptr) {
tok->str(platformtype->_type); tok->str(platformtype->mType);
typeToken = tok; typeToken = tok;
tok->insertToken("*"); tok->insertToken("*");
tok->insertToken("*"); tok->insertToken("*");
} else { } else {
tok->originalName(tok->str()); tok->originalName(tok->str());
tok->str(platformtype->_type); tok->str(platformtype->mType);
typeToken = tok; typeToken = tok;
} }
if (platformtype->_signed) if (platformtype->_signed)