Fixed Function::retDef initialization:
- Move/Copy Constructors and Destructors do not have a return type neither - Fixed crash in SymbolDatabase::printOut - Added testing
This commit is contained in:
parent
5d7518aa57
commit
6b47ed414a
|
@ -422,7 +422,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
}
|
||||
|
||||
// find the return type
|
||||
if (function.type != Function::eConstructor) {
|
||||
if (!function.isConstructor() && !function.isDestructor()) {
|
||||
while (tok1 && Token::Match(tok1->next(), "virtual|static|friend|const|struct|union"))
|
||||
tok1 = tok1->next();
|
||||
|
||||
|
@ -1744,7 +1744,8 @@ void SymbolDatabase::printOut(const char *title) const
|
|||
std::cout << " retFuncPtr: " << (func->retFuncPtr ? "true" : "false") << std::endl;
|
||||
std::cout << " tokenDef: " << func->tokenDef->str() << " " <<_tokenizer->list.fileLine(func->tokenDef) << std::endl;
|
||||
std::cout << " argDef: " << _tokenizer->list.fileLine(func->argDef) << std::endl;
|
||||
std::cout << " retDef: " << func->retDef->str() << " " <<_tokenizer->list.fileLine(func->retDef) << std::endl;
|
||||
if (!func->isConstructor() && !func->isDestructor())
|
||||
std::cout << " retDef: " << func->retDef->str() << " " <<_tokenizer->list.fileLine(func->retDef) << std::endl;
|
||||
std::cout << " retType: " << func->retType << std::endl;
|
||||
if (func->hasBody) {
|
||||
std::cout << " token: " << _tokenizer->list.fileLine(func->token) << std::endl;
|
||||
|
|
|
@ -638,6 +638,7 @@ private:
|
|||
ASSERT(function && function->token == tokenizer.tokens()->next());
|
||||
ASSERT(function && function->hasBody);
|
||||
ASSERT(function && function->functionScope == scope && scope->function == function && function->nestedIn != scope);
|
||||
ASSERT(function && function->retDef == tokenizer.tokens());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,6 +660,7 @@ private:
|
|||
ASSERT(function && function->token == tokenizer.tokens()->tokAt(4));
|
||||
ASSERT(function && function->hasBody && function->isInline);
|
||||
ASSERT(function && function->functionScope == scope && scope->function == function && function->nestedIn == db->findScopeByName("Fred"));
|
||||
ASSERT(function && function->retDef == tokenizer.tokens()->tokAt(3));
|
||||
|
||||
ASSERT(db && db->findScopeByName("Fred") && db->findScopeByName("Fred")->definedType->getFunction("func") == function);
|
||||
}
|
||||
|
@ -803,21 +805,25 @@ private:
|
|||
GET_SYMBOL_DB("class Foo { Foo(Foo f); };");
|
||||
const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
|
||||
ASSERT(db && ctor && ctor->type == Function::eConstructor && !ctor->isExplicit);
|
||||
ASSERT(ctor && ctor->retDef == 0);
|
||||
}
|
||||
{
|
||||
GET_SYMBOL_DB("class Foo { explicit Foo(Foo f); };");
|
||||
const Function* ctor = tokenizer.tokens()->tokAt(4)->function();
|
||||
ASSERT(db && ctor && ctor->type == Function::eConstructor && ctor->isExplicit);
|
||||
ASSERT(ctor && ctor->retDef == 0);
|
||||
}
|
||||
{
|
||||
GET_SYMBOL_DB("class Foo { Foo(Foo& f); };");
|
||||
const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
|
||||
ASSERT(db && ctor && ctor->type == Function::eCopyConstructor);
|
||||
ASSERT(ctor && ctor->retDef == 0);
|
||||
}
|
||||
{
|
||||
GET_SYMBOL_DB("class Foo { Foo(Foo&& f); };");
|
||||
const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
|
||||
ASSERT(db && ctor && ctor->type == Function::eMoveConstructor);
|
||||
ASSERT(ctor && ctor->retDef == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue