Modernize: Use enum class
This commit is contained in:
parent
680fbfe612
commit
4fb6c27276
|
@ -227,7 +227,7 @@ void CheckClass::constructors()
|
|||
|
||||
if (classNameUsed)
|
||||
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 (!precedes(scope->bodyStart, func.tokenDef))
|
||||
continue;
|
||||
|
@ -240,9 +240,9 @@ void CheckClass::constructors()
|
|||
func.functionScope->bodyStart->link() == func.functionScope->bodyStart->next()) {
|
||||
// don't warn about user defined default constructor when there are other constructors
|
||||
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
|
||||
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
|
||||
// 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)
|
||||
if (!func.isConstructor() || func.isDelete() || (!func.hasBody() && func.access == Private))
|
||||
if (!func.isConstructor() || func.isDelete() || (!func.hasBody() && func.access == AccessControl::Private))
|
||||
continue;
|
||||
|
||||
if (!func.isExplicit() &&
|
||||
|
@ -311,7 +311,7 @@ static bool isNonCopyable(const Scope *scope, bool *unknown)
|
|||
for (const Function &func : baseInfo.type->classScope->functionList) {
|
||||
if (func.type != Function::eCopyConstructor)
|
||||
continue;
|
||||
if (func.access == Private || func.isDelete())
|
||||
if (func.access == AccessControl::Private || func.isDelete())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ bool CheckClass::canNotCopy(const Scope *scope)
|
|||
for (const Function &func : scope->functionList) {
|
||||
if (func.isConstructor())
|
||||
constructor = true;
|
||||
if (func.access != Public)
|
||||
if (func.access != AccessControl::Public)
|
||||
continue;
|
||||
if (func.type == Function::eCopyConstructor) {
|
||||
publicCopy = true;
|
||||
|
@ -520,7 +520,7 @@ bool CheckClass::canNotMove(const Scope *scope)
|
|||
for (const Function &func : scope->functionList) {
|
||||
if (func.isConstructor())
|
||||
constructor = true;
|
||||
if (func.access != Public)
|
||||
if (func.access != AccessControl::Public)
|
||||
continue;
|
||||
if (func.type == Function::eCopyConstructor) {
|
||||
publicCopy = true;
|
||||
|
@ -1038,7 +1038,7 @@ static bool checkFunctionUsage(const Function *privfunc, const Scope* scope)
|
|||
}
|
||||
} else if ((func->type != Function::eCopyConstructor &&
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1079,7 +1079,7 @@ void CheckClass::privateFunctions()
|
|||
std::list<const Function*> privateFuncs;
|
||||
for (const Function &func : scope->functionList) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ void CheckClass::operatorEq()
|
|||
|
||||
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||
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
|
||||
if (func->isDelete())
|
||||
continue;
|
||||
|
@ -1472,7 +1472,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
|||
if (startTok->next() == last) {
|
||||
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
|
||||
operatorEqMissingReturnStatementError(func->token, func->access == Public);
|
||||
operatorEqMissingReturnStatementError(func->token, func->access == AccessControl::Public);
|
||||
} else {
|
||||
operatorEqMissingReturnStatementError(func->token, true);
|
||||
}
|
||||
|
@ -1485,7 +1485,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
|||
return;
|
||||
}
|
||||
|
||||
operatorEqMissingReturnStatementError(func->token, func->access == Public);
|
||||
operatorEqMissingReturnStatementError(func->token, func->access == AccessControl::Public);
|
||||
}
|
||||
|
||||
void CheckClass::operatorEqRetRefThisError(const Token *tok)
|
||||
|
@ -1682,7 +1682,7 @@ void CheckClass::virtualDestructor()
|
|||
// Iterate through each base class...
|
||||
for (int j = 0; j < scope->definedType->derivedFrom.size(); ++j) {
|
||||
// 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 Scope *derivedFromScope = derivedFrom->classScope;
|
||||
if (!derivedFromScope)
|
||||
|
@ -1749,7 +1749,7 @@ void CheckClass::virtualDestructor()
|
|||
// Make sure that the destructor is public (protected or private
|
||||
// would not compile if inheritance is used in a way that would
|
||||
// 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);
|
||||
// check for duplicate error and remove it if found
|
||||
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
|
||||
for (const Function &func : scope->functionList) {
|
||||
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();
|
||||
if (Token::Match(tok2, "%varid% =", varid)) {
|
||||
const CheckMemoryLeak::AllocType alloc = getAllocationType(tok2->tokAt(2), varid);
|
||||
|
|
|
@ -214,10 +214,10 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
|
||||
// definition may be different than declaration
|
||||
if (mTokenizer->isCPP() && tok->str() == "class") {
|
||||
access[new_scope] = Private;
|
||||
access[new_scope] = AccessControl::Private;
|
||||
new_scope->type = Scope::eClass;
|
||||
} else if (tok->str() == "struct") {
|
||||
access[new_scope] = Public;
|
||||
access[new_scope] = AccessControl::Public;
|
||||
new_scope->type = Scope::eStruct;
|
||||
}
|
||||
|
||||
|
@ -235,9 +235,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
new_scope = &scopeList.back();
|
||||
|
||||
if (tok->str() == "class")
|
||||
access[new_scope] = Private;
|
||||
access[new_scope] = AccessControl::Private;
|
||||
else if (tok->str() == "struct" || tok->str() == "union")
|
||||
access[new_scope] = Public;
|
||||
access[new_scope] = AccessControl::Public;
|
||||
|
||||
// fill typeList...
|
||||
if (new_scope->isClassOrStructOrUnion() || new_scope->type == Scope::eEnum) {
|
||||
|
@ -297,7 +297,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
scopeList.emplace_back(this, tok, scope);
|
||||
|
||||
Scope *new_scope = &scopeList.back();
|
||||
access[new_scope] = Public;
|
||||
access[new_scope] = AccessControl::Public;
|
||||
|
||||
const Token *tok2 = tok->linkAt(3)->next();
|
||||
|
||||
|
@ -370,7 +370,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
scopeList.emplace_back(this, tok, scope);
|
||||
|
||||
Scope *new_scope = &scopeList.back();
|
||||
access[new_scope] = Public;
|
||||
access[new_scope] = AccessControl::Public;
|
||||
|
||||
const Token* varNameTok = tok->next()->link()->next();
|
||||
if (varNameTok->str() == "*") {
|
||||
|
@ -413,7 +413,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
scopeList.emplace_back(this, tok, scope);
|
||||
|
||||
Scope *new_scope = &scopeList.back();
|
||||
access[new_scope] = Public;
|
||||
access[new_scope] = AccessControl::Public;
|
||||
|
||||
const Token *tok2 = tok->next();
|
||||
|
||||
|
@ -463,18 +463,18 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
|
||||
// What section are we in..
|
||||
if (tok->str() == "private:")
|
||||
access[scope] = Private;
|
||||
access[scope] = AccessControl::Private;
|
||||
else if (tok->str() == "protected:")
|
||||
access[scope] = Protected;
|
||||
access[scope] = AccessControl::Protected;
|
||||
else if (tok->str() == "public:" || tok->str() == "__published:")
|
||||
access[scope] = Public;
|
||||
access[scope] = AccessControl::Public;
|
||||
else if (Token::Match(tok, "public|protected|private %name% :")) {
|
||||
if (tok->str() == "private")
|
||||
access[scope] = Private;
|
||||
access[scope] = AccessControl::Private;
|
||||
else if (tok->str() == "protected")
|
||||
access[scope] = Protected;
|
||||
access[scope] = AccessControl::Protected;
|
||||
else
|
||||
access[scope] = Public;
|
||||
access[scope] = AccessControl::Public;
|
||||
|
||||
tok = tok->tokAt(2);
|
||||
}
|
||||
|
@ -658,9 +658,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
scope->nestedList.push_back(&scopeList.back());
|
||||
scope = &scopeList.back();
|
||||
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)
|
||||
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;
|
||||
} else if (Token::Match(tok, "%var% {")) {
|
||||
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(fIsSmartPointer, lib->isSmartPointer(mTypeStartToken));
|
||||
}
|
||||
if (mAccess == Argument) {
|
||||
if (mAccess == AccessControl::Argument) {
|
||||
tok = mNameToken;
|
||||
if (!tok) {
|
||||
// Argument without name
|
||||
|
@ -1742,7 +1742,7 @@ Function::Function(const Tokenizer *mTokenizer, const Token *tok, const Scope *s
|
|||
nestedIn(scope),
|
||||
initArgCount(0),
|
||||
type(eFunction),
|
||||
access(Public),
|
||||
access(AccessControl::Public),
|
||||
noexceptArg(nullptr),
|
||||
throwArg(nullptr),
|
||||
mFlags(0)
|
||||
|
@ -2092,6 +2092,7 @@ bool Function::isSafe(const Settings *settings) const
|
|||
case AccessControl::Global:
|
||||
return settings->safeChecks.externalFunctions;
|
||||
case AccessControl::Throw:
|
||||
case AccessControl::Argument:
|
||||
return false;
|
||||
};
|
||||
return false;
|
||||
|
@ -2357,19 +2358,19 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
|
|||
}
|
||||
|
||||
if (tok2->str() == "public") {
|
||||
base.access = Public;
|
||||
base.access = AccessControl::Public;
|
||||
tok2 = tok2->next();
|
||||
} else if (tok2->str() == "protected") {
|
||||
base.access = Protected;
|
||||
base.access = AccessControl::Protected;
|
||||
tok2 = tok2->next();
|
||||
} else if (tok2->str() == "private") {
|
||||
base.access = Private;
|
||||
base.access = AccessControl::Private;
|
||||
tok2 = tok2->next();
|
||||
} else {
|
||||
if (tok->str() == "class")
|
||||
base.access = Private;
|
||||
base.access = AccessControl::Private;
|
||||
else if (tok->str() == "struct")
|
||||
base.access = Public;
|
||||
base.access = AccessControl::Public;
|
||||
}
|
||||
if (!tok2)
|
||||
return nullptr;
|
||||
|
@ -2588,21 +2589,21 @@ static std::ostream & operator << (std::ostream & s, Scope::ScopeType type)
|
|||
static std::string accessControlToString(const AccessControl& access)
|
||||
{
|
||||
switch (access) {
|
||||
case Public:
|
||||
case AccessControl::Public:
|
||||
return "Public";
|
||||
case Protected:
|
||||
case AccessControl::Protected:
|
||||
return "Protected";
|
||||
case Private:
|
||||
case AccessControl::Private:
|
||||
return "Private";
|
||||
case Global:
|
||||
case AccessControl::Global:
|
||||
return "Global";
|
||||
case Namespace:
|
||||
case AccessControl::Namespace:
|
||||
return "Namespace";
|
||||
case Argument:
|
||||
case AccessControl::Argument:
|
||||
return "Argument";
|
||||
case Local:
|
||||
case AccessControl::Local:
|
||||
return "Local";
|
||||
case Throw:
|
||||
case AccessControl::Throw:
|
||||
return "Throw";
|
||||
}
|
||||
return "Unknown";
|
||||
|
@ -2918,9 +2919,9 @@ void SymbolDatabase::printOut(const char *title) const
|
|||
if (type->derivedFrom[i].isVirtual)
|
||||
std::cout << "Virtual ";
|
||||
|
||||
std::cout << (type->derivedFrom[i].access == Public ? " Public" :
|
||||
type->derivedFrom[i].access == Protected ? " Protected" :
|
||||
type->derivedFrom[i].access == Private ? " Private" :
|
||||
std::cout << (type->derivedFrom[i].access == AccessControl::Public ? " Public" :
|
||||
type->derivedFrom[i].access == AccessControl::Protected ? " Protected" :
|
||||
type->derivedFrom[i].access == AccessControl::Private ? " Private" :
|
||||
" Unknown");
|
||||
|
||||
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"))
|
||||
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() == ")") {
|
||||
// check for a variadic function
|
||||
|
@ -3377,17 +3378,17 @@ AccessControl Scope::defaultAccess() const
|
|||
{
|
||||
switch (type) {
|
||||
case eGlobal:
|
||||
return Global;
|
||||
return AccessControl::Global;
|
||||
case eClass:
|
||||
return Private;
|
||||
return AccessControl::Private;
|
||||
case eStruct:
|
||||
return Public;
|
||||
return AccessControl::Public;
|
||||
case eUnion:
|
||||
return Public;
|
||||
return AccessControl::Public;
|
||||
case eNamespace:
|
||||
return Namespace;
|
||||
return AccessControl::Namespace;
|
||||
default:
|
||||
return Local;
|
||||
return AccessControl::Local;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3457,13 +3458,13 @@ void Scope::getVariableList(const Settings* settings)
|
|||
|
||||
// "private:" "public:" "protected:" etc
|
||||
else if (tok->str() == "public:") {
|
||||
varaccess = Public;
|
||||
varaccess = AccessControl::Public;
|
||||
continue;
|
||||
} else if (tok->str() == "protected:") {
|
||||
varaccess = Protected;
|
||||
varaccess = AccessControl::Protected;
|
||||
continue;
|
||||
} else if (tok->str() == "private:") {
|
||||
varaccess = Private;
|
||||
varaccess = AccessControl::Private;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class ValueType;
|
|||
/**
|
||||
* @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.
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
class BaseInfo {
|
||||
public:
|
||||
BaseInfo() :
|
||||
type(nullptr), nameTok(nullptr), access(Public), isVirtual(false) {
|
||||
type(nullptr), nameTok(nullptr), access(AccessControl::Public), isVirtual(false) {
|
||||
}
|
||||
|
||||
std::string name;
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
* @return true if public, false if not
|
||||
*/
|
||||
bool isPublic() const {
|
||||
return mAccess == Public;
|
||||
return mAccess == AccessControl::Public;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -323,7 +323,7 @@ public:
|
|||
* @return true if protected, false if not
|
||||
*/
|
||||
bool isProtected() const {
|
||||
return mAccess == Protected;
|
||||
return mAccess == AccessControl::Protected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -331,7 +331,7 @@ public:
|
|||
* @return true if private, false if not
|
||||
*/
|
||||
bool isPrivate() const {
|
||||
return mAccess == Private;
|
||||
return mAccess == AccessControl::Private;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -339,7 +339,7 @@ public:
|
|||
* @return true if global, false if not
|
||||
*/
|
||||
bool isGlobal() const {
|
||||
return mAccess == Global;
|
||||
return mAccess == AccessControl::Global;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -347,7 +347,7 @@ public:
|
|||
* @return true if in a namespace, false if not
|
||||
*/
|
||||
bool isNamespace() const {
|
||||
return mAccess == Namespace;
|
||||
return mAccess == AccessControl::Namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,7 +355,7 @@ public:
|
|||
* @return true if a function argument, false if not
|
||||
*/
|
||||
bool isArgument() const {
|
||||
return mAccess == Argument;
|
||||
return mAccess == AccessControl::Argument;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,7 +363,7 @@ public:
|
|||
* @return true if local, false if not
|
||||
*/
|
||||
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
|
||||
*/
|
||||
bool isThrow() const {
|
||||
return mAccess == Throw;
|
||||
return mAccess == AccessControl::Throw;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -430,7 +430,7 @@ private:
|
|||
ASSERT_EQUALS(false, result);
|
||||
ASSERT(nullptr == vartok);
|
||||
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() {
|
||||
|
@ -440,7 +440,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -453,7 +453,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -466,7 +466,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -479,7 +479,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -492,7 +492,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -505,7 +505,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -518,7 +518,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -531,14 +531,14 @@ private:
|
|||
ASSERT_EQUALS(true, result1);
|
||||
ASSERT_EQUALS("p", vartok->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(true == v1.isPointer());
|
||||
ASSERT(false == v1.isReference());
|
||||
|
||||
reset();
|
||||
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(true == v2.isPointer());
|
||||
ASSERT(false == v2.isConst());
|
||||
|
@ -550,7 +550,7 @@ private:
|
|||
ASSERT_EQUALS(true, result2);
|
||||
ASSERT_EQUALS("p", vartok->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(true == v3.isPointer());
|
||||
ASSERT(true == v3.isConst());
|
||||
|
@ -573,7 +573,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("first", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -586,7 +586,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("p", vartok->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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -599,7 +599,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("pp", vartok->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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -612,7 +612,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("p", vartok->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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -625,7 +625,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("v", vartok->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(false == v.isPointer());
|
||||
ASSERT(false == v.isPointerArray());
|
||||
|
@ -639,7 +639,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("a", vartok->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(true == v.isArray());
|
||||
ASSERT(false == v.isPointerToArray());
|
||||
|
@ -654,7 +654,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("a", vartok->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(false == v.isArray());
|
||||
ASSERT(true == v.isPointerToArray());
|
||||
|
@ -669,7 +669,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("chars", vartok->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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -682,7 +682,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -695,7 +695,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->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(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -708,7 +708,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -721,7 +721,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("floats", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -734,7 +734,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("intsets", vartok->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.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -745,7 +745,7 @@ private:
|
|||
givenACodeSampleToTokenize var1("int& foo;");
|
||||
const bool result1 = nullScope.isVariableDeclaration(var1.tokens(), vartok, typetok);
|
||||
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.isPointer());
|
||||
ASSERT(true == v1.isReference());
|
||||
|
@ -754,7 +754,7 @@ private:
|
|||
givenACodeSampleToTokenize var2("foo*& bar;");
|
||||
const bool result2 = nullScope.isVariableDeclaration(var2.tokens(), vartok, typetok);
|
||||
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(true == v2.isPointer());
|
||||
ASSERT(true == v2.isReference());
|
||||
|
@ -763,7 +763,7 @@ private:
|
|||
givenACodeSampleToTokenize var3("std::vector<int>& foo;");
|
||||
const bool result3 = nullScope.isVariableDeclaration(var3.tokens(), vartok, typetok);
|
||||
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.isPointer());
|
||||
ASSERT(true == v3.isReference());
|
||||
|
@ -788,7 +788,7 @@ private:
|
|||
givenACodeSampleToTokenize var("std::string const* s;");
|
||||
const bool result = nullScope.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
||||
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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -799,7 +799,7 @@ private:
|
|||
givenACodeSampleToTokenize var("int&& i;");
|
||||
const bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
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.isPointer());
|
||||
ASSERT(true == v.isReference());
|
||||
|
@ -964,7 +964,7 @@ private:
|
|||
list.createTokens(code, "test.cpp");
|
||||
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
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> no_types = { "set" };
|
||||
ASSERT_EQUALS(true, v.isStlType());
|
||||
|
@ -980,7 +980,7 @@ private:
|
|||
list.front()->tokAt(3)->link(list.front()->tokAt(5));
|
||||
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
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> no_types = { "bitset", "map", "set" };
|
||||
ASSERT_EQUALS(true, v.isStlType());
|
||||
|
@ -995,7 +995,7 @@ private:
|
|||
list.createTokens(code, "test.cpp");
|
||||
const bool result = nullScope.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
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" };
|
||||
ASSERT_EQUALS(false, v.isStlType());
|
||||
ASSERT_EQUALS(false, v.isStlType(types));
|
||||
|
@ -1008,7 +1008,7 @@ private:
|
|||
givenACodeSampleToTokenize var("char* const * s;");
|
||||
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -1019,7 +1019,7 @@ private:
|
|||
givenACodeSampleToTokenize var("char* volatile * s;");
|
||||
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -1030,7 +1030,7 @@ private:
|
|||
givenACodeSampleToTokenize var("char* const volatile * s;");
|
||||
bool result = nullScope.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -1041,7 +1041,7 @@ private:
|
|||
givenACodeSampleToTokenize var("const char* const volatile * const volatile * const volatile * const volatile s;");
|
||||
bool result = nullScope.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
||||
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(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
|
Loading…
Reference in New Issue