diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a1ae1bc6a..372aca40c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4811,72 +4811,7 @@ bool Tokenizer::simplifyTokenList() if (_settings->debugwarnings) { - getSymbolDatabase(); - - std::set unknowns; - - for (size_t i = 1; i <= _varId; i++) - { - const Variable *var = _symbolDatabase->getVariableFromVarId(i); - - // is unknown record type? - if (var && var->isClass() && !var->type()) - { - std::string name; - - // single token type? - if (var->typeStartToken() == var->typeEndToken()) - name = var->typeStartToken()->str(); - - // complcated type - else - { - const Token *tok = var->typeStartToken(); - int level = 0; - - while (tok) - { - // skip pointer and reference part of type - if (level == 0 && (tok->str() == "*" || tok->str() == "&")) - break; - - name += tok->str(); - - if (Token::Match(tok, "struct|union")) - name += " "; - - // pointers and referennces are OK in template - else if (tok->str() == "<") - level++; - else if (tok->str() == ">") - level--; - - if (tok == var->typeEndToken()) - break; - - tok = tok->next(); - } - } - - unknowns.insert(name); - } - } - - if (!unknowns.empty()) - { - std::ostringstream ss; - - ss << unknowns.size() << " unknown types:" << std::endl; - - std::set::const_iterator it; - size_t count = 1; - - for (it = unknowns.begin(); it != unknowns.end(); ++it, ++count) - ss << count << ": " << *it << std::endl; - - if (_errorLogger) - _errorLogger->reportOut(ss.str()); - } + printUnknownTypes(); } return true; @@ -11148,3 +11083,72 @@ void Tokenizer::simplifyReturn() } } +void Tokenizer::printUnknownTypes() +{ + getSymbolDatabase(); + + std::set unknowns; + + for (size_t i = 1; i <= _varId; i++) + { + const Variable *var = _symbolDatabase->getVariableFromVarId(i); + + // is unknown record type? + if (var && var->isClass() && !var->type()) + { + std::string name; + + // single token type? + if (var->typeStartToken() == var->typeEndToken()) + name = var->typeStartToken()->str(); + + // complcated type + else + { + const Token *tok = var->typeStartToken(); + int level = 0; + + while (tok) + { + // skip pointer and reference part of type + if (level == 0 && (tok->str() == "*" || tok->str() == "&")) + break; + + name += tok->str(); + + if (Token::Match(tok, "struct|union")) + name += " "; + + // pointers and referennces are OK in template + else if (tok->str() == "<") + level++; + else if (tok->str() == ">") + level--; + + if (tok == var->typeEndToken()) + break; + + tok = tok->next(); + } + } + + unknowns.insert(name); + } + } + + if (!unknowns.empty()) + { + std::ostringstream ss; + + ss << unknowns.size() << " unknown types:" << std::endl; + + std::set::const_iterator it; + size_t count = 1; + + for (it = unknowns.begin(); it != unknowns.end(); ++it, ++count) + ss << count << ": " << *it << std::endl; + + if (_errorLogger) + _errorLogger->reportOut(ss.str()); + } +} diff --git a/lib/tokenize.h b/lib/tokenize.h index a85559054..aee180a36 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -709,6 +709,11 @@ public: */ void simplifyReturn(); + /** + * Output list of unknown types. + */ + void printUnknownTypes(); + private: /** Disable copy constructor, no implementation */ Tokenizer(const Tokenizer &);