Skip to content

Commit cfc1fda

Browse files
Undo/restore
1 parent 08a8b7c commit cfc1fda

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

test/testvalueflow.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7473,6 +7473,32 @@ class TestValueFlow : public TestFixture {
74737473
"}";
74747474
ASSERT_EQUALS(true, testValueOfX(code, 4U, 100, ValueFlow::Value::ValueType::BUFFER_SIZE));
74757475

7476+
code = "struct A {};\n" // #14305
7477+
"void* f() {\n"
7478+
" A* x = new A();\n"
7479+
" return x;\n"
7480+
"}";
7481+
ASSERT_EQUALS(true, testValueOfX(code, 4U, 1, ValueFlow::Value::ValueType::BUFFER_SIZE));
7482+
7483+
code = "struct A {};\n"
7484+
"void* f() {\n"
7485+
" void* x = new A;\n"
7486+
" return x;\n"
7487+
"}";
7488+
{
7489+
auto values = tokenValues(code, "x ; }");
7490+
ASSERT_EQUALS(1, values.size());
7491+
ASSERT(values.front().isSymbolicValue());
7492+
// TODO: add BUFFER_SIZE value = 1
7493+
}
7494+
7495+
code = "struct B { int32_t i; };\n"
7496+
"void* f() {\n"
7497+
" B* x = new B();\n"
7498+
" return x;\n"
7499+
"}";
7500+
ASSERT_EQUALS(true, testValueOfX(code, 4U, 4, ValueFlow::Value::ValueType::BUFFER_SIZE));
7501+
74767502
settings = settingsOld;
74777503
}
74787504

@@ -9082,8 +9108,8 @@ class TestValueFlow : public TestFixture {
90829108
ASSERT_EQUALS(false, testValueOfX(code, 5U, 0));
90839109
}
90849110

9085-
void valueFlowBailoutIncompleteVar() { // #12526
9086-
bailout(
9111+
void valueFlowBailoutIncompleteVar() {
9112+
bailout( // #12526
90879113
"int f1() {\n"
90889114
" return VALUE_1;\n"
90899115
"}\n"
@@ -9096,6 +9122,13 @@ class TestValueFlow : public TestFixture {
90969122
"[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable VALUE_1\n"
90979123
"[test.cpp:6]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable VALUE_2\n",
90989124
errout_str());
9125+
9126+
bailout(
9127+
"std::string_view f() {\n"
9128+
" return \"abc\"sv;\n"
9129+
"}\n"
9130+
);
9131+
ASSERT_EQUALS_WITHOUT_LINENUMBERS("", errout_str());
90999132
}
91009133

91019134
void valueFlowBailoutNoreturn() { // #13718

0 commit comments

Comments
 (0)