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:
parent
d12197ce1a
commit
d45f5c94cb
|
@ -33,8 +33,8 @@ class Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A preprocessor directive
|
* @brief A preprocessor directive
|
||||||
* Each preprocessor directive (#include, #define, #undef,#if, #ifdef,
|
* Each preprocessor directive (\#include, \#define, \#undef, \#if, \#ifdef, \#else, \#endif)
|
||||||
* #else, #endif) will be recorded as an instance of this class.
|
* will be recorded as an instance of this class.
|
||||||
*
|
*
|
||||||
* file and linenr denote the location where where the directive is defined.
|
* file and linenr denote the location where where the directive is defined.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1372,25 +1372,39 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
|
||||||
return false;
|
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
|
void SymbolDatabase::validate() const
|
||||||
{
|
{
|
||||||
if (_settings->debugwarnings) {
|
if (_settings->debugwarnings) {
|
||||||
const std::size_t functions = functionScopes.size();
|
validateExecutableScopes();
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//validateVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Variable::isPointerArray() const
|
bool Variable::isPointerArray() const
|
||||||
|
|
|
@ -1026,6 +1026,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void validate() const;
|
void validate() const;
|
||||||
|
|
||||||
|
void validateExecutableScopes() const;
|
||||||
|
/**
|
||||||
|
* @brief Check variable list, e.g. variables w/o scope
|
||||||
|
*/
|
||||||
|
void validateVariables() const;
|
||||||
|
|
||||||
/** Set valuetype in provided tokenlist */
|
/** Set valuetype in provided tokenlist */
|
||||||
static void setValueTypeInTokenList(Token *tokens, bool cpp, char defaultSignedness);
|
static void setValueTypeInTokenList(Token *tokens, bool cpp, char defaultSignedness);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue