SymbolDatabase: Add Variable::valueType(). First step to reuse ValueType handling in Variable
This commit is contained in:
parent
cfddc8f537
commit
b4cb2505c3
|
@ -365,7 +365,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
|||
scope->definedTypesMap[new_type->name()] = new_type;
|
||||
}
|
||||
|
||||
scope->addVariable(varNameTok, tok, tok, access[scope], new_scope->definedType, scope, &mSettings->library);
|
||||
scope->addVariable(varNameTok, tok, tok, access[scope], new_scope->definedType, scope, mSettings);
|
||||
|
||||
const Token *tok2 = tok->next();
|
||||
|
||||
|
@ -637,9 +637,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->library); // check for variable declaration and add it to new scope if found
|
||||
scope->checkVariable(tok->tokAt(2), 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->library); // check for variable declaration and add it to new scope if found
|
||||
scope->checkVariable(tok->tokAt(2), Throw, mSettings); // check for variable declaration and add it to new scope if found
|
||||
tok = scopeStartTok;
|
||||
} else if (tok->str() == "{") {
|
||||
if (tok->previous()->varId())
|
||||
|
@ -717,7 +717,7 @@ void SymbolDatabase::createSymbolDatabaseVariableInfo()
|
|||
// fill in variable info
|
||||
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
|
||||
// find variables
|
||||
it->getVariableList(&mSettings->library);
|
||||
it->getVariableList(mSettings);
|
||||
}
|
||||
|
||||
// fill in function arguments
|
||||
|
@ -1598,6 +1598,11 @@ void SymbolDatabase::validate() const
|
|||
//validateVariables();
|
||||
}
|
||||
|
||||
Variable::~Variable()
|
||||
{
|
||||
delete mValueType;
|
||||
}
|
||||
|
||||
bool Variable::isPointerArray() const
|
||||
{
|
||||
return isArray() && nameToken() && nameToken()->previous() && (nameToken()->previous()->str() == "*");
|
||||
|
@ -1614,14 +1619,16 @@ const Token * Variable::declEndToken() const
|
|||
return declEnd;
|
||||
}
|
||||
|
||||
void Variable::evaluate(const Library* lib)
|
||||
void Variable::evaluate(const Settings* settings)
|
||||
{
|
||||
unsigned int pointer = 0;
|
||||
mConstness = 0;
|
||||
const Library * const lib = settings ? &settings->library : nullptr;
|
||||
|
||||
if (mNameToken)
|
||||
setFlag(fIsArray, arrayDimensions(lib));
|
||||
|
||||
if (mTypeStartToken)
|
||||
setValueType(ValueType::parseDecl(mTypeStartToken,settings));
|
||||
|
||||
const Token* tok = mTypeStartToken;
|
||||
while (tok && tok->previous() && tok->previous()->isName())
|
||||
tok = tok->previous();
|
||||
|
@ -1637,13 +1644,11 @@ void Variable::evaluate(const Library* lib)
|
|||
setFlag(fIsVolatile, true);
|
||||
else if (tok->str() == "mutable")
|
||||
setFlag(fIsMutable, true);
|
||||
else if (tok->str() == "const") {
|
||||
else if (tok->str() == "const")
|
||||
setFlag(fIsConst, true);
|
||||
mConstness |= 1 << pointer;
|
||||
} else if (tok->str() == "*") {
|
||||
else if (tok->str() == "*") {
|
||||
setFlag(fIsPointer, !isArray() || Token::Match(tok->previous(), "( * %name% )"));
|
||||
setFlag(fIsConst, false); // Points to const, isn't necessarily const itself
|
||||
++pointer;
|
||||
} else if (tok->str() == "&") {
|
||||
if (isReference())
|
||||
setFlag(fIsRValueRef, true);
|
||||
|
@ -1708,6 +1713,15 @@ void Variable::evaluate(const Library* lib)
|
|||
}
|
||||
}
|
||||
|
||||
void Variable::setValueType(const ValueType &valueType)
|
||||
{
|
||||
delete mValueType;
|
||||
mValueType = new ValueType(valueType);
|
||||
if ((mValueType->pointer > 0) && (!isArray() || Token::Match(mNameToken->previous(), "( * %name% )")))
|
||||
setFlag(fIsPointer, true);
|
||||
setFlag(fIsConst, mValueType->constness & (1U << mValueType->pointer));
|
||||
}
|
||||
|
||||
Function::Function(const Tokenizer *mTokenizer, const Token *tok, const Scope *scope, const Token *tokDef, const Token *tokArgDef)
|
||||
: tokenDef(tokDef),
|
||||
argDef(tokArgDef),
|
||||
|
@ -2503,15 +2517,6 @@ bool Variable::arrayDimensions(const Library* lib)
|
|||
return arr;
|
||||
}
|
||||
|
||||
void Variable::setFlags(const ValueType &valuetype)
|
||||
{
|
||||
if (valuetype.constness)
|
||||
setFlag(fIsConst,true);
|
||||
if (valuetype.pointer)
|
||||
setFlag(fIsPointer,true);
|
||||
}
|
||||
|
||||
|
||||
static std::ostream & operator << (std::ostream & s, Scope::ScopeType type)
|
||||
{
|
||||
s << (type == Scope::eGlobal ? "Global" :
|
||||
|
@ -3006,7 +3011,6 @@ void SymbolDatabase::printXml(std::ostream &out) const
|
|||
out << " isPointer=\"" << var->isPointer() << '\"';
|
||||
out << " isReference=\"" << var->isReference() << '\"';
|
||||
out << " isStatic=\"" << var->isStatic() << '\"';
|
||||
out << " constness=\"" << var->constness() << '\"';
|
||||
out << "/>" << std::endl;
|
||||
}
|
||||
out << " </variables>" << std::endl;
|
||||
|
@ -3123,7 +3127,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->library);
|
||||
argumentList.emplace_back(nameTok, startTok, endTok, count++, Argument, argType, functionScope, symbolDatabase->mSettings);
|
||||
|
||||
if (tok->str() == ")") {
|
||||
// check for a variadic function
|
||||
|
@ -3325,7 +3329,7 @@ AccessControl Scope::defaultAccess() const
|
|||
}
|
||||
|
||||
// Get variable list..
|
||||
void Scope::getVariableList(const Library* lib)
|
||||
void Scope::getVariableList(const Settings* settings)
|
||||
{
|
||||
const Token *start;
|
||||
|
||||
|
@ -3426,14 +3430,14 @@ void Scope::getVariableList(const Library* lib)
|
|||
else if (tok->str() == ";")
|
||||
continue;
|
||||
|
||||
tok = checkVariable(tok, varaccess, lib);
|
||||
tok = checkVariable(tok, varaccess, settings);
|
||||
|
||||
if (!tok)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, const Library* lib)
|
||||
const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, const Settings* settings)
|
||||
{
|
||||
// Is it a throw..?
|
||||
if (Token::Match(tok, "throw %any% (") &&
|
||||
|
@ -3494,7 +3498,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
|
|||
if (Token::Match(typestart, "enum|struct"))
|
||||
typestart = typestart->next();
|
||||
|
||||
addVariable(vartok, typestart, vartok->previous(), varaccess, vType, this, lib);
|
||||
addVariable(vartok, typestart, vartok->previous(), varaccess, vType, this, settings);
|
||||
}
|
||||
|
||||
return tok;
|
||||
|
@ -4872,7 +4876,7 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
|||
setValueType(parent->previous(), *vt2);
|
||||
Variable *var = const_cast<Variable *>(parent->previous()->variable());
|
||||
if (var) {
|
||||
var->setFlags(*vt2);
|
||||
var->setValueType(*vt2);
|
||||
if (vt2->typeScope && vt2->typeScope->definedType) {
|
||||
var->type(vt2->typeScope->definedType);
|
||||
if (autoTok->valueType()->pointer == 0)
|
||||
|
@ -4956,7 +4960,7 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
|||
setValueType(parent->previous(), varvt);
|
||||
Variable *var = const_cast<Variable *>(parent->previous()->variable());
|
||||
if (var) {
|
||||
var->setFlags(varvt);
|
||||
var->setValueType(varvt);
|
||||
if (vt2->typeScope && vt2->typeScope->definedType) {
|
||||
var->type(vt2->typeScope->definedType);
|
||||
autoToken->type(vt2->typeScope->definedType);
|
||||
|
@ -4985,7 +4989,7 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
|||
setValueType(parent->previous(), varvt);
|
||||
Variable * var = const_cast<Variable *>(parent->previous()->variable());
|
||||
if (var) {
|
||||
var->setFlags(varvt);
|
||||
var->setValueType(varvt);
|
||||
const Type * type = typeStart->tokAt(4)->type();
|
||||
if (type && type->classScope && type->classScope->definedType) {
|
||||
autoToken->type(type->classScope->definedType);
|
||||
|
|
|
@ -221,7 +221,7 @@ class CPPCHECKLIB Variable {
|
|||
public:
|
||||
Variable(const Token *name_, const Token *start_, const Token *end_,
|
||||
std::size_t index_, AccessControl access_, const Type *type_,
|
||||
const Scope *scope_, const Library* lib)
|
||||
const Scope *scope_, const Settings* settings)
|
||||
: mNameToken(name_),
|
||||
mTypeStartToken(start_),
|
||||
mTypeEndToken(end_),
|
||||
|
@ -230,10 +230,13 @@ public:
|
|||
mFlags(0),
|
||||
mConstness(0),
|
||||
mType(type_),
|
||||
mScope(scope_) {
|
||||
evaluate(lib);
|
||||
mScope(scope_),
|
||||
mValueType(nullptr) {
|
||||
evaluate(settings);
|
||||
}
|
||||
|
||||
~Variable();
|
||||
|
||||
/**
|
||||
* Get name token.
|
||||
* @return name token
|
||||
|
@ -597,12 +600,12 @@ public:
|
|||
return type() && type()->isEnumType();
|
||||
}
|
||||
|
||||
void setFlags(const ValueType &valuetype);
|
||||
|
||||
unsigned int constness() const {
|
||||
return mConstness;
|
||||
const ValueType *valueType() const {
|
||||
return mValueType;
|
||||
}
|
||||
|
||||
void setValueType(const ValueType &valueType);
|
||||
|
||||
private:
|
||||
// only symbol database can change the type
|
||||
friend class SymbolDatabase;
|
||||
|
@ -642,11 +645,13 @@ private:
|
|||
/** @brief pointer to scope this variable is in */
|
||||
const Scope *mScope;
|
||||
|
||||
ValueType *mValueType;
|
||||
|
||||
/** @brief array dimensions */
|
||||
std::vector<Dimension> mDimensions;
|
||||
|
||||
/** @brief fill in information, depending on Tokens given at instantiation */
|
||||
void evaluate(const Library* lib);
|
||||
void evaluate(const Settings* settings);
|
||||
};
|
||||
|
||||
class CPPCHECKLIB Function {
|
||||
|
@ -1008,14 +1013,14 @@ public:
|
|||
|
||||
void addVariable(const Token *token_, const Token *start_,
|
||||
const Token *end_, AccessControl access_, const Type *type_,
|
||||
const Scope *scope_, const Library* lib) {
|
||||
const Scope *scope_, const Settings* settings) {
|
||||
varlist.emplace_back(token_, start_, end_, varlist.size(),
|
||||
access_,
|
||||
type_, scope_, lib);
|
||||
type_, scope_, settings);
|
||||
}
|
||||
|
||||
/** @brief initialize varlist */
|
||||
void getVariableList(const Library* lib);
|
||||
void getVariableList(const Settings* settings);
|
||||
|
||||
const Function *getDestructor() const;
|
||||
|
||||
|
@ -1035,10 +1040,10 @@ public:
|
|||
* @brief check if statement is variable declaration and add it if it is
|
||||
* @param tok pointer to start of statement
|
||||
* @param varaccess access control of statement
|
||||
* @param lib Library instance
|
||||
* @param settings Settings
|
||||
* @return pointer to last token
|
||||
*/
|
||||
const Token *checkVariable(const Token *tok, AccessControl varaccess, const Library* lib);
|
||||
const Token *checkVariable(const Token *tok, AccessControl varaccess, const Settings* settings);
|
||||
|
||||
/**
|
||||
* @brief get variable from name
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "library.h"
|
||||
#include "platform.h"
|
||||
#include "settings.h"
|
||||
#include "symboldatabase.h"
|
||||
|
@ -401,7 +400,7 @@ private:
|
|||
TokenList list(nullptr);
|
||||
list.createTokens(code, "test.c");
|
||||
list.front()->tokAt(3)->link(list.front()->tokAt(7));
|
||||
Variable v(list.front()->next(), list.front(), list.back(), 0, Public, nullptr, nullptr, &settings1.library);
|
||||
Variable v(list.front()->next(), list.front(), list.back(), 0, Public, nullptr, nullptr, &settings1);
|
||||
ASSERT(v.isArray());
|
||||
ASSERT_EQUALS(1U, v.dimensions().size());
|
||||
ASSERT_EQUALS(20U, v.dimension(0));
|
||||
|
@ -413,7 +412,7 @@ private:
|
|||
ASSERT_EQUALS(false, result);
|
||||
ASSERT(nullptr == vartok);
|
||||
ASSERT(nullptr == typetok);
|
||||
Variable v(nullptr, nullptr, nullptr, 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(nullptr, nullptr, nullptr, 0, Public, 0, 0, &settings1);
|
||||
}
|
||||
|
||||
void test_isVariableDeclarationIdentifiesSimpleDeclaration() {
|
||||
|
@ -423,7 +422,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -436,7 +435,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -449,7 +448,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -462,7 +461,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -475,7 +474,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->str());
|
||||
ASSERT_EQUALS("string", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -488,7 +487,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->str());
|
||||
ASSERT_EQUALS("string", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -501,7 +500,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("x", vartok->str());
|
||||
ASSERT_EQUALS("EE", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -514,14 +513,14 @@ private:
|
|||
ASSERT_EQUALS(true, result1);
|
||||
ASSERT_EQUALS("p", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v1(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v1(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &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, 0, 0, &settings1.library);
|
||||
Variable v2(constpointer.tokens()->tokAt(3), constpointer.tokens()->next(), constpointer.tokens()->tokAt(2), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v2.isArray());
|
||||
ASSERT(true == v2.isPointer());
|
||||
ASSERT(false == v2.isConst());
|
||||
|
@ -533,7 +532,7 @@ private:
|
|||
ASSERT_EQUALS(true, result2);
|
||||
ASSERT_EQUALS("p", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v3(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v3(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v3.isArray());
|
||||
ASSERT(true == v3.isPointer());
|
||||
ASSERT(true == v3.isConst());
|
||||
|
@ -556,7 +555,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("first", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -569,7 +568,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("p", vartok->str());
|
||||
ASSERT_EQUALS("EE", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -582,7 +581,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("pp", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -595,7 +594,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("p", vartok->str());
|
||||
ASSERT_EQUALS("int", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -608,7 +607,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("v", vartok->str());
|
||||
ASSERT_EQUALS("string", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(true == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isPointerArray());
|
||||
|
@ -622,7 +621,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("a", vartok->str());
|
||||
ASSERT_EQUALS("A", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(true == v.isArray());
|
||||
ASSERT(false == v.isPointerToArray());
|
||||
|
@ -637,7 +636,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("a", vartok->str());
|
||||
ASSERT_EQUALS("A", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(true == v.isPointer());
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(true == v.isPointerToArray());
|
||||
|
@ -652,7 +651,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("chars", vartok->str());
|
||||
ASSERT_EQUALS("set", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -665,7 +664,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->str());
|
||||
ASSERT_EQUALS("deque", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -678,7 +677,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->str());
|
||||
ASSERT_EQUALS("deque", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(true == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -691,7 +690,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->str());
|
||||
ASSERT_EQUALS("vector", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -704,7 +703,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, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -717,7 +716,7 @@ private:
|
|||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("intsets", vartok->str());
|
||||
ASSERT_EQUALS("deque", typetok->str());
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -728,7 +727,7 @@ private:
|
|||
givenACodeSampleToTokenize var1("int& foo;");
|
||||
bool result1 = si.isVariableDeclaration(var1.tokens(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result1);
|
||||
Variable v1(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v1(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v1.isArray());
|
||||
ASSERT(false == v1.isPointer());
|
||||
ASSERT(true == v1.isReference());
|
||||
|
@ -737,7 +736,7 @@ private:
|
|||
givenACodeSampleToTokenize var2("foo*& bar;");
|
||||
bool result2 = si.isVariableDeclaration(var2.tokens(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result2);
|
||||
Variable v2(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v2(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v2.isArray());
|
||||
ASSERT(true == v2.isPointer());
|
||||
ASSERT(true == v2.isReference());
|
||||
|
@ -746,7 +745,7 @@ private:
|
|||
givenACodeSampleToTokenize var3("std::vector<int>& foo;");
|
||||
bool result3 = si.isVariableDeclaration(var3.tokens(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result3);
|
||||
Variable v3(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v3(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v3.isArray());
|
||||
ASSERT(false == v3.isPointer());
|
||||
ASSERT(true == v3.isReference());
|
||||
|
@ -771,7 +770,7 @@ private:
|
|||
givenACodeSampleToTokenize var("std::string const* s;");
|
||||
bool result = si.isVariableDeclaration(var.tokens()->next(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(true == v.isPointer());
|
||||
ASSERT(false == v.isReference());
|
||||
|
@ -782,7 +781,7 @@ private:
|
|||
givenACodeSampleToTokenize var("int&& i;");
|
||||
bool result = si.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, typetok, vartok->previous(), 0, Public, 0, 0, &settings1);
|
||||
ASSERT(false == v.isArray());
|
||||
ASSERT(false == v.isPointer());
|
||||
ASSERT(true == v.isReference());
|
||||
|
@ -880,7 +879,7 @@ private:
|
|||
list.createTokens(code, "test.cpp");
|
||||
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1);
|
||||
static const std::set<std::string> types = { "string", "wstring" };
|
||||
static const std::set<std::string> no_types = { "set" };
|
||||
ASSERT_EQUALS(true, v.isStlType());
|
||||
|
@ -896,7 +895,7 @@ private:
|
|||
list.front()->tokAt(3)->link(list.front()->tokAt(5));
|
||||
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &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());
|
||||
|
@ -911,7 +910,7 @@ private:
|
|||
list.createTokens(code, "test.cpp");
|
||||
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1.library);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1);
|
||||
static const std::set<std::string> types = { "bitset", "set", "vector" };
|
||||
ASSERT_EQUALS(false, v.isStlType());
|
||||
ASSERT_EQUALS(false, v.isStlType(types));
|
||||
|
@ -5939,7 +5938,7 @@ private:
|
|||
const Token *autotok = tokenizer.tokens()->next();
|
||||
ASSERT(autotok && autotok->isStandardType());
|
||||
const Variable *var = db ? db->getVariableFromVarId(1) : nullptr;
|
||||
ASSERT(var && var->isPointer() && var->isConst());
|
||||
ASSERT(var && var->isPointer() && !var->isConst());
|
||||
}
|
||||
|
||||
void auto2() {
|
||||
|
|
Loading…
Reference in New Issue