SymbolDatabase: Refactor SymbolDatabase: variable list
This commit is contained in:
parent
6208ee4af1
commit
ca8e19c96d
|
@ -1106,8 +1106,7 @@ static bool isVLAIndex(const Token *index)
|
||||||
|
|
||||||
void CheckBufferOverrun::negativeArraySize()
|
void CheckBufferOverrun::negativeArraySize()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 1; i <= _tokenizer->varIdCount(); i++) {
|
for (const Variable *var : symbolDatabase->variableList()) {
|
||||||
const Variable * const var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (!var || !var->isArray())
|
if (!var || !var->isArray())
|
||||||
continue;
|
continue;
|
||||||
const Token * const nameToken = var->nameToken();
|
const Token * const nameToken = var->nameToken();
|
||||||
|
|
|
@ -1560,8 +1560,7 @@ void CheckClass::virtualDestructor()
|
||||||
// pointer variables of type 'Base *'
|
// pointer variables of type 'Base *'
|
||||||
std::set<unsigned int> baseClassPointers;
|
std::set<unsigned int> baseClassPointers;
|
||||||
|
|
||||||
for (std::size_t k = 1; k < symbolDatabase->getVariableListSize(); k++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(k);
|
|
||||||
if (var && var->isPointer() && var->type() == derivedFrom)
|
if (var && var->isPointer() && var->type() == derivedFrom)
|
||||||
baseClassPointers.insert(var->declarationId());
|
baseClassPointers.insert(var->declarationId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,9 +126,7 @@ void CheckIO::checkFileUsage()
|
||||||
std::map<unsigned int, Filepointer> filepointers;
|
std::map<unsigned int, Filepointer> filepointers;
|
||||||
|
|
||||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
const std::size_t varListSize = symbolDatabase->getVariableListSize();
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
for (std::size_t i = 1; i < varListSize; ++i) {
|
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (!var || !var->declarationId() || var->isArray() || !Token::simpleMatch(var->typeStartToken(), "FILE *"))
|
if (!var || !var->declarationId() || var->isArray() || !Token::simpleMatch(var->typeStartToken(), "FILE *"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -143,9 +141,7 @@ void CheckIO::checkFileUsage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t j = 0; j < functions; ++j) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[j];
|
|
||||||
unsigned int indent = 0;
|
unsigned int indent = 0;
|
||||||
for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
|
for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
|
||||||
if (tok->str() == "{")
|
if (tok->str() == "{")
|
||||||
|
|
|
@ -2201,16 +2201,13 @@ static bool isInMemberFunc(const Scope* scope)
|
||||||
void CheckMemoryLeakInFunction::check()
|
void CheckMemoryLeakInFunction::check()
|
||||||
{
|
{
|
||||||
// Check locking/unlocking of global resources..
|
// Check locking/unlocking of global resources..
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
|
||||||
if (!scope->hasInlineOrLambdaFunction())
|
if (!scope->hasInlineOrLambdaFunction())
|
||||||
checkScope(scope->bodyStart->next(), emptyString, 0, scope->functionOf != nullptr, 1);
|
checkScope(scope->bodyStart->next(), emptyString, 0, scope->functionOf != nullptr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check variables..
|
// Check variables..
|
||||||
for (unsigned int i = 1; i < symbolDatabase->getVariableListSize(); i++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (!var || (!var->isLocal() && !var->isArgument()) || var->isStatic() || !var->scope())
|
if (!var || (!var->isLocal() && !var->isArgument()) || var->isStatic() || !var->scope())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -2232,9 +2229,9 @@ void CheckMemoryLeakInFunction::check()
|
||||||
sz = 1;
|
sz = 1;
|
||||||
|
|
||||||
if (var->isArgument())
|
if (var->isArgument())
|
||||||
checkScope(var->scope()->bodyStart->next(), var->name(), i, isInMemberFunc(var->scope()), sz);
|
checkScope(var->scope()->bodyStart->next(), var->name(), var->declarationId(), isInMemberFunc(var->scope()), sz);
|
||||||
else
|
else
|
||||||
checkScope(var->nameToken(), var->name(), i, isInMemberFunc(var->scope()), sz);
|
checkScope(var->nameToken(), var->name(), var->declarationId(), isInMemberFunc(var->scope()), sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -2434,8 +2431,7 @@ void CheckMemoryLeakInClass::publicAllocationError(const Token *tok, const std::
|
||||||
void CheckMemoryLeakStructMember::check()
|
void CheckMemoryLeakStructMember::check()
|
||||||
{
|
{
|
||||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
for (unsigned int i = 1; i < symbolDatabase->getVariableListSize(); i++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (!var || !var->isLocal() || var->isStatic())
|
if (!var || !var->isLocal() || var->isStatic())
|
||||||
continue;
|
continue;
|
||||||
if (var->typeEndToken()->isStandardType())
|
if (var->typeEndToken()->isStandardType())
|
||||||
|
|
|
@ -1096,8 +1096,7 @@ void CheckOther::checkVariableScope()
|
||||||
|
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
for (unsigned int i = 1; i < symbolDatabase->getVariableListSize(); i++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (!var || !var->isLocal() || (!var->isPointer() && !var->typeStartToken()->isStandardType()))
|
if (!var || !var->isLocal() || (!var->isPointer() && !var->typeStartToken()->isStandardType()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1416,8 +1415,7 @@ void CheckOther::checkPassByReference()
|
||||||
|
|
||||||
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
for (unsigned int i = 1; i < symbolDatabase->getVariableListSize(); i++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (!var || !var->isArgument() || !var->isClass() || var->isPointer() || var->isArray() || var->isReference() || var->isEnumType())
|
if (!var || !var->isArgument() || !var->isClass() || var->isPointer() || var->isArray() || var->isReference() || var->isEnumType())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -2234,9 +2232,7 @@ void CheckOther::checkRedundantCopy()
|
||||||
|
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
for (std::size_t i = 1; i < symbolDatabase->getVariableListSize(); i++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
|
|
||||||
if (!var || var->isReference() || !var->isConst() || var->isPointer() || (!var->type() && !var->isStlType())) // bailout if var is of standard type, if it is a pointer or non-const
|
if (!var || var->isReference() || !var->isConst() || var->isPointer() || (!var->type() && !var->isStlType())) // bailout if var is of standard type, if it is a pointer or non-const
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -130,13 +130,13 @@ void CheckStl::iterators()
|
||||||
{
|
{
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
for (unsigned int iteratorId = 1; iteratorId < symbolDatabase->getVariableListSize(); iteratorId++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(iteratorId);
|
|
||||||
|
|
||||||
bool inconclusiveType=false;
|
bool inconclusiveType=false;
|
||||||
if (!isIterator(var, inconclusiveType))
|
if (!isIterator(var, inconclusiveType))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const unsigned int iteratorId = var->declarationId();
|
||||||
|
|
||||||
// the validIterator flag says if the iterator has a valid value or not
|
// the validIterator flag says if the iterator has a valid value or not
|
||||||
bool validIterator = Token::Match(var->nameToken()->next(), "[(=:{]");
|
bool validIterator = Token::Match(var->nameToken()->next(), "[(=:{]");
|
||||||
const Scope* invalidationScope = nullptr;
|
const Scope* invalidationScope = nullptr;
|
||||||
|
@ -389,8 +389,7 @@ void CheckStl::mismatchingContainers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (unsigned int varid = 0; varid < symbolDatabase->getVariableListSize(); varid++) {
|
for (const Variable *var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(varid);
|
|
||||||
if (var && var->isStlStringType() && Token::Match(var->nameToken(), "%var% (") && Token::Match(var->nameToken()->tokAt(2), pattern2.c_str())) {
|
if (var && var->isStlStringType() && Token::Match(var->nameToken(), "%var% (") && Token::Match(var->nameToken()->tokAt(2), pattern2.c_str())) {
|
||||||
if (var->nameToken()->strAt(2) != var->nameToken()->strAt(8)) {
|
if (var->nameToken()->strAt(2) != var->nameToken()->strAt(8)) {
|
||||||
mismatchingContainersError(var->nameToken());
|
mismatchingContainersError(var->nameToken());
|
||||||
|
@ -605,13 +604,13 @@ void CheckStl::pushback()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterator becomes invalid after reserve, resize, insert, push_back or push_front..
|
// Iterator becomes invalid after reserve, resize, insert, push_back or push_front..
|
||||||
for (unsigned int iteratorId = 1; iteratorId < symbolDatabase->getVariableListSize(); iteratorId++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(iteratorId);
|
|
||||||
|
|
||||||
// Check that its an iterator
|
// Check that its an iterator
|
||||||
if (!var || !var->isLocal() || !Token::Match(var->typeEndToken(), "iterator|const_iterator|reverse_iterator|const_reverse_iterator"))
|
if (!var || !var->isLocal() || !Token::Match(var->typeEndToken(), "iterator|const_iterator|reverse_iterator|const_reverse_iterator"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const unsigned int iteratorId = var->declarationId();
|
||||||
|
|
||||||
// ... on std::vector
|
// ... on std::vector
|
||||||
if (!Token::Match(var->typeStartToken(), "std| ::| vector <"))
|
if (!Token::Match(var->typeStartToken(), "std| ::| vector <"))
|
||||||
continue;
|
continue;
|
||||||
|
@ -726,8 +725,7 @@ void CheckStl::invalidPointerError(const Token *tok, const std::string &func, co
|
||||||
void CheckStl::stlBoundaries()
|
void CheckStl::stlBoundaries()
|
||||||
{
|
{
|
||||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
for (unsigned int iteratorId = 1; iteratorId < symbolDatabase->getVariableListSize(); iteratorId++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(iteratorId);
|
|
||||||
if (!var || !var->scope() || !var->scope()->isExecutable())
|
if (!var || !var->scope() || !var->scope()->isExecutable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -1342,8 +1342,7 @@ void CheckUnusedVar::checkStructMemberUsage()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// bail out for extern/global struct
|
// bail out for extern/global struct
|
||||||
for (size_t i = 0; i < symbolDatabase->getVariableListSize(); i++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (var && (var->isExtern() || (var->isGlobal() && !var->isStatic())) && var->typeEndToken()->str() == scope->className) {
|
if (var && (var->isExtern() || (var->isGlobal() && !var->isStatic())) && var->typeEndToken()->str() == scope->className) {
|
||||||
bailout = true;
|
bailout = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -96,8 +96,7 @@ void CheckVaarg::referenceAs_va_start_error(const Token *tok, const std::string&
|
||||||
void CheckVaarg::va_list_usage()
|
void CheckVaarg::va_list_usage()
|
||||||
{
|
{
|
||||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
for (unsigned int varid = 1; varid < symbolDatabase->getVariableListSize(); varid++) {
|
for (const Variable* var : symbolDatabase->variableList()) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(varid);
|
|
||||||
if (!var || var->isPointer() || var->isReference() || var->isArray() || !var->scope() || var->typeStartToken()->str() != "va_list")
|
if (!var || var->isPointer() || var->isReference() || var->isArray() || !var->scope() || var->typeStartToken()->str() != "va_list")
|
||||||
continue;
|
continue;
|
||||||
if (!var->isLocal() && !var->isArgument()) // Check only local variables and arguments
|
if (!var->isLocal() && !var->isArgument()) // Check only local variables and arguments
|
||||||
|
|
|
@ -1164,8 +1164,8 @@ public:
|
||||||
return _variableList.at(varId);
|
return _variableList.at(varId);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t getVariableListSize() const {
|
const std::vector<const Variable *> & variableList() const {
|
||||||
return _variableList.size();
|
return _variableList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1750,8 +1750,7 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
|
||||||
createSymbolDatabase();
|
createSymbolDatabase();
|
||||||
|
|
||||||
// Use symbol database to identify rvalue references. Split && to & &. This is safe, since it doesn't delete any tokens (which might be referenced by symbol database)
|
// Use symbol database to identify rvalue references. Split && to & &. This is safe, since it doesn't delete any tokens (which might be referenced by symbol database)
|
||||||
for (std::size_t i = 0; i < _symbolDatabase->getVariableListSize(); i++) {
|
for (const Variable* var : _symbolDatabase->variableList()) {
|
||||||
const Variable* var = _symbolDatabase->getVariableFromVarId(i);
|
|
||||||
if (var && var->isRValueReference()) {
|
if (var && var->isRValueReference()) {
|
||||||
Token* endTok = const_cast<Token*>(var->typeEndToken());
|
Token* endTok = const_cast<Token*>(var->typeEndToken());
|
||||||
endTok->str("&");
|
endTok->str("&");
|
||||||
|
@ -4067,8 +4066,7 @@ void Tokenizer::printDebugOutput(unsigned int simplification) const
|
||||||
printUnknownTypes();
|
printUnknownTypes();
|
||||||
|
|
||||||
// the typeStartToken() should come before typeEndToken()
|
// the typeStartToken() should come before typeEndToken()
|
||||||
for (unsigned int varid = 1; varid < _symbolDatabase->getVariableListSize(); varid++) {
|
for (const Variable *var : _symbolDatabase->variableList()) {
|
||||||
const Variable *var = _symbolDatabase->getVariableFromVarId(varid);
|
|
||||||
if (!var)
|
if (!var)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -377,7 +377,7 @@ private:
|
||||||
ASSERT(db != nullptr);
|
ASSERT(db != nullptr);
|
||||||
if (!db)
|
if (!db)
|
||||||
return;
|
return;
|
||||||
ASSERT(db->getVariableListSize() == 2); // the first one is not used
|
ASSERT(db->variableList().size() == 2); // the first one is not used
|
||||||
const Variable * v = db->getVariableFromVarId(1);
|
const Variable * v = db->getVariableFromVarId(1);
|
||||||
ASSERT(v != nullptr);
|
ASSERT(v != nullptr);
|
||||||
if (!v)
|
if (!v)
|
||||||
|
@ -857,8 +857,8 @@ private:
|
||||||
if (!db)
|
if (!db)
|
||||||
return;
|
return;
|
||||||
ASSERT(db->scopeList.back().type == Scope::eFor);
|
ASSERT(db->scopeList.back().type == Scope::eFor);
|
||||||
ASSERT_EQUALS(2, db->getVariableListSize());
|
ASSERT_EQUALS(2, db->variableList().size());
|
||||||
if (db->getVariableListSize() < 2)
|
if (db->variableList().size() < 2)
|
||||||
return;
|
return;
|
||||||
const Variable* e = db->getVariableFromVarId(1);
|
const Variable* e = db->getVariableFromVarId(1);
|
||||||
ASSERT(e && e->isReference() && e->isLocal());
|
ASSERT(e && e->isReference() && e->isLocal());
|
||||||
|
@ -965,7 +965,7 @@ private:
|
||||||
"const double Foo::d = 5.0;");
|
"const double Foo::d = 5.0;");
|
||||||
|
|
||||||
const Variable* v = db->getVariableFromVarId(1);
|
const Variable* v = db->getVariableFromVarId(1);
|
||||||
ASSERT(v && db->getVariableListSize() == 2);
|
ASSERT(v && db->variableList().size() == 2);
|
||||||
ASSERT(v && v->isStatic() && v->isConst() && v->isPrivate());
|
ASSERT(v && v->isStatic() && v->isConst() && v->isPrivate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,7 +975,7 @@ private:
|
||||||
|
|
||||||
const Variable* v = db->getVariableFromVarId(2);
|
const Variable* v = db->getVariableFromVarId(2);
|
||||||
// three elements: varId 0 also counts via a fake-entry
|
// three elements: varId 0 also counts via a fake-entry
|
||||||
ASSERT(v && db->getVariableListSize() == 3);
|
ASSERT(v && db->variableList().size() == 3);
|
||||||
|
|
||||||
ASSERT_THROW(db->getVariableFromVarId(3), std::out_of_range);
|
ASSERT_THROW(db->getVariableFromVarId(3), std::out_of_range);
|
||||||
}
|
}
|
||||||
|
@ -1304,7 +1304,7 @@ private:
|
||||||
ASSERT(db != nullptr);
|
ASSERT(db != nullptr);
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
ASSERT_EQUALS(10, db->getVariableListSize() - 1);
|
ASSERT_EQUALS(10, db->variableList().size() - 1);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->dimensions().size() == 1);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->dimensions().size() == 1);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(2) != nullptr);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(2) != nullptr);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->dimensions().size() == 0);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->dimensions().size() == 0);
|
||||||
|
@ -1325,7 +1325,7 @@ private:
|
||||||
ASSERT(db != nullptr);
|
ASSERT(db != nullptr);
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
ASSERT_EQUALS(1, db->getVariableListSize() - 1);
|
ASSERT_EQUALS(1, db->variableList().size() - 1);
|
||||||
ASSERT_EQUALS(true, db->getVariableFromVarId(1) != nullptr);
|
ASSERT_EQUALS(true, db->getVariableFromVarId(1) != nullptr);
|
||||||
if (db->getVariableFromVarId(1))
|
if (db->getVariableFromVarId(1))
|
||||||
ASSERT_EQUALS("pFun", db->getVariableFromVarId(1)->name());
|
ASSERT_EQUALS("pFun", db->getVariableFromVarId(1)->name());
|
||||||
|
@ -1660,7 +1660,7 @@ private:
|
||||||
"const char m[];\n"
|
"const char m[];\n"
|
||||||
"void f(const char* const l;) {}");
|
"void f(const char* const l;) {}");
|
||||||
|
|
||||||
ASSERT(db && db->getVariableListSize() == 6 && db->getVariableFromVarId(1) && db->getVariableFromVarId(2) && db->getVariableFromVarId(3) && db->getVariableFromVarId(4) && db->getVariableFromVarId(5));
|
ASSERT(db && db->variableList().size() == 6 && db->getVariableFromVarId(1) && db->getVariableFromVarId(2) && db->getVariableFromVarId(3) && db->getVariableFromVarId(4) && db->getVariableFromVarId(5));
|
||||||
if (db && db->getVariableFromVarId(1) && db->getVariableFromVarId(2) && db->getVariableFromVarId(3) && db->getVariableFromVarId(4) && db->getVariableFromVarId(5)) {
|
if (db && db->getVariableFromVarId(1) && db->getVariableFromVarId(2) && db->getVariableFromVarId(3) && db->getVariableFromVarId(4) && db->getVariableFromVarId(5)) {
|
||||||
ASSERT_EQUALS("std", db->getVariableFromVarId(1)->typeStartToken()->str());
|
ASSERT_EQUALS("std", db->getVariableFromVarId(1)->typeStartToken()->str());
|
||||||
ASSERT_EQUALS("std", db->getVariableFromVarId(2)->typeStartToken()->str());
|
ASSERT_EQUALS("std", db->getVariableFromVarId(2)->typeStartToken()->str());
|
||||||
|
@ -1727,7 +1727,7 @@ private:
|
||||||
void functionArgs1() {
|
void functionArgs1() {
|
||||||
{
|
{
|
||||||
GET_SYMBOL_DB("void f(std::vector<std::string>, const std::vector<int> & v) { }");
|
GET_SYMBOL_DB("void f(std::vector<std::string>, const std::vector<int> & v) { }");
|
||||||
ASSERT_EQUALS(1+1, db->getVariableListSize());
|
ASSERT_EQUALS(1+1, db->variableList().size());
|
||||||
const Variable* v = db->getVariableFromVarId(1);
|
const Variable* v = db->getVariableFromVarId(1);
|
||||||
ASSERT(v && v->isReference() && v->isConst() && v->isArgument());
|
ASSERT(v && v->isReference() && v->isConst() && v->isArgument());
|
||||||
const Scope* f = db->findScopeByName("f");
|
const Scope* f = db->findScopeByName("f");
|
||||||
|
@ -1738,7 +1738,7 @@ private:
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
GET_SYMBOL_DB("void g(std::map<std::string, std::vector<int> > m) { }");
|
GET_SYMBOL_DB("void g(std::map<std::string, std::vector<int> > m) { }");
|
||||||
ASSERT_EQUALS(1+1, db->getVariableListSize());
|
ASSERT_EQUALS(1+1, db->variableList().size());
|
||||||
const Variable* m = db->getVariableFromVarId(1);
|
const Variable* m = db->getVariableFromVarId(1);
|
||||||
ASSERT(m && !m->isReference() && !m->isConst() && m->isArgument() && m->isClass());
|
ASSERT(m && !m->isReference() && !m->isConst() && m->isArgument() && m->isClass());
|
||||||
const Scope* g = db->findScopeByName("g");
|
const Scope* g = db->findScopeByName("g");
|
||||||
|
@ -2193,7 +2193,7 @@ private:
|
||||||
"}";
|
"}";
|
||||||
GET_SYMBOL_DB(str);
|
GET_SYMBOL_DB(str);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
ASSERT(db && db->getVariableListSize() == 5); // index 0 + 4 variables
|
ASSERT(db && db->variableList().size() == 5); // index 0 + 4 variables
|
||||||
ASSERT(db && db->scopeList.size() == 7); // global + function + try + 4 catch
|
ASSERT(db && db->scopeList.size() == 7); // global + function + try + 4 catch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2471,7 +2471,7 @@ private:
|
||||||
"}";
|
"}";
|
||||||
GET_SYMBOL_DB(str);
|
GET_SYMBOL_DB(str);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
ASSERT(db && db->getVariableListSize() == 2); // index 0 + 1 variable
|
ASSERT(db && db->variableList().size() == 2); // index 0 + 1 variable
|
||||||
}
|
}
|
||||||
|
|
||||||
// ticket #3561 (throw C)
|
// ticket #3561 (throw C)
|
||||||
|
@ -2481,7 +2481,7 @@ private:
|
||||||
"}";
|
"}";
|
||||||
GET_SYMBOL_DB_C(str);
|
GET_SYMBOL_DB_C(str);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
ASSERT(db && db->getVariableListSize() == 2); // index 0 + 1 variable
|
ASSERT(db && db->variableList().size() == 2); // index 0 + 1 variable
|
||||||
}
|
}
|
||||||
|
|
||||||
// ticket #3543 (segmentation fault)
|
// ticket #3543 (segmentation fault)
|
||||||
|
@ -2617,8 +2617,8 @@ private:
|
||||||
ASSERT(Fred && Fred->classDef && Fred->classScope && Fred->enclosingScope && Fred->name() == "Fred");
|
ASSERT(Fred && Fred->classDef && Fred->classScope && Fred->enclosingScope && Fred->name() == "Fred");
|
||||||
ASSERT(Wilma && Wilma->classDef && Wilma->classScope && Wilma->enclosingScope && Wilma->name() == "Wilma");
|
ASSERT(Wilma && Wilma->classDef && Wilma->classScope && Wilma->enclosingScope && Wilma->name() == "Wilma");
|
||||||
ASSERT(Barney && Barney->classDef && Barney->classScope && Barney->enclosingScope && Barney->name() == "Barney");
|
ASSERT(Barney && Barney->classDef && Barney->classScope && Barney->enclosingScope && Barney->name() == "Barney");
|
||||||
ASSERT(db->getVariableListSize() == 5);
|
ASSERT(db->variableList().size() == 5);
|
||||||
if (db->getVariableListSize() != 5)
|
if (db->variableList().size() != 5)
|
||||||
return;
|
return;
|
||||||
ASSERT(db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->type() && db->getVariableFromVarId(1)->type()->name() == "Barney");
|
ASSERT(db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->type() && db->getVariableFromVarId(1)->type()->name() == "Barney");
|
||||||
ASSERT(db->getVariableFromVarId(2) && db->getVariableFromVarId(2)->type() && db->getVariableFromVarId(2)->type()->name() == "Wilma");
|
ASSERT(db->getVariableFromVarId(2) && db->getVariableFromVarId(2)->type() && db->getVariableFromVarId(2)->type()->name() == "Wilma");
|
||||||
|
@ -2673,9 +2673,9 @@ private:
|
||||||
" int l ( 1 );\n"
|
" int l ( 1 );\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT(db != nullptr);
|
ASSERT(db != nullptr);
|
||||||
ASSERT_EQUALS(4U, db->getVariableListSize() - 1);
|
ASSERT_EQUALS(4U, db->variableList().size() - 1);
|
||||||
ASSERT_EQUALS(2U, db->scopeList.size());
|
ASSERT_EQUALS(2U, db->scopeList.size());
|
||||||
for (std::size_t i = 1U; i < db->getVariableListSize(); i++)
|
for (std::size_t i = 1U; i < db->variableList().size(); i++)
|
||||||
ASSERT(db->getVariableFromVarId(i) != nullptr);
|
ASSERT(db->getVariableFromVarId(i) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2695,8 +2695,8 @@ private:
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
ASSERT(db != nullptr);
|
ASSERT(db != nullptr);
|
||||||
ASSERT_EQUALS(4U, db->getVariableListSize() - 1);
|
ASSERT_EQUALS(4U, db->variableList().size() - 1);
|
||||||
for (std::size_t i = 1U; i < db->getVariableListSize(); i++)
|
for (std::size_t i = 1U; i < db->variableList().size(); i++)
|
||||||
ASSERT(db->getVariableFromVarId(i) != nullptr);
|
ASSERT(db->getVariableFromVarId(i) != nullptr);
|
||||||
|
|
||||||
ASSERT_EQUALS(4U, db->scopeList.size());
|
ASSERT_EQUALS(4U, db->scopeList.size());
|
||||||
|
@ -2826,7 +2826,7 @@ private:
|
||||||
ASSERT(db != nullptr);
|
ASSERT(db != nullptr);
|
||||||
if (db) {
|
if (db) {
|
||||||
ASSERT_EQUALS(2, db->scopeList.size());
|
ASSERT_EQUALS(2, db->scopeList.size());
|
||||||
ASSERT_EQUALS(2, db->getVariableListSize()-1);
|
ASSERT_EQUALS(2, db->variableList().size()-1);
|
||||||
ASSERT(db->getVariableFromVarId(1) != nullptr);
|
ASSERT(db->getVariableFromVarId(1) != nullptr);
|
||||||
ASSERT(db->getVariableFromVarId(2) != nullptr);
|
ASSERT(db->getVariableFromVarId(2) != nullptr);
|
||||||
}
|
}
|
||||||
|
@ -3495,7 +3495,7 @@ private:
|
||||||
ASSERT_EQUALS(true, scope->enumeratorList[1].value_known);
|
ASSERT_EQUALS(true, scope->enumeratorList[1].value_known);
|
||||||
ASSERT_EQUALS(2, scope->enumeratorList[1].value);
|
ASSERT_EQUALS(2, scope->enumeratorList[1].value);
|
||||||
|
|
||||||
ASSERT(db->getVariableListSize() == 6); // the first one is not used
|
ASSERT(db->variableList().size() == 6); // the first one is not used
|
||||||
const Variable * v = db->getVariableFromVarId(1);
|
const Variable * v = db->getVariableFromVarId(1);
|
||||||
ASSERT(v != nullptr);
|
ASSERT(v != nullptr);
|
||||||
if (!v)
|
if (!v)
|
||||||
|
@ -3587,7 +3587,7 @@ private:
|
||||||
ASSERT(db != nullptr);
|
ASSERT(db != nullptr);
|
||||||
if (!db)
|
if (!db)
|
||||||
return;
|
return;
|
||||||
ASSERT(db->getVariableListSize() == 13); // the first one is not used
|
ASSERT(db->variableList().size() == 13); // the first one is not used
|
||||||
const Variable * v;
|
const Variable * v;
|
||||||
unsigned int id = 1;
|
unsigned int id = 1;
|
||||||
TEST(settings1.sizeof_int);
|
TEST(settings1.sizeof_int);
|
||||||
|
|
Loading…
Reference in New Issue