Fix 10424: ExpressionAnalyzer assertion failure in librevisa
This commit is contained in:
parent
7d14f461f0
commit
37ef29889b
|
@ -7079,7 +7079,9 @@ static void valueFlowContainerSize(TokenList *tokenlist, SymbolDatabase* symbold
|
||||||
setTokenValue(const_cast<Token*>(tok), value, settings);
|
setTokenValue(const_cast<Token*>(tok), value, settings);
|
||||||
} else if (Token::Match(tok, "%name%|;|{|} %var% = %str% ;")) {
|
} else if (Token::Match(tok, "%name%|;|{|} %var% = %str% ;")) {
|
||||||
const Token *containerTok = tok->next();
|
const Token *containerTok = tok->next();
|
||||||
if (containerTok && containerTok->valueType() && containerTok->valueType()->container && containerTok->valueType()->container->stdStringLike) {
|
if (containerTok->exprId() == 0)
|
||||||
|
continue;
|
||||||
|
if (containerTok->valueType() && containerTok->valueType()->container && containerTok->valueType()->container->stdStringLike) {
|
||||||
ValueFlow::Value value(Token::getStrLength(containerTok->tokAt(2)));
|
ValueFlow::Value value(Token::getStrLength(containerTok->tokAt(2)));
|
||||||
value.valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE;
|
value.valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE;
|
||||||
value.setKnown();
|
value.setKnown();
|
||||||
|
@ -7087,6 +7089,8 @@ static void valueFlowContainerSize(TokenList *tokenlist, SymbolDatabase* symbold
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok, "%name%|;|{|}|> %var% = {") && Token::simpleMatch(tok->linkAt(3), "} ;")) {
|
} else if (Token::Match(tok, "%name%|;|{|}|> %var% = {") && Token::simpleMatch(tok->linkAt(3), "} ;")) {
|
||||||
const Token* containerTok = tok->next();
|
const Token* containerTok = tok->next();
|
||||||
|
if (containerTok->exprId() == 0)
|
||||||
|
continue;
|
||||||
if (astIsContainer(containerTok) && containerTok->valueType()->container->size_templateArgNo < 0) {
|
if (astIsContainer(containerTok) && containerTok->valueType()->container->size_templateArgNo < 0) {
|
||||||
std::vector<ValueFlow::Value> values = getInitListSize(tok->tokAt(3), containerTok->valueType()->container);
|
std::vector<ValueFlow::Value> values = getInitListSize(tok->tokAt(3), containerTok->valueType()->container);
|
||||||
for (const ValueFlow::Value& value : values)
|
for (const ValueFlow::Value& value : values)
|
||||||
|
@ -7094,6 +7098,8 @@ static void valueFlowContainerSize(TokenList *tokenlist, SymbolDatabase* symbold
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok, ". %name% (") && tok->astOperand1() && tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->container) {
|
} else if (Token::Match(tok, ". %name% (") && tok->astOperand1() && tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->container) {
|
||||||
const Token* containerTok = tok->astOperand1();
|
const Token* containerTok = tok->astOperand1();
|
||||||
|
if (containerTok->exprId() == 0)
|
||||||
|
continue;
|
||||||
Library::Container::Action action = containerTok->valueType()->container->getAction(tok->strAt(1));
|
Library::Container::Action action = containerTok->valueType()->container->getAction(tok->strAt(1));
|
||||||
if (action == Library::Container::Action::CLEAR) {
|
if (action == Library::Container::Action::CLEAR) {
|
||||||
ValueFlow::Value value(0);
|
ValueFlow::Value value(0);
|
||||||
|
|
|
@ -5669,6 +5669,16 @@ private:
|
||||||
" return o;\n"
|
" return o;\n"
|
||||||
"}}\n";
|
"}}\n";
|
||||||
valueOfTok(code, "return");
|
valueOfTok(code, "return");
|
||||||
|
|
||||||
|
code = "class dummy_resource : public instrument_resource {\n"
|
||||||
|
"public:\n"
|
||||||
|
" int reads;\n"
|
||||||
|
" static std::list<int> log;\n"
|
||||||
|
"};\n"
|
||||||
|
"void dummy_reader_reset() {\n"
|
||||||
|
" dummy_resource::log.clear();\n"
|
||||||
|
"}\n";
|
||||||
|
valueOfTok(code, "log");
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowCrash() {
|
void valueFlowCrash() {
|
||||||
|
|
Loading…
Reference in New Issue