Symbol database: report error when it is detected that a variable id is missing. Ticket: #1928
This commit is contained in:
parent
6423288d2e
commit
556ef9afcf
|
@ -63,6 +63,7 @@ void CheckClass::createSymbolDatabase()
|
||||||
if (Token::Match(tok, "class|struct|namespace %var% [{:]"))
|
if (Token::Match(tok, "class|struct|namespace %var% [{:]"))
|
||||||
{
|
{
|
||||||
SpaceInfo *new_info = new SpaceInfo;
|
SpaceInfo *new_info = new SpaceInfo;
|
||||||
|
new_info->tokenizer = _tokenizer;
|
||||||
new_info->isNamespace = tok->str() == "namespace";
|
new_info->isNamespace = tok->str() == "namespace";
|
||||||
new_info->className = tok->next()->str();
|
new_info->className = tok->next()->str();
|
||||||
new_info->classDef = tok;
|
new_info->classDef = tok;
|
||||||
|
@ -563,15 +564,20 @@ void CheckClass::SpaceInfo::getVarList()
|
||||||
// If the vartok was set in the if-blocks above, create a entry for this variable..
|
// If the vartok was set in the if-blocks above, create a entry for this variable..
|
||||||
if (vartok && vartok->str() != "operator")
|
if (vartok && vartok->str() != "operator")
|
||||||
{
|
{
|
||||||
#if 0 //ndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (vartok->varId() == 0)
|
if (vartok->varId() == 0)
|
||||||
{
|
{
|
||||||
// debug message that something is wrong..
|
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
||||||
std::cout << "getVarList debug-information: missing varid: "
|
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||||
<< vartok->linenr()
|
loc.line = vartok->linenr();
|
||||||
<< ": "
|
loc.setfile(tokenizer->file(vartok));
|
||||||
<< vartok->str()
|
locationList.push_back(loc);
|
||||||
<< std::endl;
|
|
||||||
|
const ErrorLogger::ErrorMessage errmsg(locationList,
|
||||||
|
Severity::error,
|
||||||
|
"Internal error. CheckClass::SpaceInfo::getVarList found variable with varid 0.",
|
||||||
|
"cppcheckError");
|
||||||
|
Check::reportError(errmsg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,7 @@ private:
|
||||||
|
|
||||||
struct SpaceInfo
|
struct SpaceInfo
|
||||||
{
|
{
|
||||||
|
const Tokenizer *tokenizer;
|
||||||
bool isNamespace;
|
bool isNamespace;
|
||||||
std::string className;
|
std::string className;
|
||||||
const Token *classDef; // class/struct/namespace token
|
const Token *classDef; // class/struct/namespace token
|
||||||
|
|
Loading…
Reference in New Issue