Fixed #8560 (Symboldatabase lacks entry for C++11 overloaded member function) (#1217)

This commit is contained in:
IOBYTE 2018-05-09 14:16:08 -04:00 committed by amai2012
parent 50aa3620da
commit 5452c4dc4a
2 changed files with 27 additions and 1 deletions

View File

@ -1407,7 +1407,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
}
// skip over const, noexcept, throw and override specifiers
while (Token::Match(tok2, "const|noexcept|throw|override")) {
while (Token::Match(tok2, "const|noexcept|throw|override|final")) {
tok2 = tok2->next();
if (tok2 && tok2->str() == "(")
tok2 = tok2->link()->next();

View File

@ -285,6 +285,7 @@ private:
TEST_CASE(symboldatabase65);
TEST_CASE(symboldatabase66); // #8540
TEST_CASE(symboldatabase67); // #8538
TEST_CASE(symboldatabase68); // #8560
TEST_CASE(enum1);
TEST_CASE(enum2);
@ -3838,6 +3839,31 @@ private:
ASSERT(f && f->isNoExcept());
}
void symboldatabase68() { // #8560
GET_SYMBOL_DB("struct Bar {\n"
" virtual std::string get_endpoint_url() const noexcept;\n"
"};\n"
"struct Foo : Bar {\n"
" virtual std::string get_endpoint_url() const noexcept override final;\n"
"};");
const Token *f = db ? Token::findsimplematch(tokenizer.tokens(), "get_endpoint_url ( ) const noexcept ;") : nullptr;
ASSERT(f != nullptr);
ASSERT(f && f->function() && f->function()->token->linenr() == 2);
ASSERT(f && f->function() && f->function()->isVirtual());
ASSERT(f && f->function() && !f->function()->hasOverrideSpecifier());
ASSERT(f && f->function() && !f->function()->hasFinalSpecifier());
ASSERT(f && f->function() && f->function()->isConst());
ASSERT(f && f->function() && f->function()->isNoExcept());
f = db ? Token::findsimplematch(tokenizer.tokens(), "get_endpoint_url ( ) const noexcept override final ;") : nullptr;
ASSERT(f != nullptr);
ASSERT(f && f->function() && f->function()->token->linenr() == 5);
ASSERT(f && f->function() && f->function()->isVirtual());
ASSERT(f && f->function() && f->function()->hasOverrideSpecifier());
ASSERT(f && f->function() && f->function()->hasFinalSpecifier());
ASSERT(f && f->function() && f->function()->isConst());
ASSERT(f && f->function() && f->function()->isNoExcept());
}
void enum1() {
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");