Improve --check-library error message (#4755)

This commit is contained in:
chrchr-github 2023-02-01 14:53:57 +01:00 committed by GitHub
parent 9acc9659aa
commit e8c3a80678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 12 deletions

View File

@ -2300,19 +2300,19 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token* tok, bool poi
if (vt && vt->containerTypeToken)
return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) };
}
if (pointedToType && astIsSmartPointer(var->nameToken())) {
const ValueType* vt = var->valueType();
if (vt && vt->smartPointerTypeToken)
return { vt->smartPointerTypeToken, vt->smartPointerTypeToken->linkAt(-1) };
}
if (pointedToType && astIsIterator(var->nameToken())) {
const ValueType* vt = var->valueType();
if (vt && vt->containerTypeToken)
return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) };
}
if (result.first)
return result;
}
if (pointedToType && astIsSmartPointer(var->nameToken())) {
const ValueType* vt = var->valueType();
if (vt && vt->smartPointerTypeToken)
return { vt->smartPointerTypeToken, vt->smartPointerTypeToken->linkAt(-1) };
}
if (pointedToType && astIsIterator(var->nameToken())) {
const ValueType* vt = var->valueType();
if (vt && vt->containerTypeToken)
return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) };
}
if (result.first)
return result;
return {var->typeStartToken(), var->typeEndToken()->next()};
} else if (Token::simpleMatch(tok, "return")) {
const Scope* scope = tok->scope();

View File

@ -1949,6 +1949,16 @@ private:
"[test.cpp:5]: (information) --check-library: There is no matching configuration for function auto::push_back()\n",
errout.str());
check("struct F { void g(int); };\n"
"void f(std::list<F>& l) {\n"
" std::list<F>::iterator it;\n"
" for (it = l.begin(); it != l.end(); ++it)\n"
" it->g(0);\n"
"}\n");
TODO_ASSERT_EQUALS("",
"[test.cpp:5]: (information) --check-library: There is no matching configuration for function F::g()\n",
errout.str());
settings = settings_old;
}