Add (disabled) function in SymbolDatabase to check variable list (e.g. find variables w/o scope). Fix some doxygen warnings.

This commit is contained in:
Alexander Mai 2016-02-03 17:08:46 +01:00
parent d12197ce1a
commit d45f5c94cb
3 changed files with 37 additions and 17 deletions

View File

@ -33,8 +33,8 @@ class Settings;
/**
* @brief A preprocessor directive
* Each preprocessor directive (#include, #define, #undef,#if, #ifdef,
* #else, #endif) will be recorded as an instance of this class.
* Each preprocessor directive (\#include, \#define, \#undef, \#if, \#ifdef, \#else, \#endif)
* will be recorded as an instance of this class.
*
* file and linenr denote the location where where the directive is defined.
*

View File

@ -1372,25 +1372,39 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
return false;
}
void SymbolDatabase::validateExecutableScopes() const
{
const std::size_t functions = functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
const Scope* const scope = functionScopes[i];
const Function* const function = scope->function;
if (scope->isExecutable() && !function) {
const std::list<const Token*> callstack(1, scope->classDef);
const std::string msg = std::string("Executable scope '") + scope->classDef->str() + "' with unknown function.";
const ErrorLogger::ErrorMessage errmsg(callstack, &_tokenizer->list, Severity::debug,
"symbolDatabaseWarning",
msg,
false);
_errorLogger->reportErr(errmsg);
}
}
}
void SymbolDatabase::validateVariables() const
{
for (std::vector<const Variable *>::const_iterator iter = _variableList.begin(); iter!=_variableList.end(); ++iter) {
if (*iter && !(*iter)->scope()) {
throw InternalError((*iter)->nameToken(), "Analysis failed (variable without scope). If the code is valid then please report this failure.", InternalError::INTERNAL);
}
}
}
void SymbolDatabase::validate() const
{
if (_settings->debugwarnings) {
const std::size_t functions = functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
const Scope* scope = functionScopes[i];
const Function* function = scope->function;
if (scope->isExecutable() && !function) {
const std::list<const Token*> callstack(1, scope->classDef);
const std::string msg = std::string("Executable scope '") + scope->classDef->str() + "' with unknown function.";
const ErrorLogger::ErrorMessage errmsg(callstack, &_tokenizer->list, Severity::debug,
"symbolDatabaseWarning",
msg,
false);
_errorLogger->reportErr(errmsg);
}
}
validateExecutableScopes();
}
//validateVariables();
}
bool Variable::isPointerArray() const

View File

@ -1026,6 +1026,12 @@ public:
*/
void validate() const;
void validateExecutableScopes() const;
/**
* @brief Check variable list, e.g. variables w/o scope
*/
void validateVariables() const;
/** Set valuetype in provided tokenlist */
static void setValueTypeInTokenList(Token *tokens, bool cpp, char defaultSignedness);