Skip to content

Commit 63af1a1

Browse files
Fix #13727 FP knownEmptyContainer with call to insert() template (danmar#7490)
1 parent 3783374 commit 63af1a1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static std::pair<const Token*, const Library::Container*> getContainerFunction(c
295295
if (!tok || !tok->valueType() || (!tok->valueType()->container && (!(cont = library.detectContainerOrIterator(tok->valueType()->smartPointerTypeToken)))))
296296
return {};
297297
const Token* parent = tok->astParent();
298-
if (Token::Match(parent, ". %name% (") && astIsLHS(tok)) {
298+
if (Token::Match(parent, ". %name% [(<]") && astIsLHS(tok)) {
299299
return { parent->next(), cont ? cont : tok->valueType()->container };
300300
}
301301
return {};

test/teststl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6956,6 +6956,13 @@ class TestStl : public TestFixture {
69566956
" s += \'a\';\n"
69576957
"}\n", dinit(CheckOptions, $.inconclusive = true));
69586958
ASSERT_EQUALS("", errout_str());
6959+
6960+
check("void f(std::vector<int>::iterator it) {\n" // #13727
6961+
" std::vector<int> v;\n"
6962+
" v.insert<std::vector<int>::iterator>(v.end(), it, it + 1);\n"
6963+
" for (auto i : v) {}\n"
6964+
"}\n", dinit(CheckOptions, $.inconclusive = true));
6965+
ASSERT_EQUALS("", errout_str());
69596966
}
69606967

69616968
void checkMutexes() {

0 commit comments

Comments
 (0)