diff --git a/cfg/std.cfg b/cfg/std.cfg index ede343a4b..cd84c30c0 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -6600,12 +6600,6 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - - - - false - - @@ -6703,26 +6697,6 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - - - false - - - - false - - - - false - - - - false - - - - false - false @@ -6768,14 +6742,6 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - - - - - - - false - diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 5c132e734..36f67d753 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -622,6 +622,14 @@ void CheckFunctions::checkLibraryMatchFunctions() if (Token::simpleMatch(tok->astTop(), "throw")) continue; + if (Token::simpleMatch(tok->astParent(), ".")) { + const Token* contTok = tok->astParent()->astOperand1(); + if (astContainerAction(contTok) != Library::Container::Action::NO_ACTION) + continue; + if (astContainerYield(contTok) != Library::Container::Yield::NO_YIELD) + continue; + } + if (!mSettings->library.isNotLibraryFunction(tok)) continue; diff --git a/lib/library.cpp b/lib/library.cpp index 60754cad8..2f7c6e0dc 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -1358,6 +1358,15 @@ const Library::NonOverlappingData* Library::getNonOverlappingData(const Token *f Library::UseRetValType Library::getUseRetValType(const Token *ftok) const { + if (Token::simpleMatch(ftok->astParent(), ".")) { + using Yield = Library::Container::Yield; + using Action = Library::Container::Action; + const Yield yield = astContainerYield(ftok->astParent()->astOperand1()); + if (yield == Yield::START_ITERATOR || yield == Yield::END_ITERATOR || yield == Yield::AT_INDEX || + yield == Yield::SIZE || yield == Yield::EMPTY || yield == Yield::BUFFER || yield == Yield::BUFFER_NT || + ((yield == Yield::ITEM || yield == Yield::ITERATOR) && astContainerAction(ftok->astParent()->astOperand1()) == Action::NO_ACTION)) + return Library::UseRetValType::DEFAULT; + } if (isNotLibraryFunction(ftok)) return Library::UseRetValType::NONE; const std::unordered_map::const_iterator it = functions.find(getFunctionName(ftok)); diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index cf26f73cb..b58935ba2 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -4489,7 +4489,7 @@ void getline() in.close(); } -// cppcheck-suppress passedByValue +// TODO cppcheck-suppress passedByValue void stream_write(std::ofstream& s, std::vector v) { if (v.empty()) {} s.write(v.data(), v.size()); diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 2df7ae22c..90d87d37b 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1925,9 +1925,7 @@ private: " auto x = std::vector(1);\n" " x.push_back(1);\n" "}\n", "test.cpp", &s); - TODO_ASSERT_EQUALS("", - "[test.cpp:7]: (information) --check-library: There is no matching configuration for function auto::push_back()\n", - errout.str()); + ASSERT_EQUALS("", errout.str()); check("void f() {\n" " auto p(std::make_shared>());\n"