From 9dce0dd75c4a15f4e6f9e5217d343152e2863ce4 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 20 Jan 2011 18:02:52 +0100 Subject: [PATCH] Symbol database: refactoring of classAndStructTypes parsing. ticket: #2468 --- lib/symboldatabase.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a174e5a15..52b3cb28e 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -38,13 +38,6 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) : _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger) { - // fill the classAndStructTypes set.. - for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) - { - if (Token::Match(tok, "class|struct %var% [:{;]")) - classAndStructTypes.insert(tok->next()->str()); - } - // find all namespaces (class,struct and namespace) Scope *info = new Scope(this, NULL, NULL); spaceInfoList.push_back(info); @@ -59,6 +52,9 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti // only create base list for classes and structures if (new_info->isClassOrStruct()) { + // fill the classAndStructTypes set.. + classAndStructTypes.insert(new_info->className); + // goto initial '{' tok2 = initBaseInfo(new_info, tok); } @@ -81,6 +77,17 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti tok = tok2; } + // forward declaration + else if (Token::Match(tok, "class|struct %var% ;")) + { + // fill the classAndStructTypes set.. + classAndStructTypes.insert(tok->next()->str()); + + /** @todo save forward declarations in database someday */ + tok = tok->tokAt(2); + continue; + } + else { // check for end of space