Modernize: Use enum class
This commit is contained in:
parent
680fbfe612
commit
4fb6c27276
|
@ -227,7 +227,7 @@ void CheckClass::constructors()
|
||||||
|
|
||||||
if (classNameUsed)
|
if (classNameUsed)
|
||||||
operatorEqVarError(func.token, scope->className, var.name(), inconclusive);
|
operatorEqVarError(func.token, scope->className, var.name(), inconclusive);
|
||||||
} else if (func.access != Private || mSettings->standards.cpp >= Standards::CPP11) {
|
} else if (func.access != AccessControl::Private || mSettings->standards.cpp >= Standards::CPP11) {
|
||||||
// If constructor is not in scope then we maybe using a oonstructor from a different template specialization
|
// If constructor is not in scope then we maybe using a oonstructor from a different template specialization
|
||||||
if (!precedes(scope->bodyStart, func.tokenDef))
|
if (!precedes(scope->bodyStart, func.tokenDef))
|
||||||
continue;
|
continue;
|
||||||
|
@ -240,9 +240,9 @@ void CheckClass::constructors()
|
||||||
func.functionScope->bodyStart->link() == func.functionScope->bodyStart->next()) {
|
func.functionScope->bodyStart->link() == func.functionScope->bodyStart->next()) {
|
||||||
// don't warn about user defined default constructor when there are other constructors
|
// don't warn about user defined default constructor when there are other constructors
|
||||||
if (printInconclusive)
|
if (printInconclusive)
|
||||||
uninitVarError(func.token, func.access == Private, scope->className, var.name(), true);
|
uninitVarError(func.token, func.access == AccessControl::Private, scope->className, var.name(), true);
|
||||||
} else
|
} else
|
||||||
uninitVarError(func.token, func.access == Private, scope->className, var.name(), inconclusive);
|
uninitVarError(func.token, func.access == AccessControl::Private, scope->className, var.name(), inconclusive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ void CheckClass::checkExplicitConstructors()
|
||||||
// 2) Constructor is not declared as explicit
|
// 2) Constructor is not declared as explicit
|
||||||
// 3) It is not a copy/move constructor of non-abstract class
|
// 3) It is not a copy/move constructor of non-abstract class
|
||||||
// 4) Constructor is not marked as delete (programmer can mark the default constructor as deleted, which is ok)
|
// 4) Constructor is not marked as delete (programmer can mark the default constructor as deleted, which is ok)
|
||||||
if (!func.isConstructor() || func.isDelete() || (!func.hasBody() && func.access == Private))
|
if (!func.isConstructor() || func.isDelete() || (!func.hasBody() && func.access == AccessControl::Private))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!func.isExplicit() &&
|
if (!func.isExplicit() &&
|
||||||
|
@ -311,7 +311,7 @@ static bool isNonCopyable(const Scope *scope, bool *unknown)
|
||||||
for (const Function &func : baseInfo.type->classScope->functionList) {
|
for (const Function &func : baseInfo.type->classScope->functionList) {
|
||||||
if (func.type != Function::eCopyConstructor)
|
if (func.type != Function::eCopyConstructor)
|
||||||
continue;
|
continue;
|
||||||
if (func.access == Private || func.isDelete())
|
if (func.access == AccessControl::Private || func.isDelete())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ bool CheckClass::canNotCopy(const Scope *scope)
|
||||||
for (const Function &func : scope->functionList) {
|
for (const Function &func : scope->functionList) {
|
||||||
if (func.isConstructor())
|
if (func.isConstructor())
|
||||||
constructor = true;
|
constructor = true;
|
||||||
if (func.access != Public)
|
if (func.access != AccessControl::Public)
|
||||||
continue;
|
continue;
|
||||||
if (func.type == Function::eCopyConstructor) {
|
if (func.type == Function::eCopyConstructor) {
|
||||||
publicCopy = true;
|
publicCopy = true;
|
||||||
|
@ -520,7 +520,7 @@ bool CheckClass::canNotMove(const Scope *scope)
|
||||||
for (const Function &func : scope->functionList) {
|
for (const Function &func : scope->functionList) {
|
||||||
if (func.isConstructor())
|
if (func.isConstructor())
|
||||||
constructor = true;
|
constructor = true;
|
||||||
if (func.access != Public)
|
if (func.access != AccessControl::Public)
|
||||||
continue;
|
continue;
|
||||||
if (func.type == Function::eCopyConstructor) {
|
if (func.type == Function::eCopyConstructor) {
|
||||||
publicCopy = true;
|
publicCopy = true;
|
||||||
|
@ -1038,7 +1038,7 @@ static bool checkFunctionUsage(const Function *privfunc, const Scope* scope)
|
||||||
}
|
}
|
||||||
} else if ((func->type != Function::eCopyConstructor &&
|
} else if ((func->type != Function::eCopyConstructor &&
|
||||||
func->type != Function::eOperatorEqual) ||
|
func->type != Function::eOperatorEqual) ||
|
||||||
func->access != Private) // Assume it is used, if a function implementation isn't seen, but empty private copy constructors and assignment operators are OK
|
func->access != AccessControl::Private) // Assume it is used, if a function implementation isn't seen, but empty private copy constructors and assignment operators are OK
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,7 +1079,7 @@ void CheckClass::privateFunctions()
|
||||||
std::list<const Function*> privateFuncs;
|
std::list<const Function*> privateFuncs;
|
||||||
for (const Function &func : scope->functionList) {
|
for (const Function &func : scope->functionList) {
|
||||||
// Get private functions..
|
// Get private functions..
|
||||||
if (func.type == Function::eFunction && func.access == Private && !func.isOperator()) // TODO: There are smarter ways to check private operator usage
|
if (func.type == Function::eFunction && func.access == AccessControl::Private && !func.isOperator()) // TODO: There are smarter ways to check private operator usage
|
||||||
privateFuncs.push_back(&func);
|
privateFuncs.push_back(&func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,7 +1338,7 @@ void CheckClass::operatorEq()
|
||||||
|
|
||||||
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||||
if (func->type == Function::eOperatorEqual && func->access == Public) {
|
if (func->type == Function::eOperatorEqual && func->access == AccessControl::Public) {
|
||||||
// skip "deleted" functions - cannot be called anyway
|
// skip "deleted" functions - cannot be called anyway
|
||||||
if (func->isDelete())
|
if (func->isDelete())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1472,7 +1472,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
||||||
if (startTok->next() == last) {
|
if (startTok->next() == last) {
|
||||||
if (Token::simpleMatch(func->argDef, std::string("( const " + scope->className + " &").c_str())) {
|
if (Token::simpleMatch(func->argDef, std::string("( const " + scope->className + " &").c_str())) {
|
||||||
// Typical wrong way to suppress default assignment operator by declaring it and leaving empty
|
// Typical wrong way to suppress default assignment operator by declaring it and leaving empty
|
||||||
operatorEqMissingReturnStatementError(func->token, func->access == Public);
|
operatorEqMissingReturnStatementError(func->token, func->access == AccessControl::Public);
|
||||||
} else {
|
} else {
|
||||||
operatorEqMissingReturnStatementError(func->token, true);
|
operatorEqMissingReturnStatementError(func->token, true);
|
||||||
}
|
}
|
||||||
|
@ -1485,7 +1485,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
operatorEqMissingReturnStatementError(func->token, func->access == Public);
|
operatorEqMissingReturnStatementError(func->token, func->access == AccessControl::Public);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckClass::operatorEqRetRefThisError(const Token *tok)
|
void CheckClass::operatorEqRetRefThisError(const Token *tok)
|
||||||
|
@ -1682,7 +1682,7 @@ void CheckClass::virtualDestructor()
|
||||||
// Iterate through each base class...
|
// Iterate through each base class...
|
||||||
for (int j = 0; j < scope->definedType->derivedFrom.size(); ++j) {
|
for (int j = 0; j < scope->definedType->derivedFrom.size(); ++j) {
|
||||||
// Check if base class is public and exists in database
|
// Check if base class is public and exists in database
|
||||||
if (scope->definedType->derivedFrom[j].access != Private && scope->definedType->derivedFrom[j].type) {
|
if (scope->definedType->derivedFrom[j].access != AccessControl::Private && scope->definedType->derivedFrom[j].type) {
|
||||||
const Type *derivedFrom = scope->definedType->derivedFrom[j].type;
|
const Type *derivedFrom = scope->definedType->derivedFrom[j].type;
|
||||||
const Scope *derivedFromScope = derivedFrom->classScope;
|
const Scope *derivedFromScope = derivedFrom->classScope;
|
||||||
if (!derivedFromScope)
|
if (!derivedFromScope)
|
||||||
|
@ -1749,7 +1749,7 @@ void CheckClass::virtualDestructor()
|
||||||
// Make sure that the destructor is public (protected or private
|
// Make sure that the destructor is public (protected or private
|
||||||
// would not compile if inheritance is used in a way that would
|
// would not compile if inheritance is used in a way that would
|
||||||
// cause the bug we are trying to find here.)
|
// cause the bug we are trying to find here.)
|
||||||
if (baseDestructor->access == Public) {
|
if (baseDestructor->access == AccessControl::Public) {
|
||||||
virtualDestructorError(baseDestructor->token, derivedFrom->name(), derivedClass->str(), false);
|
virtualDestructorError(baseDestructor->token, derivedFrom->name(), derivedClass->str(), false);
|
||||||
// check for duplicate error and remove it if found
|
// check for duplicate error and remove it if found
|
||||||
const std::list<const Function *>::iterator found = find(inconclusiveErrors.begin(), inconclusiveErrors.end(), baseDestructor);
|
const std::list<const Function *>::iterator found = find(inconclusiveErrors.begin(), inconclusiveErrors.end(), baseDestructor);
|
||||||
|
|
|
@ -722,7 +722,7 @@ void CheckMemoryLeakInClass::checkPublicFunctions(const Scope *scope, const Toke
|
||||||
// If they allocate member variables, they should also deallocate
|
// If they allocate member variables, they should also deallocate
|
||||||
for (const Function &func : scope->functionList) {
|
for (const Function &func : scope->functionList) {
|
||||||
if ((func.type == Function::eFunction || func.type == Function::eOperatorEqual) &&
|
if ((func.type == Function::eFunction || func.type == Function::eOperatorEqual) &&
|
||||||
func.access == Public && func.hasBody()) {
|
func.access == AccessControl::Public && func.hasBody()) {
|
||||||
const Token *tok2 = func.functionScope->bodyStart->next();
|
const Token *tok2 = func.functionScope->bodyStart->next();
|
||||||
if (Token::Match(tok2, "%varid% =", varid)) {
|
if (Token::Match(tok2, "%varid% =", varid)) {
|
||||||
const CheckMemoryLeak::AllocType alloc = getAllocationType(tok2->tokAt(2), varid);
|
const CheckMemoryLeak::AllocType alloc = getAllocationType(tok2->tokAt(2), varid);
|
||||||
|
|
|
@ -214,10 +214,10 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
|
|
||||||
// definition may be different than declaration
|
// definition may be different than declaration
|
||||||
if (mTokenizer->isCPP() && tok->str() == "class") {
|
if (mTokenizer->isCPP() && tok->str() == "class") {
|
||||||
access[new_scope] = Private;
|
access[new_scope] = AccessControl::Private;
|
||||||
new_scope->type = Scope::eClass;
|
new_scope->type = Scope::eClass;
|
||||||
} else if (tok->str() == "struct") {
|
} else if (tok->str() == "struct") {
|
||||||
access[new_scope] = Public;
|
access[new_scope] = AccessControl::Public;
|
||||||
new_scope->type = Scope::eStruct;
|
new_scope->type = Scope::eStruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
new_scope = &scopeList.back();
|
new_scope = &scopeList.back();
|
||||||
|
|
||||||
if (tok->str() == "class")
|
if (tok->str() == "class")
|
||||||
access[new_scope] = Private;
|
access[new_scope] = AccessControl::Private;
|
||||||
else if (tok->str() == "struct" || tok->str() == "union")
|
else if (tok->str() == "struct" || tok->str() == "union")
|
||||||
access[new_scope] = Public;
|
access[new_scope] = AccessControl::Public;
|
||||||
|
|
||||||
// fill typeList...
|
// fill typeList...
|
||||||
if (new_scope->isClassOrStructOrUnion() || new_scope->type == Scope::eEnum) {
|
if (new_scope->isClassOrStructOrUnion() || new_scope->type == Scope::eEnum) {
|
||||||
|
@ -297,7 +297,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
scopeList.emplace_back(this, tok, scope);
|
scopeList.emplace_back(this, tok, scope);
|
||||||
|
|
||||||
Scope *new_scope = &scopeList.back();
|
Scope *new_scope = &scopeList.back();
|
||||||
access[new_scope] = Public;
|
access[new_scope] = AccessControl::Public;
|
||||||
|
|
||||||
const Token *tok2 = tok->linkAt(3)->next();
|
const Token *tok2 = tok->linkAt(3)->next();
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
scopeList.emplace_back(this, tok, scope);
|
scopeList.emplace_back(this, tok, scope);
|
||||||
|
|
||||||
Scope *new_scope = &scopeList.back();
|
Scope *new_scope = &scopeList.back();
|
||||||
access[new_scope] = Public;
|
access[new_scope] = AccessControl::Public;
|
||||||
|
|
||||||
const Token* varNameTok = tok->next()->link()->next();
|
const Token* varNameTok = tok->next()->link()->next();
|
||||||
if (varNameTok->str() == "*") {
|
if (varNameTok->str() == "*") {
|
||||||
|
@ -413,7 +413,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
scopeList.emplace_back(this, tok, scope);
|
scopeList.emplace_back(this, tok, scope);
|
||||||
|
|
||||||
Scope *new_scope = &scopeList.back();
|
Scope *new_scope = &scopeList.back();
|
||||||
access[new_scope] = Public;
|
access[new_scope] = AccessControl::Public;
|
||||||
|
|
||||||
const Token *tok2 = tok->next();
|
const Token *tok2 = tok->next();
|
||||||
|
|
||||||
|
@ -463,18 +463,18 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
|
|
||||||
// What section are we in..
|
// What section are we in..
|
||||||
if (tok->str() == "private:")
|
if (tok->str() == "private:")
|
||||||
access[scope] = Private;
|
access[scope] = AccessControl::Private;
|
||||||
else if (tok->str() == "protected:")
|
else if (tok->str() == "protected:")
|
||||||
access[scope] = Protected;
|
access[scope] = AccessControl::Protected;
|
||||||
else if (tok->str() == "public:" || tok->str() == "__published:")
|
else if (tok->str() == "public:" || tok->str() == "__published:")
|
||||||
access[scope] = Public;
|
access[scope] = AccessControl::Public;
|
||||||
else if (Token::Match(tok, "public|protected|private %name% :")) {
|
else if (Token::Match(tok, "public|protected|private %name% :")) {
|
||||||
if (tok->str() == "private")
|
if (tok->str() == "private")
|
||||||
access[scope] = Private;
|
access[scope] = AccessControl::Private;
|
||||||
else if (tok->str() == "protected")
|
else if (tok->str() == "protected")
|
||||||
access[scope] = Protected;
|
access[scope] = AccessControl::Protected;
|
||||||
else
|
else
|
||||||
access[scope] = Public;
|
access[scope] = AccessControl::Public;
|
||||||
|
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
}
|
}
|
||||||
|
@ -658,9 +658,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
scope->nestedList.push_back(&scopeList.back());
|
scope->nestedList.push_back(&scopeList.back());
|
||||||
scope = &scopeList.back();
|
scope = &scopeList.back();
|
||||||
if (scope->type == Scope::eFor)
|
if (scope->type == Scope::eFor)
|
||||||
scope->checkVariable(tok->tokAt(2), Local, mSettings); // check for variable declaration and add it to new scope if found
|
scope->checkVariable(tok->tokAt(2), AccessControl::Local, mSettings); // check for variable declaration and add it to new scope if found
|
||||||
else if (scope->type == Scope::eCatch)
|
else if (scope->type == Scope::eCatch)
|
||||||
scope->checkVariable(tok->tokAt(2), Throw, mSettings); // check for variable declaration and add it to new scope if found
|
scope->checkVariable(tok->tokAt(2), AccessControl::Throw, mSettings); // check for variable declaration and add it to new scope if found
|
||||||
tok = scopeStartTok;
|
tok = scopeStartTok;
|
||||||
} else if (Token::Match(tok, "%var% {")) {
|
} else if (Token::Match(tok, "%var% {")) {
|
||||||
tok = tok->linkAt(1);
|
tok = tok->linkAt(1);
|
||||||
|
@ -1667,7 +1667,7 @@ void Variable::evaluate(const Settings* settings)
|
||||||
setFlag(fIsStlString, isStlType() && (Token::Match(mTypeStartToken->tokAt(2), "string|wstring|u16string|u32string !!::") || (Token::simpleMatch(mTypeStartToken->tokAt(2), "basic_string <") && !Token::simpleMatch(mTypeStartToken->linkAt(3), "> ::"))));
|
setFlag(fIsStlString, isStlType() && (Token::Match(mTypeStartToken->tokAt(2), "string|wstring|u16string|u32string !!::") || (Token::simpleMatch(mTypeStartToken->tokAt(2), "basic_string <") && !Token::simpleMatch(mTypeStartToken->linkAt(3), "> ::"))));
|
||||||
setFlag(fIsSmartPointer, lib->isSmartPointer(mTypeStartToken));
|
setFlag(fIsSmartPointer, lib->isSmartPointer(mTypeStartToken));
|
||||||
}
|
}
|
||||||
if (mAccess == Argument) {
|
if (mAccess == AccessControl::Argument) {
|
||||||
tok = mNameToken;
|
tok = mNameToken;
|
||||||
if (!tok) {
|
if (!tok) {
|
||||||
// Argument without name
|
// Argument without name
|
||||||
|
@ -1742,7 +1742,7 @@ Function::Function(const Tokenizer *mTokenizer, const Token *tok, const Scope *s
|
||||||
nestedIn(scope),
|
nestedIn(scope),
|
||||||
initArgCount(0),
|
initArgCount(0),
|
||||||
type(eFunction),
|
type(eFunction),
|
||||||
access(Public),
|
access(AccessControl::Public),
|
||||||
noexceptArg(nullptr),
|
noexceptArg(nullptr),
|
||||||
throwArg(nullptr),
|
throwArg(nullptr),
|
||||||
mFlags(0)
|
mFlags(0)
|
||||||
|
@ -2092,6 +2092,7 @@ bool Function::isSafe(const Settings *settings) const
|
||||||
case AccessControl::Global:
|
case AccessControl::Global:
|
||||||
return settings->safeChecks.externalFunctions;
|
return settings->safeChecks.externalFunctions;
|
||||||
case AccessControl::Throw:
|
case AccessControl::Throw:
|
||||||
|
case AccessControl::Argument:
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
return false;
|
return false;
|
||||||
|
@ -2357,19 +2358,19 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok2->str() == "public") {
|
if (tok2->str() == "public") {
|
||||||
base.access = Public;
|
base.access = AccessControl::Public;
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
} else if (tok2->str() == "protected") {
|
} else if (tok2->str() == "protected") {
|
||||||
base.access = Protected;
|
base.access = AccessControl::Protected;
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
} else if (tok2->str() == "private") {
|
} else if (tok2->str() == "private") {
|
||||||
base.access = Private;
|
base.access = AccessControl::Private;
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
} else {
|
} else {
|
||||||
if (tok->str() == "class")
|
if (tok->str() == "class")
|
||||||
base.access = Private;
|
base.access = AccessControl::Private;
|
||||||
else if (tok->str() == "struct")
|
else if (tok->str() == "struct")
|
||||||
base.access = Public;
|
base.access = AccessControl::Public;
|
||||||
}
|
}
|
||||||
if (!tok2)
|
if (!tok2)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2588,21 +2589,21 @@ static std::ostream & operator << (std::ostream & s, Scope::ScopeType type)
|
||||||
static std::string accessControlToString(const AccessControl& access)
|
static std::string accessControlToString(const AccessControl& access)
|
||||||
{
|
{
|
||||||
switch (access) {
|
switch (access) {
|
||||||
case Public:
|
case AccessControl::Public:
|
||||||
return "Public";
|
return "Public";
|
||||||
case Protected:
|
case AccessControl::Protected:
|
||||||
return "Protected";
|
return "Protected";
|
||||||
case Private:
|
case AccessControl::Private:
|
||||||
return "Private";
|
return "Private";
|
||||||
case Global:
|
case AccessControl::Global:
|
||||||
return "Global";
|
return "Global";
|
||||||
case Namespace:
|
case AccessControl::Namespace:
|
||||||
return "Namespace";
|
return "Namespace";
|
||||||
case Argument:
|
case AccessControl::Argument:
|
||||||
return "Argument";
|
return "Argument";
|
||||||
case Local:
|
case AccessControl::Local:
|
||||||
return "Local";
|
return "Local";
|
||||||
case Throw:
|
case AccessControl::Throw:
|
||||||
return "Throw";
|
return "Throw";
|
||||||
}
|
}
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
|
@ -2918,9 +2919,9 @@ void SymbolDatabase::printOut(const char *title) const
|
||||||
if (type->derivedFrom[i].isVirtual)
|
if (type->derivedFrom[i].isVirtual)
|
||||||
std::cout << "Virtual ";
|
std::cout << "Virtual ";
|
||||||
|
|
||||||
std::cout << (type->derivedFrom[i].access == Public ? " Public" :
|
std::cout << (type->derivedFrom[i].access == AccessControl::Public ? " Public" :
|
||||||
type->derivedFrom[i].access == Protected ? " Protected" :
|
type->derivedFrom[i].access == AccessControl::Protected ? " Protected" :
|
||||||
type->derivedFrom[i].access == Private ? " Private" :
|
type->derivedFrom[i].access == AccessControl::Private ? " Private" :
|
||||||
" Unknown");
|
" Unknown");
|
||||||
|
|
||||||
if (type->derivedFrom[i].type)
|
if (type->derivedFrom[i].type)
|
||||||
|
@ -3177,7 +3178,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
||||||
while (Token::Match(startTok, "enum|struct|const|volatile"))
|
while (Token::Match(startTok, "enum|struct|const|volatile"))
|
||||||
startTok = startTok->next();
|
startTok = startTok->next();
|
||||||
|
|
||||||
argumentList.emplace_back(nameTok, startTok, endTok, count++, Argument, argType, functionScope, symbolDatabase->mSettings);
|
argumentList.emplace_back(nameTok, startTok, endTok, count++, AccessControl::Argument, argType, functionScope, symbolDatabase->mSettings);
|
||||||
|
|
||||||
if (tok->str() == ")") {
|
if (tok->str() == ")") {
|
||||||
// check for a variadic function
|
// check for a variadic function
|
||||||
|
@ -3377,17 +3378,17 @@ AccessControl Scope::defaultAccess() const
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case eGlobal:
|
case eGlobal:
|
||||||
return Global;
|
return AccessControl::Global;
|
||||||
case eClass:
|
case eClass:
|
||||||
return Private;
|
return AccessControl::Private;
|
||||||
case eStruct:
|
case eStruct:
|
||||||
return Public;
|
return AccessControl::Public;
|
||||||
case eUnion:
|
case eUnion:
|
||||||
return Public;
|
return AccessControl::Public;
|
||||||
case eNamespace:
|
case eNamespace:
|
||||||
return Namespace;
|
return AccessControl::Namespace;
|
||||||
default:
|
default:
|
||||||
return Local;
|
return AccessControl::Local;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3457,13 +3458,13 @@ void Scope::getVariableList(const Settings* settings)
|
||||||
|
|
||||||
// "private:" "public:" "protected:" etc
|
// "private:" "public:" "protected:" etc
|
||||||
else if (tok->str() == "public:") {
|
else if (tok->str() == "public:") {
|
||||||
varaccess = Public;
|
varaccess = AccessControl::Public;
|
||||||
continue;
|
continue;
|
||||||
} else if (tok->str() == "protected:") {
|
} else if (tok->str() == "protected:") {
|
||||||
varaccess = Protected;
|
varaccess = AccessControl::Protected;
|
||||||
continue;
|
continue;
|
||||||
} else if (tok->str() == "private:") {
|
} else if (tok->str() == "private:") {
|
||||||
varaccess = Private;
|
varaccess = AccessControl::Private;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ValueType;
|
||||||
/**
|
/**
|
||||||
* @brief Access control enumerations.
|
* @brief Access control enumerations.
|
||||||
*/
|
*/
|
||||||
enum AccessControl { Public, Protected, Private, Global, Namespace, Argument, Local, Throw };
|
enum class AccessControl { Public, Protected, Private, Global, Namespace, Argument, Local, Throw };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Array dimension information.
|
* @brief Array dimension information.
|
||||||
|
@ -72,7 +72,7 @@ public:
|
||||||
class BaseInfo {
|
class BaseInfo {
|
||||||
public:
|
public:
|
||||||
BaseInfo() :
|
BaseInfo() :
|
||||||
type(nullptr), nameTok(nullptr), access(Public), isVirtual(false) {
|
type(nullptr), nameTok(nullptr), access(AccessControl::Public), isVirtual(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -315,7 +315,7 @@ public:
|
||||||
* @return true if public, false if not
|
* @return true if public, false if not
|
||||||
*/
|
*/
|
||||||
bool isPublic() const {
|
bool isPublic() const {
|
||||||
return mAccess == Public;
|
return mAccess == AccessControl::Public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -323,7 +323,7 @@ public:
|
||||||
* @return true if protected, false if not
|
* @return true if protected, false if not
|
||||||
*/
|
*/
|
||||||
bool isProtected() const {
|
bool isProtected() const {
|
||||||
return mAccess == Protected;
|
return mAccess == AccessControl::Protected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,7 +331,7 @@ public:
|
||||||
* @return true if private, false if not
|
* @return true if private, false if not
|
||||||
*/
|
*/
|
||||||
bool isPrivate() const {
|
bool isPrivate() const {
|
||||||
return mAccess == Private;
|
return mAccess == AccessControl::Private;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -339,7 +339,7 @@ public:
|
||||||
* @return true if global, false if not
|
* @return true if global, false if not
|
||||||
*/
|
*/
|
||||||
bool isGlobal() const {
|
bool isGlobal() const {
|
||||||
return mAccess == Global;
|
return mAccess == AccessControl::Global;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,7 +347,7 @@ public:
|
||||||
* @return true if in a namespace, false if not
|
* @return true if in a namespace, false if not
|
||||||
*/
|
*/
|
||||||
bool isNamespace() const {
|
bool isNamespace() const {
|
||||||
return mAccess == Namespace;
|
return mAccess == AccessControl::Namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -355,7 +355,7 @@ public:
|
||||||
* @return true if a function argument, false if not
|
* @return true if a function argument, false if not
|
||||||
*/
|
*/
|
||||||
bool isArgument() const {
|
bool isArgument() const {
|
||||||
return mAccess == Argument;
|
return mAccess == AccessControl::Argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -363,7 +363,7 @@ public:
|
||||||
* @return true if local, false if not
|
* @return true if local, false if not
|
||||||
*/
|
*/
|
||||||
bool isLocal() const {
|
bool isLocal() const {
|
||||||
return (mAccess == Local) && !isExtern();
|
return (mAccess == AccessControl::Local) && !isExtern();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -411,7 +411,7 @@ public:
|
||||||
* @return true if throw type, false if not
|
* @return true if throw type, false if not
|
||||||
*/
|
*/
|
||||||
bool isThrow() const {
|
bool isThrow() const {
|
||||||
return mAccess == Throw;
|
return mAccess == AccessControl::Throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -430,7 +430,7 @@ private:
|
||||||
ASSERT_EQUALS(false, result);
|
ASSERT_EQUALS(false, result);
|
||||||
ASSERT(nullptr == vartok);
|
ASSERT(nullptr == vartok);
|
||||||
ASSERT(nullptr == typetok);
|
ASSERT(nullptr == typetok);
|
||||||
Variable v(nullptr, nullptr, nullptr, 0, Public, nullptr, nullptr, &settings1);
|
Variable v(nullptr, nullptr, nullptr, 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_isVariableDeclarationIdentifiesSimpleDeclaration() {
|
void test_isVariableDeclarationIdentifiesSimpleDeclaration() {
|
||||||
|
@ -440,7 +440,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("x", vartok->str());
|
ASSERT_EQUALS("x", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -453,7 +453,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("x", vartok->str());
|
ASSERT_EQUALS("x", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -466,7 +466,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("x", vartok->str());
|
ASSERT_EQUALS("x", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -479,7 +479,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("x", vartok->str());
|
ASSERT_EQUALS("x", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -492,7 +492,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("x", vartok->str());
|
ASSERT_EQUALS("x", vartok->str());
|
||||||
ASSERT_EQUALS("string", typetok->str());
|
ASSERT_EQUALS("string", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -505,7 +505,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("x", vartok->str());
|
ASSERT_EQUALS("x", vartok->str());
|
||||||
ASSERT_EQUALS("string", typetok->str());
|
ASSERT_EQUALS("string", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -518,7 +518,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("x", vartok->str());
|
ASSERT_EQUALS("x", vartok->str());
|
||||||
ASSERT_EQUALS("EE", typetok->str());
|
ASSERT_EQUALS("EE", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -531,14 +531,14 @@ private:
|
||||||
ASSERT_EQUALS(true, result1);
|
ASSERT_EQUALS(true, result1);
|
||||||
ASSERT_EQUALS("p", vartok->str());
|
ASSERT_EQUALS("p", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v1(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v1(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v1.isArray());
|
ASSERT(false == v1.isArray());
|
||||||
ASSERT(true == v1.isPointer());
|
ASSERT(true == v1.isPointer());
|
||||||
ASSERT(false == v1.isReference());
|
ASSERT(false == v1.isReference());
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
givenACodeSampleToTokenize constpointer("const int* p;");
|
givenACodeSampleToTokenize constpointer("const int* p;");
|
||||||
Variable v2(constpointer.tokens()->tokAt(3), constpointer.tokens()->next(), constpointer.tokens()->tokAt(2), 0, Public, nullptr, nullptr, &settings1);
|
Variable v2(constpointer.tokens()->tokAt(3), constpointer.tokens()->next(), constpointer.tokens()->tokAt(2), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v2.isArray());
|
ASSERT(false == v2.isArray());
|
||||||
ASSERT(true == v2.isPointer());
|
ASSERT(true == v2.isPointer());
|
||||||
ASSERT(false == v2.isConst());
|
ASSERT(false == v2.isConst());
|
||||||
|
@ -550,7 +550,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result2);
|
ASSERT_EQUALS(true, result2);
|
||||||
ASSERT_EQUALS("p", vartok->str());
|
ASSERT_EQUALS("p", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v3(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v3(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v3.isArray());
|
ASSERT(false == v3.isArray());
|
||||||
ASSERT(true == v3.isPointer());
|
ASSERT(true == v3.isPointer());
|
||||||
ASSERT(true == v3.isConst());
|
ASSERT(true == v3.isConst());
|
||||||
|
@ -573,7 +573,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("first", vartok->str());
|
ASSERT_EQUALS("first", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -586,7 +586,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("p", vartok->str());
|
ASSERT_EQUALS("p", vartok->str());
|
||||||
ASSERT_EQUALS("EE", typetok->str());
|
ASSERT_EQUALS("EE", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -599,7 +599,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("pp", vartok->str());
|
ASSERT_EQUALS("pp", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -612,7 +612,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("p", vartok->str());
|
ASSERT_EQUALS("p", vartok->str());
|
||||||
ASSERT_EQUALS("int", typetok->str());
|
ASSERT_EQUALS("int", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -625,7 +625,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("v", vartok->str());
|
ASSERT_EQUALS("v", vartok->str());
|
||||||
ASSERT_EQUALS("string", typetok->str());
|
ASSERT_EQUALS("string", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(true == v.isArray());
|
ASSERT(true == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isPointerArray());
|
ASSERT(false == v.isPointerArray());
|
||||||
|
@ -639,7 +639,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("a", vartok->str());
|
ASSERT_EQUALS("a", vartok->str());
|
||||||
ASSERT_EQUALS("A", typetok->str());
|
ASSERT_EQUALS("A", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(true == v.isArray());
|
ASSERT(true == v.isArray());
|
||||||
ASSERT(false == v.isPointerToArray());
|
ASSERT(false == v.isPointerToArray());
|
||||||
|
@ -654,7 +654,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("a", vartok->str());
|
ASSERT_EQUALS("a", vartok->str());
|
||||||
ASSERT_EQUALS("A", typetok->str());
|
ASSERT_EQUALS("A", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointerToArray());
|
ASSERT(true == v.isPointerToArray());
|
||||||
|
@ -669,7 +669,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("chars", vartok->str());
|
ASSERT_EQUALS("chars", vartok->str());
|
||||||
ASSERT_EQUALS("set", typetok->str());
|
ASSERT_EQUALS("set", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -682,7 +682,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("ints", vartok->str());
|
ASSERT_EQUALS("ints", vartok->str());
|
||||||
ASSERT_EQUALS("deque", typetok->str());
|
ASSERT_EQUALS("deque", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -695,7 +695,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("ints", vartok->str());
|
ASSERT_EQUALS("ints", vartok->str());
|
||||||
ASSERT_EQUALS("deque", typetok->str());
|
ASSERT_EQUALS("deque", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(true == v.isArray());
|
ASSERT(true == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -708,7 +708,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("ints", vartok->str());
|
ASSERT_EQUALS("ints", vartok->str());
|
||||||
ASSERT_EQUALS("vector", typetok->str());
|
ASSERT_EQUALS("vector", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -721,7 +721,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("floats", vartok->str());
|
ASSERT_EQUALS("floats", vartok->str());
|
||||||
ASSERT_EQUALS("const_iterator", typetok->str());
|
ASSERT_EQUALS("const_iterator", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -734,7 +734,7 @@ private:
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
ASSERT_EQUALS("intsets", vartok->str());
|
ASSERT_EQUALS("intsets", vartok->str());
|
||||||
ASSERT_EQUALS("deque", typetok->str());
|
ASSERT_EQUALS("deque", typetok->str());
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -745,7 +745,7 @@ private:
|
||||||
givenACodeSampleToTokenize var1("int& foo;");
|
givenACodeSampleToTokenize var1("int& foo;");
|
||||||
const bool result1 = nullScope.isVariableDeclaration(var1.tokens(), vartok, typetok);
|
const bool result1 = nullScope.isVariableDeclaration(var1.tokens(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result1);
|
ASSERT_EQUALS(true, result1);
|
||||||
Variable v1(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v1(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v1.isArray());
|
ASSERT(false == v1.isArray());
|
||||||
ASSERT(false == v1.isPointer());
|
ASSERT(false == v1.isPointer());
|
||||||
ASSERT(true == v1.isReference());
|
ASSERT(true == v1.isReference());
|
||||||
|
@ -754,7 +754,7 @@ private:
|
||||||
givenACodeSampleToTokenize var2("foo*& bar;");
|
givenACodeSampleToTokenize var2("foo*& bar;");
|
||||||
const bool result2 = nullScope.isVariableDeclaration(var2.tokens(), vartok, typetok);
|
const bool result2 = nullScope.isVariableDeclaration(var2.tokens(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result2);
|
ASSERT_EQUALS(true, result2);
|
||||||
Variable v2(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v2(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v2.isArray());
|
ASSERT(false == v2.isArray());
|
||||||
ASSERT(true == v2.isPointer());
|
ASSERT(true == v2.isPointer());
|
||||||
ASSERT(true == v2.isReference());
|
ASSERT(true == v2.isReference());
|
||||||
|
@ -763,7 +763,7 @@ private:
|
||||||
givenACodeSampleToTokenize var3("std::vector<int>& foo;");
|
givenACodeSampleToTokenize var3("std::vector<int>& foo;");
|
||||||
const bool result3 = nullScope.isVariableDeclaration(var3.tokens(), vartok, typetok);
|
const bool result3 = nullScope.isVariableDeclaration(var3.tokens(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result3);
|
ASSERT_EQUALS(true, result3);
|
||||||
Variable v3(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v3(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v3.isArray());
|
ASSERT(false == v3.isArray());
|
||||||
ASSERT(false == v3.isPointer());
|
ASSERT(false == v3.isPointer());
|
||||||
ASSERT(true == v3.isReference());
|
ASSERT(true == v3.isReference());
|
||||||
|
@ -788,7 +788,7 @@ private:
|
||||||
givenACodeSampleToTokenize var("std::string const* s;");
|
givenACodeSampleToTokenize var("std::string const* s;");
|
||||||
const bool result = nullScope.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
const bool result = nullScope.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -799,7 +799,7 @@ private:
|
||||||
givenACodeSampleToTokenize var("int&& i;");
|
givenACodeSampleToTokenize var("int&& i;");
|
||||||
const bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
const bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(false == v.isPointer());
|
ASSERT(false == v.isPointer());
|
||||||
ASSERT(true == v.isReference());
|
ASSERT(true == v.isReference());
|
||||||
|
@ -964,7 +964,7 @@ private:
|
||||||
list.createTokens(code, "test.cpp");
|
list.createTokens(code, "test.cpp");
|
||||||
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, list.front(), list.back(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, list.front(), list.back(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
static const std::set<std::string> types = { "string", "wstring" };
|
static const std::set<std::string> types = { "string", "wstring" };
|
||||||
static const std::set<std::string> no_types = { "set" };
|
static const std::set<std::string> no_types = { "set" };
|
||||||
ASSERT_EQUALS(true, v.isStlType());
|
ASSERT_EQUALS(true, v.isStlType());
|
||||||
|
@ -980,7 +980,7 @@ private:
|
||||||
list.front()->tokAt(3)->link(list.front()->tokAt(5));
|
list.front()->tokAt(3)->link(list.front()->tokAt(5));
|
||||||
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, list.front(), list.back(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, list.front(), list.back(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
static const std::set<std::string> types = { "bitset", "set", "vector", "wstring" };
|
static const std::set<std::string> types = { "bitset", "set", "vector", "wstring" };
|
||||||
static const std::set<std::string> no_types = { "bitset", "map", "set" };
|
static const std::set<std::string> no_types = { "bitset", "map", "set" };
|
||||||
ASSERT_EQUALS(true, v.isStlType());
|
ASSERT_EQUALS(true, v.isStlType());
|
||||||
|
@ -995,7 +995,7 @@ private:
|
||||||
list.createTokens(code, "test.cpp");
|
list.createTokens(code, "test.cpp");
|
||||||
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, list.front(), list.back(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, list.front(), list.back(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
static const std::set<std::string> types = { "bitset", "set", "vector" };
|
static const std::set<std::string> types = { "bitset", "set", "vector" };
|
||||||
ASSERT_EQUALS(false, v.isStlType());
|
ASSERT_EQUALS(false, v.isStlType());
|
||||||
ASSERT_EQUALS(false, v.isStlType(types));
|
ASSERT_EQUALS(false, v.isStlType(types));
|
||||||
|
@ -1008,7 +1008,7 @@ private:
|
||||||
givenACodeSampleToTokenize var("char* const * s;");
|
givenACodeSampleToTokenize var("char* const * s;");
|
||||||
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -1019,7 +1019,7 @@ private:
|
||||||
givenACodeSampleToTokenize var("char* volatile * s;");
|
givenACodeSampleToTokenize var("char* volatile * s;");
|
||||||
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -1030,7 +1030,7 @@ private:
|
||||||
givenACodeSampleToTokenize var("char* const volatile * s;");
|
givenACodeSampleToTokenize var("char* const volatile * s;");
|
||||||
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
@ -1041,7 +1041,7 @@ private:
|
||||||
givenACodeSampleToTokenize var("const char* const volatile * const volatile * const volatile * const volatile s;");
|
givenACodeSampleToTokenize var("const char* const volatile * const volatile * const volatile * const volatile s;");
|
||||||
bool result = nullScope.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
bool result = nullScope.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
||||||
ASSERT_EQUALS(true, result);
|
ASSERT_EQUALS(true, result);
|
||||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, nullptr, nullptr, &settings1);
|
Variable v(vartok, typetok, vartok->previous(), 0, AccessControl::Public, nullptr, nullptr, &settings1);
|
||||||
ASSERT(false == v.isArray());
|
ASSERT(false == v.isArray());
|
||||||
ASSERT(true == v.isPointer());
|
ASSERT(true == v.isPointer());
|
||||||
ASSERT(false == v.isReference());
|
ASSERT(false == v.isReference());
|
||||||
|
|
Loading…
Reference in New Issue