Skip to content

Commit 796b181

Browse files
Refs #14289: No bailout for string literals (danmar#7984)
1 parent 510a29d commit 796b181

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/symboldatabase.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,8 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars()
15211521
continue;
15221522
if (Token::Match(tok->next(), "&|&&|* *| *| )|,|%var%|const"))
15231523
continue;
1524+
if (Token::Match(tok->previous(), "%str%"))
1525+
continue;
15241526
// Very likely a typelist
15251527
if (Token::Match(tok->tokAt(-2), "%type% ,") || Token::Match(tok->next(), ", %type%"))
15261528
continue;

test/cfg/std.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5036,7 +5036,6 @@ void invalidPrintfArgType_printf(void)
50365036
// #7016
50375037
uint8_t n = 7;
50385038
// TODO cppcheck-suppress invalidPrintfArgType_uint
5039-
// cppcheck-suppress valueFlowBailoutIncompleteVar
50405039
printf("%" PRIi16 "\n", n);
50415040
}
50425041

test/testvalueflow.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9066,8 +9066,8 @@ class TestValueFlow : public TestFixture {
90669066
ASSERT_EQUALS(false, testValueOfX(code, 5U, 0));
90679067
}
90689068

9069-
void valueFlowBailoutIncompleteVar() { // #12526
9070-
bailout(
9069+
void valueFlowBailoutIncompleteVar() {
9070+
bailout( // #12526
90719071
"int f1() {\n"
90729072
" return VALUE_1;\n"
90739073
"}\n"
@@ -9080,6 +9080,13 @@ class TestValueFlow : public TestFixture {
90809080
"[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable VALUE_1\n"
90819081
"[test.cpp:6]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable VALUE_2\n",
90829082
errout_str());
9083+
9084+
bailout(
9085+
"std::string_view f() {\n"
9086+
" return \"abc\"sv;\n"
9087+
"}\n"
9088+
);
9089+
ASSERT_EQUALS_WITHOUT_LINENUMBERS("", errout_str());
90839090
}
90849091

90859092
void valueFlowBailoutNoreturn() { // #13718

0 commit comments

Comments
 (0)