Fix 11848: Assert failure in getParentValueTypes() (#5274)
This commit is contained in:
parent
931a59a724
commit
389e446dc0
|
@ -3490,16 +3490,28 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
|
||||||
return tok2;
|
return tok2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& Type::name() const
|
std::string Type::name() const
|
||||||
{
|
{
|
||||||
const Token* next = classDef->next();
|
const Token* start = classDef->next();
|
||||||
if (classScope && classScope->enumClass && isEnumType())
|
if (classScope && classScope->enumClass && isEnumType())
|
||||||
return next->strAt(1);
|
start = start->tokAt(1);
|
||||||
if (next->str() == "class")
|
else if (start->str() == "class")
|
||||||
return next->strAt(1);
|
start = start->tokAt(1);
|
||||||
if (next->isName())
|
else if (!start->isName())
|
||||||
return next->str();
|
return emptyString;
|
||||||
return emptyString;
|
const Token* next = start;
|
||||||
|
while (Token::Match(next, "::|<|>|(|)|[|]|*|&|&&|%name%")) {
|
||||||
|
if (Token::Match(next, "<|(|[") && next->link())
|
||||||
|
next = next->link();
|
||||||
|
next = next->next();
|
||||||
|
}
|
||||||
|
std::string result;
|
||||||
|
for (const Token* tok = start; tok != next; tok = tok->next()) {
|
||||||
|
if (!result.empty())
|
||||||
|
result += ' ';
|
||||||
|
result += tok->str();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolDatabase::debugMessage(const Token *tok, const std::string &type, const std::string &msg) const
|
void SymbolDatabase::debugMessage(const Token *tok, const std::string &type, const std::string &msg) const
|
||||||
|
|
|
@ -131,7 +131,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& name() const;
|
std::string name() const;
|
||||||
|
|
||||||
const std::string& type() const {
|
const std::string& type() const {
|
||||||
return classDef ? classDef->str() : emptyString;
|
return classDef ? classDef->str() : emptyString;
|
||||||
|
|
|
@ -6812,6 +6812,14 @@ private:
|
||||||
" dummy_resource::log.clear();\n"
|
" dummy_resource::log.clear();\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
valueOfTok(code, "log");
|
valueOfTok(code, "log");
|
||||||
|
|
||||||
|
code = "struct D : B<int> {\n"
|
||||||
|
" D(int i, const std::string& s) : B<int>(i, s) {}\n"
|
||||||
|
"};\n"
|
||||||
|
"template<> struct B<int>::S {\n"
|
||||||
|
" int j;\n"
|
||||||
|
"};\n";
|
||||||
|
valueOfTok(code, "B");
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowCrash() {
|
void valueFlowCrash() {
|
||||||
|
|
Loading…
Reference in New Issue