Merge pull request #5148 from chrchr-github/chr_Fix11764

Fix #11764 checkLibraryFunction/NoReturn when inheriting from container
This commit is contained in:
chrchr-github 2023-06-16 23:33:08 +02:00 committed by GitHub
commit 8761e6b8fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -975,7 +975,15 @@ std::string Library::getFunctionName(const Token *ftok, bool &error) const
continue;
const std::vector<Type::BaseInfo> &derivedFrom = scope->definedType->derivedFrom;
for (const Type::BaseInfo & baseInfo : derivedFrom) {
const std::string name(baseInfo.name + "::" + ftok->str());
std::string name;
const Token* tok = baseInfo.nameTok; // baseInfo.name still contains template parameters, but is missing namespaces
if (tok->str() == "::")
tok = tok->next();
while (Token::Match(tok, "%name%|::")) {
name += tok->str();
tok = tok->next();
}
name += "::" + ftok->str();
if (functions.find(name) != functions.end() && matchArguments(ftok, name))
return name;
}

View File

@ -2002,6 +2002,11 @@ private:
"}\n", "test.cpp", &s);
ASSERT_EQUALS("[test.cpp:5]: (information) --check-library: There is no matching configuration for function T::h()\n",
errout.str());
check("struct S : std::vector<int> {\n"
" void f(int i) { push_back(i); }\n"
"};\n", "test.cpp", &s);
ASSERT_EQUALS("", errout.str());
}
void checkUseStandardLibrary1() {