diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 7bb91afac47..5bda0c72ef3 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -85,6 +85,7 @@ class TestBufferOverrun : public TestFixture { } void run() override { + // TODO: mNewTemplate = true; TEST_CASE(noerr1); TEST_CASE(noerr2); TEST_CASE(noerr3); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index c069f08321d..c04b68acbb3 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -43,6 +43,7 @@ class TestCondition : public TestFixture { ""; settings1 = settingsBuilder(settings1).libraryxml(cfg).build(); + // TODO: mNewTemplate = true; TEST_CASE(assignAndCompare); // assignment and comparison don't match TEST_CASE(mismatchingBitAnd); // overlapping bitmasks TEST_CASE(comparison); // CheckCondition::comparison test cases diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index f587afb7d62..c94dbc6d4c5 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -54,6 +54,7 @@ class TestConstructors : public TestFixture { } void run() override { + // TODO: mNewTemplate = true; TEST_CASE(simple1); TEST_CASE(simple2); TEST_CASE(simple3); diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index f596037c831..097a34c7566 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -36,6 +36,7 @@ class TestFunctions : public TestFixture { certainty(Certainty::inconclusive).c(Standards::C11).cpp(Standards::CPP11).library("std.cfg").library("posix.cfg").build(); void run() override { + // TODO: mNewTemplate = true; // Prohibited functions TEST_CASE(prohibitedFunctions_posix); TEST_CASE(prohibitedFunctions_index); diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 5a3f630c8dd..656a71fc19c 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -33,6 +33,7 @@ class TestLeakAutoVar : public TestFixture { const Settings settings = settingsBuilder().library("std.cfg").build(); void run() override { + // TODO: mNewTemplate = true; // Assign TEST_CASE(assign1); TEST_CASE(assign2); diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 7bdd06e5aad..a6a7abb51c0 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -126,6 +126,7 @@ class TestMemleakInFunction : public TestFixture { void run() override { + mNewTemplate = true; TEST_CASE(realloc1); TEST_CASE(realloc2); TEST_CASE(realloc3); @@ -157,7 +158,7 @@ class TestMemleakInFunction : public TestFixture { " char *a = (char *)malloc(10);\n" " a = realloc(a, 100);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:5]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } void realloc2() { @@ -168,7 +169,7 @@ class TestMemleakInFunction : public TestFixture { " free(a);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:5]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } void realloc3() { @@ -193,7 +194,7 @@ class TestMemleakInFunction : public TestFixture { "}"); TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: a\n", - "[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", + "[test.cpp:4:10]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } @@ -285,7 +286,7 @@ class TestMemleakInFunction : public TestFixture { " *str = realloc(*str,100);\n" " free (*str);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'str\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:6]: (error) Common realloc mistake: \'str\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } void realloc14() { @@ -307,7 +308,7 @@ class TestMemleakInFunction : public TestFixture { " return false;\n" " return true;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Common realloc mistake: \'m_options\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Common realloc mistake: \'m_options\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } void realloc16() { @@ -326,7 +327,7 @@ class TestMemleakInFunction : public TestFixture { " void ***a = malloc(sizeof(a));\n" " ***a = realloc(***(a), sizeof(a) * 2);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:8]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } void realloc18() { @@ -335,7 +336,7 @@ class TestMemleakInFunction : public TestFixture { " void *a = malloc(sizeof(a));\n" " a = realloc((void*)a, sizeof(a) * 2);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:5]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } void realloc19() { @@ -344,7 +345,7 @@ class TestMemleakInFunction : public TestFixture { " void *a = malloc(sizeof(a));\n" " a = (realloc((void*)((a)), sizeof(a) * 2));\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:5]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); } void realloc20() { @@ -401,14 +402,14 @@ class TestMemleakInFunction : public TestFixture { "a = malloc(10);\n" "a = realloc(a, 20);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:1]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); check("void f() {\n" "void *a = nullptr;\n" "a = malloc(10);\n" "a = realloc(a, 20);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:1]: (error) Common realloc mistake: \'a\' nulled but not freed upon failure [memleakOnRealloc]\n", errout_str()); check("void f(char *b) {\n" "void *a = NULL;\n" @@ -451,6 +452,7 @@ class TestMemleakInClass : public TestFixture { } void run() override { + mNewTemplate = true; TEST_CASE(class1); TEST_CASE(class2); TEST_CASE(class3); @@ -512,7 +514,7 @@ class TestMemleakInClass : public TestFixture { "{\n" " delete [] str2;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class Fred\n" "{\n" @@ -530,7 +532,7 @@ class TestMemleakInClass : public TestFixture { " delete [] str2;\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void class2() { @@ -552,7 +554,7 @@ class TestMemleakInClass : public TestFixture { "{\n" " free(str1);\n" "}"); - ASSERT_EQUALS("[test.cpp:17]: (error) Mismatching allocation and deallocation: Fred::str1\n", errout_str()); + ASSERT_EQUALS("[test.cpp:17:5]: (error) Mismatching allocation and deallocation: Fred::str1 [mismatchAllocDealloc]\n", errout_str()); check("class Fred\n" "{\n" @@ -568,7 +570,7 @@ class TestMemleakInClass : public TestFixture { " free(str1);\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:12]: (error) Mismatching allocation and deallocation: Fred::str1\n", errout_str()); + ASSERT_EQUALS("[test.cpp:12:9]: (error) Mismatching allocation and deallocation: Fred::str1 [mismatchAllocDealloc]\n", errout_str()); } void class3() { @@ -807,7 +809,7 @@ class TestMemleakInClass : public TestFixture { "};\n" "A::A()\n" "{ p = new int; }"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" "{\n" @@ -815,7 +817,7 @@ class TestMemleakInClass : public TestFixture { " int * p;\n" " A() { p = new int; }\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void class11() { @@ -826,7 +828,7 @@ class TestMemleakInClass : public TestFixture { " A() : p(new int[10])\n" " { }" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" "{\n" @@ -836,7 +838,7 @@ class TestMemleakInClass : public TestFixture { "};\n" "A::A() : p(new int[10])\n" "{ }"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void class12() { @@ -858,7 +860,7 @@ class TestMemleakInClass : public TestFixture { "\n" "void A::cleanup()\n" "{ delete [] p; }"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" "{\n" @@ -872,7 +874,7 @@ class TestMemleakInClass : public TestFixture { " void cleanup()\n" " { delete [] p; }\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void class13() { @@ -894,7 +896,7 @@ class TestMemleakInClass : public TestFixture { "\n" "void A::foo()\n" "{ p = new int[10]; delete [] p; }"); - ASSERT_EQUALS("[test.cpp:17]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:17:3]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); check("class A\n" "{\n" @@ -908,7 +910,7 @@ class TestMemleakInClass : public TestFixture { " void foo()\n" " { p = new int[10]; delete [] p; }\n" "};"); - ASSERT_EQUALS("[test.cpp:11]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:11:7]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); } void class14() { @@ -921,8 +923,8 @@ class TestMemleakInClass : public TestFixture { "\n" "void A::init()\n" "{ p = new int[10]; }"); - ASSERT_EQUALS("[test.cpp:9]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n" - "[test.cpp:3]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9:3]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:3:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" "{\n" @@ -931,8 +933,8 @@ class TestMemleakInClass : public TestFixture { " void init()\n" " { p = new int[10]; }\n" "};"); - ASSERT_EQUALS("[test.cpp:6]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n" - "[test.cpp:3]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:7]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:3:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" @@ -944,8 +946,8 @@ class TestMemleakInClass : public TestFixture { "\n" "void A::init()\n" "{ p = new int; }"); - ASSERT_EQUALS("[test.cpp:9]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n" - "[test.cpp:3]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9:3]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:3:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" "{\n" @@ -954,8 +956,8 @@ class TestMemleakInClass : public TestFixture { " void init()\n" " { p = new int; }\n" "};"); - ASSERT_EQUALS("[test.cpp:6]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n" - "[test.cpp:3]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:7]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:3:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" @@ -967,8 +969,8 @@ class TestMemleakInClass : public TestFixture { "\n" "void A::init()\n" "{ p = malloc(sizeof(int)*10); }"); - ASSERT_EQUALS("[test.cpp:9]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n" - "[test.cpp:3]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9:3]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:3:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class A\n" "{\n" @@ -977,8 +979,8 @@ class TestMemleakInClass : public TestFixture { " void init()\n" " { p = malloc(sizeof(int)*10); }\n" "};"); - ASSERT_EQUALS("[test.cpp:6]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated.\n" - "[test.cpp:3]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:7]: (warning) Possible leak in public function. The pointer 'p' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:3:10]: (style) Class 'A' is unsafe, 'A::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void class15() { @@ -1075,7 +1077,7 @@ class TestMemleakInClass : public TestFixture { " A::pd = new char[12];\n" " delete [] A::pd;\n" "}"); - ASSERT_EQUALS("[test.cpp:10]: (warning) Possible leak in public function. The pointer 'pd' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:10:5]: (warning) Possible leak in public function. The pointer 'pd' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); check("class A {\n" "private:\n" @@ -1087,7 +1089,7 @@ class TestMemleakInClass : public TestFixture { " delete [] pd;\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:7]: (warning) Possible leak in public function. The pointer 'pd' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:9]: (warning) Possible leak in public function. The pointer 'pd' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); check("class A {\n" "private:\n" @@ -1101,7 +1103,7 @@ class TestMemleakInClass : public TestFixture { " pd = new char[12];\n" " delete [] pd;\n" "}"); - ASSERT_EQUALS("[test.cpp:10]: (warning) Possible leak in public function. The pointer 'pd' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:10:5]: (warning) Possible leak in public function. The pointer 'pd' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); } void class18() { @@ -1165,8 +1167,8 @@ class TestMemleakInClass : public TestFixture { " rp1 = new TRadioButton;\n" " rp2 = new TRadioButton;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Class 'Foo' is unsafe, 'Foo::rp1' can leak by wrong usage.\n" - "[test.cpp:6]: (style) Class 'Foo' is unsafe, 'Foo::rp2' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:19]: (style) Class 'Foo' is unsafe, 'Foo::rp1' can leak by wrong usage. [unsafeClassCanLeak]\n" + "[test.cpp:6:19]: (style) Class 'Foo' is unsafe, 'Foo::rp2' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("class TRadioButton { };\n" "class Foo\n" @@ -1210,7 +1212,7 @@ class TestMemleakInClass : public TestFixture { " }\n" " };\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:15]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("namespace ns1 {\n" " class Fred\n" @@ -1234,7 +1236,7 @@ class TestMemleakInClass : public TestFixture { " delete [] str2;\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:15]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("namespace ns1 {\n" " class Fred\n" @@ -1257,7 +1259,7 @@ class TestMemleakInClass : public TestFixture { "{\n" " delete [] str2;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:15]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("namespace ns1 {\n" " namespace ns2 {\n" @@ -1282,7 +1284,7 @@ class TestMemleakInClass : public TestFixture { "{\n" " delete [] str2;\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:19]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("namespace ns1 {\n" " namespace ns2 {\n" @@ -1309,7 +1311,7 @@ class TestMemleakInClass : public TestFixture { "{\n" " delete [] str2;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:23]: (style) Class 'Fred' is unsafe, 'Fred::str1' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void class21() { // ticket #2517 @@ -1326,9 +1328,9 @@ class TestMemleakInClass : public TestFixture { "public:\n" " A() : b(new B()), c(new C(b)) { }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:9]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage.\n" + TODO_ASSERT_EQUALS("[test.cpp:9:8]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage. [unsafeClassCanLeak]\n" "[test.cpp:10]: (style) Class 'A' is unsafe, 'A::c' can leak by wrong usage.\n", - "[test.cpp:9]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage.\n", + "[test.cpp:9:8]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); check("struct B { };\n" @@ -1348,9 +1350,9 @@ class TestMemleakInClass : public TestFixture { " c = new C(b);\n" " }\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:9]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage.\n" + TODO_ASSERT_EQUALS("[test.cpp:9:8]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage. [unsafeClassCanLeak]\n" "[test.cpp:10]: (style) Class 'A' is unsafe, 'A::c' can leak by wrong usage.\n", - "[test.cpp:9]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage.\n", + "[test.cpp:9:8]: (style) Class 'A' is unsafe, 'A::b' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } @@ -1414,7 +1416,7 @@ class TestMemleakInClass : public TestFixture { " C* p;\n" "};\n" "S::~S() = default;\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Class 'S' is unsafe, 'S::p' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:8]: (style) Class 'S' is unsafe, 'S::p' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void class27() { // ticket #8126 - array of pointers @@ -1425,7 +1427,7 @@ class TestMemleakInClass : public TestFixture { " }\n" " char* a[5];\n" "};\n"); - ASSERT_EQUALS("[test.cpp:6]: (style) Class 'S' is unsafe, 'S::a' can leak by wrong usage.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:11]: (style) Class 'S' is unsafe, 'S::a' can leak by wrong usage. [unsafeClassCanLeak]\n", errout_str()); } void staticvar() { @@ -1524,7 +1526,7 @@ class TestMemleakInClass : public TestFixture { "A::~A() {\n" " delete [] pkt_buffer;\n" "}"); - ASSERT_EQUALS("[test.cpp:14]: (error) Mismatching allocation and deallocation: A::pkt_buffer\n", errout_str()); + ASSERT_EQUALS("[test.cpp:14:9]: (error) Mismatching allocation and deallocation: A::pkt_buffer [mismatchAllocDealloc]\n", errout_str()); check("struct S {\n" // 5678 " ~S();\n" @@ -1536,7 +1538,7 @@ class TestMemleakInClass : public TestFixture { " delete p;\n" " p = 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:8]: (error) Mismatching allocation and deallocation: S::p\n", errout_str()); + ASSERT_EQUALS("[test.cpp:8:5]: (error) Mismatching allocation and deallocation: S::p [mismatchAllocDealloc]\n", errout_str()); } void mismatch2() { // #5659 @@ -1560,8 +1562,8 @@ class TestMemleakInClass : public TestFixture { " delete data_;\n" " data_ = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:17]: (warning) Possible leak in public function. The pointer 'data_' is not deallocated before it is allocated.\n" - "[test.cpp:18]: (error) Mismatching allocation and deallocation: Foo::data_\n", errout_str()); + ASSERT_EQUALS("[test.cpp:17:3]: (warning) Possible leak in public function. The pointer 'data_' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:18:3]: (error) Mismatching allocation and deallocation: Foo::data_ [mismatchAllocDealloc]\n", errout_str()); check("namespace NS\n" "{\n" @@ -1583,8 +1585,8 @@ class TestMemleakInClass : public TestFixture { " delete data_;\n" " data_ = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:17]: (warning) Possible leak in public function. The pointer 'data_' is not deallocated before it is allocated.\n" - "[test.cpp:18]: (error) Mismatching allocation and deallocation: Foo::data_\n", errout_str()); + ASSERT_EQUALS("[test.cpp:17:3]: (warning) Possible leak in public function. The pointer 'data_' is not deallocated before it is allocated. [publicAllocationError]\n" + "[test.cpp:18:3]: (error) Mismatching allocation and deallocation: Foo::data_ [mismatchAllocDealloc]\n", errout_str()); } void func1() { @@ -1598,7 +1600,7 @@ class TestMemleakInClass : public TestFixture { " void xy()\n" " { s = malloc(100); }\n" "};"); - ASSERT_EQUALS("[test.cpp:9]: (warning) Possible leak in public function. The pointer 's' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9:7]: (warning) Possible leak in public function. The pointer 's' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); check("class Fred\n" "{\n" @@ -1610,7 +1612,7 @@ class TestMemleakInClass : public TestFixture { "private:\n" " char *s;\n" "};"); - ASSERT_EQUALS("[test.cpp:7]: (warning) Possible leak in public function. The pointer 's' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:7]: (warning) Possible leak in public function. The pointer 's' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); } void func2() { @@ -1624,7 +1626,7 @@ class TestMemleakInClass : public TestFixture { " const Fred & operator = (const Fred &f)\n" " { s = malloc(100); }\n" "};"); - ASSERT_EQUALS("[test.cpp:9]: (warning) Possible leak in public function. The pointer 's' is not deallocated before it is allocated.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9:7]: (warning) Possible leak in public function. The pointer 's' is not deallocated before it is allocated. [publicAllocationError]\n", errout_str()); } }; @@ -1655,6 +1657,7 @@ class TestMemleakStructMember : public TestFixture { } void run() override { + mNewTemplate = true; // testing that errors are detected TEST_CASE(err); @@ -1713,14 +1716,14 @@ class TestMemleakStructMember : public TestFixture { " abc->a = malloc(10);\n" " free(abc);\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: abc.a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:5]: (error) Memory leak: abc.a [memleak]\n", errout_str()); check("static void foo()\n" "{\n" " struct ABC *abc = malloc(sizeof(struct ABC));\n" " abc->a = malloc(10);\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: abc.a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:1]: (error) Memory leak: abc.a [memleak]\n", errout_str()); check("static ABC * foo()\n" "{\n" @@ -1733,7 +1736,7 @@ class TestMemleakStructMember : public TestFixture { " }\n" " return abc;\n" "}"); - ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: abc.a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:8:9]: (error) Memory leak: abc.a [memleak]\n", errout_str()); check("static void foo(int a)\n" "{\n" @@ -1745,7 +1748,7 @@ class TestMemleakStructMember : public TestFixture { " return;\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: abc.a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:10:1]: (error) Memory leak: abc.a [memleak]\n", errout_str()); } void goto_() { @@ -1792,7 +1795,7 @@ class TestMemleakStructMember : public TestFixture { " abc.a = malloc(10);\n" " return abc.b;\n" "}", false); - ASSERT_EQUALS("[test.c:4]: (error) Memory leak: abc.a\n", errout_str()); + ASSERT_EQUALS("[test.c:4:5]: (error) Memory leak: abc.a [memleak]\n", errout_str()); } void ret2() { @@ -1857,9 +1860,9 @@ class TestMemleakStructMember : public TestFixture { " ((s).b) = open(\"xx.log\", O_RDONLY);\n" " (&s)->c = open(\"xx.log\", O_RDONLY);\n" "}\n", false); - ASSERT_EQUALS("[test.c:7]: (error) Resource leak: s.a\n" - "[test.c:7]: (error) Resource leak: s.b\n" - "[test.c:7]: (error) Resource leak: s.c\n", + ASSERT_EQUALS("[test.c:7:1]: (error) Resource leak: s.a [resourceLeak]\n" + "[test.c:7:1]: (error) Resource leak: s.b [resourceLeak]\n" + "[test.c:7:1]: (error) Resource leak: s.c [resourceLeak]\n", errout_str()); check("struct S { int *p, *q; };\n" // #7705 @@ -1867,8 +1870,8 @@ class TestMemleakStructMember : public TestFixture { " s.p = new int[10];\n" " s.q = malloc(40);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: s.p\n" - "[test.cpp:5]: (error) Memory leak: s.q\n", + ASSERT_EQUALS("[test.cpp:5:1]: (error) Memory leak: s.p [memleak]\n" + "[test.cpp:5:1]: (error) Memory leak: s.q [memleak]\n", errout_str()); check("struct S** f(struct S** s) {\n" // don't throw @@ -2015,7 +2018,7 @@ class TestMemleakStructMember : public TestFixture { " }\n" " return g(&a);\n" "}\n"); - TODO_ASSERT_EQUALS("", "[test.cpp:9]: (error) Memory leak: a.str\n", errout_str()); + TODO_ASSERT_EQUALS("", "[test.cpp:9:9]: (error) Memory leak: a.str [memleak]\n", errout_str()); } void ifelse() { @@ -2082,12 +2085,12 @@ class TestMemleakStructMember : public TestFixture { "}"; check(code1, true); - ASSERT_EQUALS("[test.cpp:12]: (error) Resource leak: a.f\n" - "[test.cpp:12]: (error) Memory leak: a.c\n" - "[test.cpp:12]: (error) Memory leak: a.m\n", errout_str()); + ASSERT_EQUALS("[test.cpp:12:1]: (error) Resource leak: a.f [resourceLeak]\n" + "[test.cpp:12:1]: (error) Memory leak: a.c [memleak]\n" + "[test.cpp:12:1]: (error) Memory leak: a.m [memleak]\n", errout_str()); check(code1, false); - ASSERT_EQUALS("[test.c:12]: (error) Resource leak: a.f\n" - "[test.c:12]: (error) Memory leak: a.m\n", errout_str()); + ASSERT_EQUALS("[test.c:12:1]: (error) Resource leak: a.f [resourceLeak]\n" + "[test.c:12:1]: (error) Memory leak: a.m [memleak]\n", errout_str()); // Test OK case const char code2[] = "struct A {\n" @@ -2118,7 +2121,7 @@ class TestMemleakStructMember : public TestFixture { check(code3, true); ASSERT_EQUALS("", errout_str()); check(code3, false); - ASSERT_EQUALS("[test.c:4]: (error) Resource leak: a.f\n", errout_str()); + ASSERT_EQUALS("[test.c:4:1]: (error) Resource leak: a.f [resourceLeak]\n", errout_str()); // Test struct with destructor const char code4[] = "struct A {\n" @@ -2168,7 +2171,7 @@ class TestMemleakStructMember : public TestFixture { " if (s.state_check_buff == 0)\n" " return;\n" "}", false); - ASSERT_EQUALS("[test.c:9]: (error) Memory leak: s.state_check_buff\n", errout_str()); + ASSERT_EQUALS("[test.c:9:1]: (error) Memory leak: s.state_check_buff [memleak]\n", errout_str()); } void varid_2() { // #5315 @@ -2178,7 +2181,7 @@ class TestMemleakStructMember : public TestFixture { " ((f)->realm) = strdup(realm);\n" " if(f->realm == NULL) {}\n" "}", false); - ASSERT_EQUALS("[test.c:6]: (error) Memory leak: f.realm\n", errout_str()); + ASSERT_EQUALS("[test.c:6:1]: (error) Memory leak: f.realm [memleak]\n", errout_str()); } void customAllocation() { // #4770 @@ -2189,7 +2192,7 @@ class TestMemleakStructMember : public TestFixture { " struct ABC abc;\n" " abc.a = myalloc();\n" "}", false); - ASSERT_EQUALS("[test.c:7]: (error) Memory leak: abc.a\n", errout_str()); + ASSERT_EQUALS("[test.c:7:1]: (error) Memory leak: abc.a [memleak]\n", errout_str()); } void lambdaInScope() { @@ -2215,7 +2218,7 @@ class TestMemleakStructMember : public TestFixture { " s.p = new int;\n" " };\n" "}\n", true); - ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: s.p\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:5]: (error) Memory leak: s.p [memleak]\n", errout_str()); check( "struct S { int* p; };\n" @@ -2263,6 +2266,7 @@ class TestMemleakNoVar : public TestFixture { } void run() override { + mNewTemplate = true; // pass allocated memory to function.. TEST_CASE(functionParameter); @@ -2285,7 +2289,7 @@ class TestMemleakNoVar : public TestFixture { check("void x() {\n" " strcpy(a, strdup(p));\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with strdup, strcpy doesn't release it.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:15]: (error) Allocation with strdup, strcpy doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("char *x() {\n" " char *ret = strcpy(malloc(10), \"abc\");\n" @@ -2324,19 +2328,19 @@ class TestMemleakNoVar : public TestFixture { "{\n" " if(TRUE || strcmp(strdup(a), b));\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Allocation with strdup, strcmp doesn't release it.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:23]: (error) Allocation with strdup, strcmp doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void f()\n" "{\n" " if(!strcmp(strdup(a), b) == 0);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Allocation with strdup, strcmp doesn't release it.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:16]: (error) Allocation with strdup, strcmp doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void f()\n" "{\n" " 42, strcmp(strdup(a), b);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Allocation with strdup, strcmp doesn't release it.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:16]: (error) Allocation with strdup, strcmp doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void f() {\n" " assert(freopen(\"/dev/null\", \"r\", stdin));\n" @@ -2346,7 +2350,7 @@ class TestMemleakNoVar : public TestFixture { check("void x() {\n" " strcpy(a, (void*)strdup(p));\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with strdup, strcpy doesn't release it.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:22]: (error) Allocation with strdup, strcpy doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void* malloc1() {\n" " return (malloc(1));\n" @@ -2363,13 +2367,13 @@ class TestMemleakNoVar : public TestFixture { " free(malloc(1));\n" " strcpy(a, strdup(p));\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Allocation with strdup, strcpy doesn't release it.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:15]: (error) Allocation with strdup, strcpy doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void f() {\n" " memcmp(calloc(10, 10), strdup(q), 100);\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with calloc, memcmp doesn't release it.\n" - "[test.cpp:2]: (error) Allocation with strdup, memcmp doesn't release it.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:12]: (error) Allocation with calloc, memcmp doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:2:28]: (error) Allocation with strdup, memcmp doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void* f(int size) {\n" " return (void*) malloc(size);\n" @@ -2383,8 +2387,8 @@ class TestMemleakNoVar : public TestFixture { check("void f() { if (new int[42]) {} }\n" // #10857 "void g() { if (malloc(42)) {} }\n"); - ASSERT_EQUALS("[test.cpp:1]: (error) Allocation with new, if doesn't release it.\n" - "[test.cpp:2]: (error) Allocation with malloc, if doesn't release it.\n", + ASSERT_EQUALS("[test.cpp:1:16]: (error) Allocation with new, if doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:2:16]: (error) Allocation with malloc, if doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("const char* string(const char* s) {\n" @@ -2428,11 +2432,11 @@ class TestMemleakNoVar : public TestFixture { " f(new tm());\n" " f(malloc(sizeof(S)));\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (error) Allocation with new, f doesn't release it.\n" - "[test.cpp:5]: (error) Allocation with new, f doesn't release it.\n" - "[test.cpp:6]: (error) Allocation with new, f doesn't release it.\n" - "[test.cpp:7]: (error) Allocation with new, f doesn't release it.\n" - "[test.cpp:8]: (error) Allocation with malloc, f doesn't release it.\n", + ASSERT_EQUALS("[test.cpp:4:7]: (error) Allocation with new, f doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:5:7]: (error) Allocation with new, f doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:6:7]: (error) Allocation with new, f doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:7:7]: (error) Allocation with new, f doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:8:7]: (error) Allocation with malloc, f doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void f(uintptr_t u);\n" @@ -2445,7 +2449,7 @@ class TestMemleakNoVar : public TestFixture { "void g() {\n" " f((uint8_t)new int());\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (error) Allocation with new, f doesn't release it.\n", + ASSERT_EQUALS("[test.cpp:3:16]: (error) Allocation with new, f doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void f(int i, T t);\n" @@ -2469,25 +2473,25 @@ class TestMemleakNoVar : public TestFixture { "{\n" " malloc(10);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'malloc' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void x()\n" "{\n" " calloc(10, 1);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'calloc' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Return value of allocation function 'calloc' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void x()\n" "{\n" " strdup(\"Test\");\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'strdup' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Return value of allocation function 'strdup' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void x()\n" "{\n" " (char*) malloc(10);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'malloc' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:13]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void x()\n" "{\n" @@ -2516,7 +2520,7 @@ class TestMemleakNoVar : public TestFixture { "{\n" " 42,malloc(42);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'malloc' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:8]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void *f()\n" "{\n" @@ -2526,7 +2530,7 @@ class TestMemleakNoVar : public TestFixture { "{\n" " f();\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (error) Return value of allocation function 'f' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:5]: (error) Return value of allocation function 'f' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void f()\n" // #8100 "{\n" @@ -2551,7 +2555,7 @@ class TestMemleakNoVar : public TestFixture { "{\n" " if(!malloc(5)) fail();\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'malloc' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("FOO* factory() {\n" " FOO* foo = new (std::nothrow) FOO;\n" @@ -2603,25 +2607,25 @@ class TestMemleakNoVar : public TestFixture { " new int{ 1 };\n" " new uint8_t[4];\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:3]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:4]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:5]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:6]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:7]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:8]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:9]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:10]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:11]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:12]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:13]: (error) Return value of allocation function 'new' is not stored.\n", + ASSERT_EQUALS("[test.cpp:2:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:3:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:4:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:5:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:6:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:7:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:8:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:9:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:10:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:11:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:12:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:13:5]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void f(int* p) {\n" " new auto('c');\n" " new(p) int;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:2]: (error) Return value of allocation function 'new' is not stored.\n" + TODO_ASSERT_EQUALS("[test.cpp:1:29]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" "[test.cpp:3]: (error) Return value of allocation function 'new' is not stored.\n", "", errout_str()); @@ -2662,24 +2666,24 @@ class TestMemleakNoVar : public TestFixture { check("void f(bool b) { if (b && malloc(42)) {} }\n" // // #10858 "void g(bool b) { if (b || malloc(42)) {} }\n"); - ASSERT_EQUALS("[test.cpp:1]: (error) Return value of allocation function 'malloc' is not stored.\n" - "[test.cpp:2]: (error) Return value of allocation function 'malloc' is not stored.\n", + ASSERT_EQUALS("[test.cpp:1:27]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:2:27]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void f0(const bool b) { b ? new int : nullptr; }\n" // #11155 "void f1(const bool b) { b ? nullptr : new int; }\n" "int* g0(const bool b) { return b ? new int : nullptr; }\n" "void g1(const bool b) { h(b, b ? nullptr : new int); }\n"); - ASSERT_EQUALS("[test.cpp:1]: (error) Return value of allocation function 'new' is not stored.\n" - "[test.cpp:2]: (error) Return value of allocation function 'new' is not stored.\n", + ASSERT_EQUALS("[test.cpp:1:29]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:2:39]: (error) Return value of allocation function 'new' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void f() {\n" // #11157 " switch (*new int) { case 42: break; }\n" " switch (*malloc(42)) { case 42: break; }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with new, switch doesn't release it.\n" - "[test.cpp:3]: (error) Allocation with malloc, switch doesn't release it.\n", + ASSERT_EQUALS("[test.cpp:2:14]: (error) Allocation with new, switch doesn't release it. [leakNoVarFunctionCall]\n" + "[test.cpp:3:14]: (error) Allocation with malloc, switch doesn't release it. [leakNoVarFunctionCall]\n", errout_str()); check("void f() {\n" @@ -2703,42 +2707,42 @@ class TestMemleakNoVar : public TestFixture { check("void x() {\n" " f(shared_ptr(new int(42)), g());\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:5]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void x() {\n" " h(12, f(shared_ptr(new int(42)), g()));\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:11]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void x() {\n" " f(unique_ptr(new int(42)), g());\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_unique() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:5]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_unique() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void x() {\n" " f(g(), shared_ptr(new int(42)));\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:5]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void x() {\n" " f(g(), unique_ptr(new int(42)));\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_unique() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:5]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_unique() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void x() {\n" " f(shared_ptr(new char), make_unique(32));\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If make_unique() throws, memory could be leaked. Use make_shared() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:5]: (warning, inconclusive) Unsafe allocation. If make_unique() throws, memory could be leaked. Use make_shared() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void x() {\n" " f(g(124), h(\"test\", 234), shared_ptr(new char));\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If h() throws, memory could be leaked. Use make_shared() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:5]: (warning, inconclusive) Unsafe allocation. If h() throws, memory could be leaked. Use make_shared() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void x() {\n" " f(shared_ptr(new std::string(\"\")), g());\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:5]: (warning, inconclusive) Unsafe allocation. If g() throws, memory could be leaked. Use make_shared() instead. [leakUnsafeArgAlloc]\n", errout_str()); check("void g(int x) throw() { }\n" "void x() {\n" @@ -2766,13 +2770,13 @@ class TestMemleakNoVar : public TestFixture { check("void foo() {\n" " fopen(\"file.txt\", \"r\");\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) Return value of allocation function 'fopen' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:3]: (error) Return value of allocation function 'fopen' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void foo() {\n" " FILE *f = fopen(\"file.txt\", \"r\");\n" " freopen(\"file.txt\", \"r\", f);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'freopen' is not stored.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:3]: (error) Return value of allocation function 'freopen' is not stored. [leakReturnValNotUsed]\n", errout_str()); check("void foo() {\n" " freopen(\"file.txt\", \"r\", stdin);\n" diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 68c4f9bf197..2303e8ed944 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -94,6 +94,7 @@ class TestPreprocessor : public TestFixture { const Settings settings0 = settingsBuilder().severity(Severity::information).build(); void run() override { + mNewTemplate = true; // The bug that started the whole work with the new preprocessor TEST_CASE(Bug2190219); @@ -373,7 +374,7 @@ class TestPreprocessor : public TestFixture { const auto settings = dinit(Settings, $.userDefines = "__cplusplus"); const std::string code("#error hello world!\n"); (void)PreprocessorHelper::getcode(settings, *this, code, "X", "test.c"); - ASSERT_EQUALS("[test.c:1]: (error) #error hello world!\n", errout_str()); + ASSERT_EQUALS("[test.c:1:0]: (error) #error hello world! [preprocessorErrorDirective]\n", errout_str()); } // Ticket #2919 - wrong filename reported for #error @@ -383,7 +384,7 @@ class TestPreprocessor : public TestFixture { const auto settings = dinit(Settings, $.userDefines = "TEST"); const std::string code("#file \"ab.h\"\n#error hello world!\n#endfile"); (void)PreprocessorHelper::getcode(settings, *this, code, "TEST", "test.c"); - ASSERT_EQUALS("[ab.h:1]: (error) #error hello world!\n", errout_str()); + ASSERT_EQUALS("[ab.h:1:0]: (error) #error hello world! [preprocessorErrorDirective]\n", errout_str()); } // After including a file @@ -391,7 +392,7 @@ class TestPreprocessor : public TestFixture { const auto settings = dinit(Settings, $.userDefines = "TEST"); const std::string code("#file \"ab.h\"\n\n#endfile\n#error aaa"); (void)PreprocessorHelper::getcode(settings, *this, code, "TEST", "test.c"); - ASSERT_EQUALS("[test.c:2]: (error) #error aaa\n", errout_str()); + ASSERT_EQUALS("[test.c:2:0]: (error) #error aaa [preprocessorErrorDirective]\n", errout_str()); } } @@ -1464,7 +1465,7 @@ class TestPreprocessor : public TestFixture { const std::map actual = PreprocessorHelper::getcode(settings0, *this, filedata); ASSERT_EQUALS(0, actual.size()); - ASSERT_EQUALS("[file.c:2]: (error) No pair for character ('). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout_str()); + ASSERT_EQUALS("[file.c:2:0]: (error) No pair for character ('). Can't process file. File is either invalid or unicode, which is currently not supported. [preprocessorErrorDirective]\n", errout_str()); } } @@ -1479,7 +1480,7 @@ class TestPreprocessor : public TestFixture { const std::string actual(expandMacros(filedata, *this)); ASSERT_EQUALS("", actual); - ASSERT_EQUALS("[file.cpp:3]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout_str()); + ASSERT_EQUALS("[file.cpp:3:0]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported. [preprocessorErrorDirective]\n", errout_str()); } { @@ -1492,7 +1493,7 @@ class TestPreprocessor : public TestFixture { const std::string actual(expandMacros(filedata, *this)); ASSERT_EQUALS("", actual); - ASSERT_EQUALS("[abc.h:2]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout_str()); + ASSERT_EQUALS("[abc.h:2:0]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported. [preprocessorErrorDirective]\n", errout_str()); } { @@ -1505,7 +1506,7 @@ class TestPreprocessor : public TestFixture { const std::string actual(expandMacros(filedata, *this)); ASSERT_EQUALS("", actual); - ASSERT_EQUALS("[file.cpp:2]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout_str()); + ASSERT_EQUALS("[file.cpp:2:0]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported. [preprocessorErrorDirective]\n", errout_str()); } { @@ -1517,7 +1518,7 @@ class TestPreprocessor : public TestFixture { const std::string actual(expandMacros(filedata, *this)); ASSERT_EQUALS("", actual); - ASSERT_EQUALS("[file.cpp:2]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout_str()); + ASSERT_EQUALS("[file.cpp:2:0]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported. [preprocessorErrorDirective]\n", errout_str()); } { @@ -1533,7 +1534,7 @@ class TestPreprocessor : public TestFixture { // expand macros.. (void)expandMacros(filedata, *this); - ASSERT_EQUALS("[file.cpp:7]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout_str()); + ASSERT_EQUALS("[file.cpp:7:0]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported. [preprocessorErrorDirective]\n", errout_str()); } } @@ -1586,7 +1587,7 @@ class TestPreprocessor : public TestFixture { // Compare results.. ASSERT_EQUALS(1, actual.size()); ASSERT_EQUALS("", actual.at("")); - ASSERT_EQUALS("[file.c:6]: (error) failed to expand 'BC', Wrong number of parameters for macro 'BC'.\n", errout_str()); + ASSERT_EQUALS("[file.c:6:0]: (error) failed to expand 'BC', Wrong number of parameters for macro 'BC'. [preprocessorErrorDirective]\n", errout_str()); } void newline_in_macro() { @@ -1903,12 +1904,12 @@ class TestPreprocessor : public TestFixture { void invalid_define_1() { (void)PreprocessorHelper::getcode(settings0, *this, "#define =\n"); - ASSERT_EQUALS("[file.c:1]: (error) Failed to parse #define\n", errout_str()); + ASSERT_EQUALS("[file.c:1:0]: (error) Failed to parse #define [preprocessorErrorDirective]\n", errout_str()); } void invalid_define_2() { // #4036 (void)PreprocessorHelper::getcode(settings0, *this, "#define () {(int f(x) }\n"); - ASSERT_EQUALS("[file.c:1]: (error) Failed to parse #define\n", errout_str()); + ASSERT_EQUALS("[file.c:1:0]: (error) Failed to parse #define [preprocessorErrorDirective]\n", errout_str()); } void inline_suppressions() { @@ -2037,7 +2038,7 @@ class TestPreprocessor : public TestFixture { const char code[] = "#elif (){\n"; const std::string actual = PreprocessorHelper::getcode(settings0, *this, code, "TEST", "test.c"); ASSERT_EQUALS("", actual); - ASSERT_EQUALS("[test.c:1]: (error) #elif without #if\n", errout_str()); + ASSERT_EQUALS("[test.c:1:0]: (error) #elif without #if [preprocessorErrorDirective]\n", errout_str()); } void getConfigs1() { @@ -2286,8 +2287,8 @@ class TestPreprocessor : public TestFixture { // Preprocess => don't crash.. (void)PreprocessorHelper::getcode(settings0, *this, filedata); ASSERT_EQUALS( - "[file.c:1]: (error) Syntax error in #ifdef\n" - "[file.c:1]: (error) Syntax error in #ifdef\n", errout_str()); + "[file.c:1:0]: (error) Syntax error in #ifdef [preprocessorErrorDirective]\n" + "[file.c:1:0]: (error) Syntax error in #ifdef [preprocessorErrorDirective]\n", errout_str()); } void garbage() { @@ -2303,7 +2304,7 @@ class TestPreprocessor : public TestFixture { const auto settings = dinit(Settings, $.userDefines = "foo"); const std::string code("#error hello world!\n"); (void)PreprocessorHelper::getcode(settings, *this, code, "X", "./././test.c"); - ASSERT_EQUALS("[test.c:1]: (error) #error hello world!\n", errout_str()); + ASSERT_EQUALS("[test.c:1:0]: (error) #error hello world! [preprocessorErrorDirective]\n", errout_str()); } // test for existing local include diff --git a/test/teststl.cpp b/test/teststl.cpp index c005ae125f4..a367013851e 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -35,6 +35,7 @@ class TestStl : public TestFixture { /*const*/ Settings settings = settingsBuilder().severity(Severity::warning).severity(Severity::style).severity(Severity::performance).library("std.cfg").build(); void run() override { + // TODO: mNewTemplate = true; TEST_CASE(outOfBounds); TEST_CASE(outOfBoundsSymbolic); TEST_CASE(outOfBoundsIndexExpression); diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 817f9e9ef19..ca7e081be10 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -48,6 +48,7 @@ class TestSuppressions : public TestFixture { const std::string templateFormat{"{callstack}: ({severity}) {inconclusive:inconclusive: }{message}"}; void run() override { + mNewTemplate = true; TEST_CASE(suppressionsBadId1); TEST_CASE(suppressionsDosFormat); // Ticket #1836 TEST_CASE(suppressionsFileNameWithColon); // Ticket #1919 - filename includes colon @@ -382,7 +383,7 @@ class TestSuppressions : public TestFixture { " a++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" " int a;\n" @@ -391,8 +392,8 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n" - "[test.cpp:5]: (error) Uninitialized variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Uninitialized variable: a [uninitvar]\n" + "[test.cpp:5:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); // suppress uninitvar globally ASSERT_EQUALS(0, (this->*check)("void f() {\n" @@ -408,8 +409,8 @@ class TestSuppressions : public TestFixture { " a++;\n" "}\n", ""); - ASSERT_EQUALS("[test.cpp:2]: (error) File suppression should be at the top of the file\n" - "[test.cpp:4]: (error) Uninitialized variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:0]: (error) File suppression should be at the top of the file [preprocessorErrorDirective]\n" + "[test.cpp:4:5]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); (this->*check)("void f() {\n" " int a;\n" @@ -417,8 +418,8 @@ class TestSuppressions : public TestFixture { "}\n" "// cppcheck-suppress-file uninitvar\n", ""); - ASSERT_EQUALS("[test.cpp:5]: (error) File suppression should be at the top of the file\n" - "[test.cpp:3]: (error) Uninitialized variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:0]: (error) File suppression should be at the top of the file [preprocessorErrorDirective]\n" + "[test.cpp:3:5]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); ASSERT_EQUALS(0, (this->*check)("// cppcheck-suppress-file uninitvar\n" "void f() {\n" @@ -461,7 +462,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "uninitvar")); - ASSERT_EQUALS("(information) Unmatched suppression: uninitvar\n", errout_str()); + ASSERT_EQUALS("(information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); (this->*check)("// cppcheck-suppress-file uninitvar\n" "void f() {\n" @@ -469,7 +470,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", ""); - ASSERT_EQUALS("[test.cpp:1]: (information) Unmatched suppression: uninitvar\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); // suppress uninitvar for this file only ASSERT_EQUALS(0, (this->*check)("void f() {\n" @@ -485,7 +486,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "uninitvar:test.cpp"); - ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: uninitvar\n", errout_str()); + ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); // suppress all for this file only ASSERT_EQUALS(0, (this->*check)("void f() {\n" @@ -501,7 +502,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "*:test.cpp"); - ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: *\n", errout_str()); + ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: * [unmatchedSuppression]\n", errout_str()); // suppress uninitvar for this file and line ASSERT_EQUALS(0, (this->*check)("void f() {\n" @@ -517,7 +518,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "uninitvar:test.cpp:3"); - ASSERT_EQUALS("[test.cpp:3]: (information) Unmatched suppression: uninitvar\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); // suppress uninitvar inline ASSERT_EQUALS(0, (this->*check)("void f() {\n" @@ -647,7 +648,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", ""); - ASSERT_EQUALS("[test.cpp:4]: (information) Unmatched suppression: uninitvar\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); // suppress block inline checks ASSERT_EQUALS(0, (this->*check)("void f() {\n" @@ -669,9 +670,9 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:2]: (error) Suppress Begin: No matching end\n" - "[test.cpp:4]: (error) Uninitialized variable: a\n" - "[test.cpp:6]: (error) Uninitialized variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:0]: (error) Suppress Begin: No matching end [preprocessorErrorDirective]\n" + "[test.cpp:4:5]: (error) Uninitialized variable: a [uninitvar]\n" + "[test.cpp:6:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" " int a;\n" @@ -681,9 +682,9 @@ class TestSuppressions : public TestFixture { " // cppcheck-suppress-end uninitvar\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:6]: (error) Suppress End: No matching begin\n" - "[test.cpp:3]: (error) Uninitialized variable: a\n" - "[test.cpp:5]: (error) Uninitialized variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:0]: (error) Suppress End: No matching begin [preprocessorErrorDirective]\n" + "[test.cpp:3:5]: (error) Uninitialized variable: a [uninitvar]\n" + "[test.cpp:5:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" " int a;\n" @@ -694,7 +695,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:7]: (error) Uninitialized variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" " int a;\n" @@ -705,7 +706,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:7]: (error) Uninitialized variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" " int a;\n" @@ -716,7 +717,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:7]: (error) Uninitialized variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" " int a;\n" @@ -727,7 +728,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:7]: (error) Uninitialized variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); (this->*check)("void f() {\n" " int a;\n" @@ -783,7 +784,7 @@ class TestSuppressions : public TestFixture { " // cppcheck-suppress-end [uninitvar, syntaxError]\n" "}\n", ""); - ASSERT_EQUALS("[test.cpp:2]: (information) Unmatched suppression: syntaxError\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:0]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str()); (this->*check)("// cppcheck-suppress-begin [uninitvar, syntaxError]\n" "void f() {\n" @@ -798,7 +799,7 @@ class TestSuppressions : public TestFixture { "}\n" "// cppcheck-suppress-end [uninitvar, syntaxError]\n", ""); - ASSERT_EQUALS("[test.cpp:1]: (information) Unmatched suppression: syntaxError\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:0]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str()); (this->*check)("// cppcheck-suppress-begin [uninitvar, syntaxError]\n" "void f() {\n" @@ -813,7 +814,7 @@ class TestSuppressions : public TestFixture { "}\n" "// cppcheck-suppress-end [uninitvar, syntaxError]", ""); - ASSERT_EQUALS("[test.cpp:1]: (information) Unmatched suppression: syntaxError\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:0]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str()); // test of multiple suppression types (this->*check)("// cppcheck-suppress-file uninitvar\n" @@ -863,7 +864,7 @@ class TestSuppressions : public TestFixture { " a++;\n" "}\n", ""); - ASSERT_EQUALS("[test.cpp:4]: (information) Unmatched suppression: uninitvar\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); // #5746 - exitcode ASSERT_EQUALS(1U, @@ -871,7 +872,7 @@ class TestSuppressions : public TestFixture { " int a; return a;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:2]: (error) Uninitialized variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:17]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); ASSERT_EQUALS(0U, (this->*check)("int f() {\n" @@ -891,7 +892,7 @@ class TestSuppressions : public TestFixture { "#define DIV(A,B) A/B\n" "a = DIV(10,1);\n", ""); - ASSERT_EQUALS("[test.cpp:2]: (information) Unmatched suppression: abc\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:0]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str()); } void suppressionsSettingsFiles() { @@ -1057,7 +1058,7 @@ class TestSuppressions : public TestFixture { " a++; b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:5]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); } void inlinesuppress_symbolname_Files() { @@ -1232,7 +1233,7 @@ class TestSuppressions : public TestFixture { const char code[] = "int f() { int a; return a; }"; ASSERT_EQUALS(0, cppCheck.check(FileWithDetails("test.c"), code)); // <- no unsuppressed error is seen - ASSERT_EQUALS("[test.c:1]: (error) Uninitialized variable: a\n", errout_str()); // <- report error so ThreadExecutor can suppress it and make sure the global suppression is matched. + ASSERT_EQUALS("[test.c:1:25]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); // <- report error so ThreadExecutor can suppress it and make sure the global suppression is matched. } void inlinesuppress_unusedFunction() const { // #4210, #4946 - wrong report of "unmatchedSuppression" for "unusedFunction" @@ -1401,7 +1402,7 @@ class TestSuppressions : public TestFixture { "}\n" "f(0, 1);\n"; ASSERT_EQUALS(1, (this->*check)(code3, "zerodiv:test.cpp:3")); // suppress 'zerodiv' at line 3 of test.cpp - ASSERT_EQUALS("[test.cpp:2]: (error) Division by zero.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:14]: (error) Division by zero. [zerodiv]\n", errout_str()); } void suppressingSyntaxErrorAndExitCodeFiles() { @@ -1419,7 +1420,7 @@ class TestSuppressions : public TestFixture { mfiles["test.cpp"] = "fi if;"; mfiles["test2.cpp"] = "fi if"; ASSERT_EQUALS(1, (this->*check)(mfiles, "*:test.cpp")); - ASSERT_EQUALS("[test2.cpp:1]: (error) syntax error\n", errout_str()); + ASSERT_EQUALS("[test2.cpp:1:4]: (error) syntax error [syntaxError]\n", errout_str()); } void suppressingSyntaxErrorAndExitCodeMultiFileFiles() { @@ -1487,14 +1488,14 @@ class TestSuppressions : public TestFixture { suppressions.emplace_back("abc", "a.c", 10U); suppressions.emplace_back("unmatchedSuppression", "b.c", SuppressionList::Suppression::NO_LINE); ASSERT_EQUALS(true, SuppressionList::reportUnmatchedSuppressions(suppressions, *this)); - ASSERT_EQUALS("[a.c:10]: (information) Unmatched suppression: abc\n", errout_str()); + ASSERT_EQUALS("[a.c:10:0]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str()); // don't suppress unmatchedSuppression when line is mismatching suppressions.clear(); suppressions.emplace_back("abc", "a.c", 10U); suppressions.emplace_back("unmatchedSuppression", "a.c", 1U); ASSERT_EQUALS(true, SuppressionList::reportUnmatchedSuppressions(suppressions, *this)); - ASSERT_EQUALS("[a.c:10]: (information) Unmatched suppression: abc\n", errout_str()); + ASSERT_EQUALS("[a.c:10:0]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str()); } void suppressionsParseXmlFile() const { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 00952138a17..f8857eaad24 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -49,6 +49,7 @@ class TestTokenizer : public TestFixture { const Settings settings_windows = settingsBuilder().library("windows.cfg").build(); void run() override { + mNewTemplate = true; TEST_CASE(tokenize1); TEST_CASE(tokenize2); TEST_CASE(tokenize4); @@ -569,7 +570,7 @@ class TestTokenizer : public TestFixture { "{ if ( p . y ( ) > yof ) { } }"; ASSERT_EQUALS(code, tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable yof\n", + "[test.cpp:2:20]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable yof [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -909,7 +910,7 @@ class TestTokenizer : public TestFixture { //valid, when there's also this declaration: 'constexpr int g[1] = {0};' ASSERT_NO_THROW(tokenizeAndStringify("void f(int n) {switch (n) { case g[0]: z(); break;}}")); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable g\n", + "[test.cpp:1:34]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable g [valueFlowBailoutIncompleteVar]\n", errout_str()); //valid, similar to above case @@ -919,7 +920,7 @@ class TestTokenizer : public TestFixture { //valid, when 'x' and 'y' are constexpr. ASSERT_NO_THROW(tokenizeAndStringify("void f(int n) {switch (n) { case sqrt(x+y): z(); break;}}")); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x\n", + "[test.cpp:1:39]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -941,14 +942,14 @@ class TestTokenizer : public TestFixture { const char code[] ="void f() { for each ( char c in MyString ) { Console::Write(c); } }"; ASSERT_EQUALS("void f ( ) { for ( char c : MyString ) { Console :: Write ( c ) ; } }", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable MyString\n", + "[test.cpp:1:33]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable MyString [valueFlowBailoutIncompleteVar]\n", errout_str()); } void ifconstexpr() { ASSERT_EQUALS("void f ( ) { if ( FOO ) { bar ( c ) ; } }", tokenizeAndStringify("void f() { if constexpr ( FOO ) { bar(c); } }")); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable FOO\n", + "[test.cpp:1:27]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable FOO [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1117,7 +1118,7 @@ class TestTokenizer : public TestFixture { "else { ; }\n" "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:9]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1131,7 +1132,7 @@ class TestTokenizer : public TestFixture { "if ( a ) { if ( b ) { } }\n" "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:9]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1145,7 +1146,7 @@ class TestTokenizer : public TestFixture { "if ( a ) { for ( ; ; ) { } }\n" "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:9]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1167,7 +1168,7 @@ class TestTokenizer : public TestFixture { "return str ;\n" "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:4]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable somecondition\n", + "[test.cpp:4:9]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable somecondition [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1256,7 +1257,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("void f ( ) { ( void ) ( { if ( * p ) { ( * p ) = x ( ) ; } } ) }", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p\n", + "[test.cpp:1:27]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } } @@ -1279,7 +1280,7 @@ class TestTokenizer : public TestFixture { "bar2 ( ) ; }\n" "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:9]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1313,7 +1314,7 @@ class TestTokenizer : public TestFixture { "bar2 ( ) ; } } }\n" "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:9]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1510,7 +1511,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS(result, tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x\n", + "[test.cpp:2:17]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } } @@ -1571,7 +1572,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS(expected, tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:14]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -1590,7 +1591,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS(expected, tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:14]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } } @@ -1718,7 +1719,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS("void foo ( ) { if ( x ) { int x ; } { } }", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x\n", + "[test.cpp:1:20]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } } @@ -1765,7 +1766,7 @@ class TestTokenizer : public TestFixture { const char code[] = "template < typename T1 > template < typename T2 > " "void A < T1 > :: foo ( T2 ) { }"; ASSERT_EQUALS(code, tokenizeAndStringify(code)); - ASSERT_EQUALS("[test.cpp:1]: (debug) Executable scope 'foo' with unknown function.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:68]: (debug) Executable scope 'foo' with unknown function. [symbolDatabaseWarning]\n", errout_str()); } void simplifyFunctionParametersErrors() { @@ -1843,7 +1844,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("void foo ( ) { free ( ( void * ) p ) ; }", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p\n", + "[test.cpp:1:29]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -1881,7 +1882,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS("void foo ( ) { free ( p ) ; }", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p\n", + "[test.cpp:1:22]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -1894,7 +1895,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS("void foo ( ) { delete p ; }", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p\n", + "[test.cpp:1:24]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -1906,7 +1907,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS("void foo ( ) { delete [ ] p ; }", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p\n", + "[test.cpp:1:27]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p [valueFlowBailoutIncompleteVar]\n", errout_str()); } } @@ -2196,7 +2197,7 @@ class TestTokenizer : public TestFixture { " int addI = frontPoint == 2 || frontPoint == 1 ? i = 0, 1 : (i = nX - 2, -1);\n" "}")); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable frontPoint\n", + "[test.cpp:2:16]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable frontPoint [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -2439,7 +2440,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS("void f ( ) {\nint a ; a = ( x < y ) ? 1 : 0 ;\n}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x\n", + "[test.cpp:2:14]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -2482,7 +2483,7 @@ class TestTokenizer : public TestFixture { "g ( ( double ) v1 * v2 , v3 , v4 ) ;\n" "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable v1\n", + "[test.cpp:2:15]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable v1 [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -2585,7 +2586,7 @@ class TestTokenizer : public TestFixture { "{\n" "const int X = 0 ;\n" "}", tokenizeAndStringify(code)); - ASSERT_EQUALS("[test.cpp:1]: (debug) Executable scope 'b' with unknown function.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:9]: (debug) Executable scope 'b' with unknown function. [symbolDatabaseWarning]\n", errout_str()); } void vardecl21() { // type in namespace @@ -2657,7 +2658,7 @@ class TestTokenizer : public TestFixture { const char expected[] = "extern int * new ; extern int obj ; extern int player ;"; ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, false)); ASSERT_EQUALS(expected, tokenizeAndStringify(code)); - ASSERT_EQUALS("[test.cpp:1]: (debug) Scope::checkVariable found variable 'new' with varid 0.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:13]: (debug) Scope::checkVariable found variable 'new' with varid 0. [varid0]\n", errout_str()); } void vardecl27() { // #7850 (segmentation fault) @@ -2768,7 +2769,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(out5, tokenizeAndStringify(in5)); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable pos\n", + "[test.cpp:3:16]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable pos [valueFlowBailoutIncompleteVar]\n", errout_str()); } { @@ -3826,7 +3827,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS(expected, tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p\n", + "[test.cpp:2:12]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable p [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -4136,7 +4137,7 @@ class TestTokenizer : public TestFixture { "}"; ASSERT_EQUALS(std::string::npos, tokenizeAndStringify(code).find("> >")); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable sprite_shift\n", + "[test.cpp:2:24]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable sprite_shift [valueFlowBailoutIncompleteVar]\n", errout_str()); } { @@ -4266,7 +4267,7 @@ class TestTokenizer : public TestFixture { void cpp14template() { // Ticket #6708 (void)tokenizeAndStringify("template " "decltype(auto) forward(T& t) { return 0; }"); - ASSERT_EQUALS("[test.cpp:1]: (debug) auto token with no type.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:32]: (debug) auto token with no type. [autoNoType]\n", errout_str()); } void arraySize() { @@ -4277,7 +4278,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("; int a [ 2 ] = { b > c ? 1 : 2 , 3 } ;", tokenizeAndStringify(";int a[]={ b>c?1:2,3};")); ASSERT_EQUALS("int main ( ) { int a [ 2 ] = { b < c ? 1 : 2 , 3 } }", tokenizeAndStringify("int main(){int a[]={b void g ( S < & T :: operator+ > ) { }", tokenizeAndStringify(code2)); @@ -5474,7 +5475,7 @@ class TestTokenizer : public TestFixture { "}", tokenizeAndStringify(code)); ASSERT_EQUALS( - "[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable RSLEqual\n", + "[test.cpp:1:116]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable RSLEqual [valueFlowBailoutIncompleteVar]\n", filter_valueflow(errout_str())); } @@ -5547,7 +5548,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("template < class ... Ts > struct overloaded : Ts ... { using Ts :: operator ( ) ... ; } ;\n" "int main ( ) { }", tokenizeAndStringify(code)); - ASSERT_EQUALS("[test.cpp:1]: (debug) simplifyOperatorName: found unsimplified operator name\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:61]: (debug) simplifyOperatorName: found unsimplified operator name [debug]\n", errout_str()); } void simplifyOperatorName29() { @@ -6687,7 +6688,7 @@ class TestTokenizer : public TestFixture { " auto l = [x = 3](std::string&& v) { };\n" "}\n")); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x\n", + "[test.cpp:2:15]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x [valueFlowBailoutIncompleteVar]\n", errout_str()); ASSERT_EQUALS("forinti(0=i5<=i++;;(", testAst("for (int (i) = 0; (i) <= 5; (i)++) {}")); // #13225 @@ -8212,7 +8213,7 @@ class TestTokenizer : public TestFixture { ASSERT_NO_THROW(tokenizeAndStringify("template struct X {};\n" // don't crash "template auto f(T t) -> X {}\n")); - ASSERT_EQUALS("[test.cpp:2]: (debug) auto token with no type.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:22]: (debug) auto token with no type. [autoNoType]\n", errout_str()); #undef testIsCpp11init } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 863518b6ce2..26e847c887f 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -34,6 +34,7 @@ class TestUninitVar : public TestFixture { const Settings settings = settingsBuilder().library("std.cfg").build(); void run() override { + // TODO: mNewTemplate = true; TEST_CASE(uninitvar1); TEST_CASE(uninitvar_warn_once); // only write 1 warning at a time TEST_CASE(uninitvar_decl); // handling various types in C and C++ files diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index e7779c69d1b..5350535d42f 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -34,6 +34,7 @@ class TestUnusedVar : public TestFixture { const Settings settings = settingsBuilder().severity(Severity::style).checkLibrary().library("std.cfg").build(); void run() override { + mNewTemplate = true; TEST_CASE(isRecordTypeWithoutSideEffects); TEST_CASE(cleanFunction); @@ -326,7 +327,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " A a;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:6]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage( "class A {};\n" @@ -337,7 +338,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " B b;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Unused variable: b\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:6]: (style) Unused variable: b [unusedVariable]\n", errout_str()); functionVariableUsage( "class C {\n" @@ -347,7 +348,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); functionVariableUsage( "class D {\n" @@ -357,7 +358,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " D d;\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Unused variable: d\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:6]: (style) Unused variable: d [unusedVariable]\n", errout_str()); functionVariableUsage( "class E {\n" @@ -367,7 +368,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " E e;\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Unused variable: e\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:6]: (style) Unused variable: e [unusedVariable]\n", errout_str()); functionVariableUsage( "class F {\n" @@ -378,7 +379,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " F f;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Unused variable: f\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:6]: (style) Unused variable: f [unusedVariable]\n", errout_str()); functionVariableUsage( "class F {\n" @@ -389,7 +390,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " F f;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Unused variable: f\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:6]: (style) Unused variable: f [unusedVariable]\n", errout_str()); functionVariableUsage( "int y = 0;\n" @@ -401,7 +402,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " F f;\n" "}"); - ASSERT_EQUALS("[test.cpp:8]: (style) Unused variable: f\n", errout_str()); + ASSERT_EQUALS("[test.cpp:8:6]: (style) Unused variable: f [unusedVariable]\n", errout_str()); functionVariableUsage( "int y = 0;" @@ -413,7 +414,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " F f;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Unused variable: f\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:6]: (style) Unused variable: f [unusedVariable]\n", errout_str()); functionVariableUsage( "int y = 0;" @@ -425,7 +426,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " F f;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Unused variable: f\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:6]: (style) Unused variable: f [unusedVariable]\n", errout_str()); functionVariableUsage( "int y = 0;" @@ -437,7 +438,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " F f;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Unused variable: f\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:6]: (style) Unused variable: f [unusedVariable]\n", errout_str()); functionVariableUsage( "int y = 0;" @@ -449,7 +450,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " F f;\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Unused variable: f\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:6]: (style) Unused variable: f [unusedVariable]\n", errout_str()); // non-empty constructor functionVariableUsage( @@ -672,7 +673,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:8]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:8:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // return variable without side effects functionVariableUsage( @@ -688,7 +689,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:11]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:11:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // return variable with side effects functionVariableUsage( @@ -735,7 +736,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:11]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:11:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // changing global variable in return functionVariableUsage( @@ -833,7 +834,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:12]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:12:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // changing global array variable in function body functionVariableUsage( @@ -932,7 +933,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:13]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:13:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); functionVariableUsage( "int x[] = {0, 1, 3};\n" @@ -949,7 +950,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:13]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:13:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); functionVariableUsage( "int x[] = {0, 1, 3};\n" @@ -998,7 +999,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:13]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:13:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // variable of user-defined class without side effects functionVariableUsage( @@ -1015,7 +1016,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:12]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:12:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // variable of user-defined class with side effects functionVariableUsage( @@ -1068,7 +1069,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:12]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:12:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // nested side-effects function call functionVariableUsage( @@ -1123,7 +1124,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:14]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:14:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // indirect clean function recursion functionVariableUsage( @@ -1145,7 +1146,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:17]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:17:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // side-effect function recursion functionVariableUsage( @@ -1198,7 +1199,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:11]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:11:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // multiple side-effect returns functionVariableUsage( @@ -1229,7 +1230,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:10]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:10:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // global variable modifying through function argument functionVariableUsage( @@ -1282,7 +1283,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:13]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:13:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // global struct variable modification functionVariableUsage( @@ -1316,7 +1317,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:12]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:12:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); // global pointer to struct variable modification functionVariableUsage( @@ -1352,7 +1353,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:13]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:13:6]: (style) Unused variable: c [unusedVariable]\n", errout_str()); } // #5355 - False positive: Variable is not assigned a value. @@ -1386,9 +1387,9 @@ class TestUnusedVar : public TestFixture { " int b;\n" " int c;\n" "};"); - ASSERT_EQUALS("[test.cpp:3]: (style) struct member 'abc::a' is never used.\n" - "[test.cpp:4]: (style) struct member 'abc::b' is never used.\n" - "[test.cpp:5]: (style) struct member 'abc::c' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) struct member 'abc::a' is never used. [unusedStructMember]\n" + "[test.cpp:4:9]: (style) struct member 'abc::b' is never used. [unusedStructMember]\n" + "[test.cpp:5:9]: (style) struct member 'abc::c' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("union abc\n" "{\n" @@ -1396,9 +1397,9 @@ class TestUnusedVar : public TestFixture { " int b;\n" " int c;\n" "};"); - ASSERT_EQUALS("[test.cpp:3]: (style) union member 'abc::a' is never used.\n" - "[test.cpp:4]: (style) union member 'abc::b' is never used.\n" - "[test.cpp:5]: (style) union member 'abc::c' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) union member 'abc::a' is never used. [unusedStructMember]\n" + "[test.cpp:4:9]: (style) union member 'abc::b' is never used. [unusedStructMember]\n" + "[test.cpp:5:9]: (style) union member 'abc::c' is never used. [unusedStructMember]\n", errout_str()); } void structmember2() { @@ -1509,7 +1510,7 @@ class TestUnusedVar : public TestFixture { "{\n" " ab->a = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) struct member 'AB::b' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:9]: (style) struct member 'AB::b' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("struct AB\n" "{\n" @@ -1521,7 +1522,7 @@ class TestUnusedVar : public TestFixture { "{\n" " ab->a = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) struct member 'AB::b' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:9]: (style) struct member 'AB::b' is never used. [unusedStructMember]\n", errout_str()); } void structmember8() { @@ -1648,7 +1649,7 @@ class TestUnusedVar : public TestFixture { "{\n" " ab.b = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) struct member 'AB::a' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) struct member 'AB::a' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("struct A\n" "{\n" @@ -1691,7 +1692,7 @@ class TestUnusedVar : public TestFixture { " static const int N = 128;\n" // <- used " char E[N];\n" // <- not used "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) struct member 'S::E' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:8]: (style) struct member 'S::E' is never used. [unusedStructMember]\n", errout_str()); } void structmember17() { // #10591 @@ -1727,7 +1728,7 @@ class TestUnusedVar : public TestFixture { " uint8_t* p = (uint8_t*)&s;\n" " return p[10];\n" "};\n"); - ASSERT_EQUALS("[test.cpp:1]: (style) struct member 'S::padding' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:20]: (style) struct member 'S::padding' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("struct S { uint8_t padding[500]; };\n" "uint8_t f(const S& s) {\n" @@ -1735,14 +1736,14 @@ class TestUnusedVar : public TestFixture { " auto p = reinterpret_cast(&s);\n" " return p[10];\n" "};\n"); - ASSERT_EQUALS("[test.cpp:1]: (style) struct member 'S::padding' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:20]: (style) struct member 'S::padding' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("struct S { int i, j; };\n" // #11577 "void f(S s) {\n" " void* p = (void*)&s;\n" " if (s.i) {}\n" "}\n"); - ASSERT_EQUALS("[test.cpp:1]: (style) struct member 'S::j' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:19]: (style) struct member 'S::j' is never used. [unusedStructMember]\n", errout_str()); } void structmember19() { @@ -1753,9 +1754,9 @@ class TestUnusedVar : public TestFixture { " C c;\n" "};\n" "void f(S* s) {}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) struct member 'S::p' is never used.\n" - "[test.cpp:4]: (style) struct member 'S::str' is never used.\n" - "[test.cpp:5]: (style) struct member 'S::c' is never used.\n", + ASSERT_EQUALS("[test.cpp:3:11]: (style) struct member 'S::p' is never used. [unusedStructMember]\n" + "[test.cpp:4:17]: (style) struct member 'S::str' is never used. [unusedStructMember]\n" + "[test.cpp:5:7]: (style) struct member 'S::c' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("class C {};\n" @@ -1765,9 +1766,9 @@ class TestUnusedVar : public TestFixture { " C c;\n" "};\n" "void f(S& s) {}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) struct member 'S::p' is never used.\n" - "[test.cpp:4]: (style) struct member 'S::str' is never used.\n" - "[test.cpp:5]: (style) struct member 'S::c' is never used.\n", + ASSERT_EQUALS("[test.cpp:3:11]: (style) struct member 'S::p' is never used. [unusedStructMember]\n" + "[test.cpp:4:17]: (style) struct member 'S::str' is never used. [unusedStructMember]\n" + "[test.cpp:5:7]: (style) struct member 'S::c' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("struct S {\n" // #10848 @@ -1824,7 +1825,7 @@ class TestUnusedVar : public TestFixture { " const A& a = b[0]->v[idx];\n" " return a;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:1]: (style) struct member 'A::i' is never used.\n", + ASSERT_EQUALS("[test.cpp:1:22]: (style) struct member 'A::i' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("struct A {\n" // #10852 @@ -1884,12 +1885,12 @@ class TestUnusedVar : public TestFixture { "struct S {\n" " int f;\n" "};\n"); - ASSERT_EQUALS("[test.cpp:10]: (style) struct member 'S::f' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:10:9]: (style) struct member 'S::f' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("struct A { int i; };\n" "struct B { struct A* pA; };"); - ASSERT_EQUALS("[test.cpp:1]: (style) struct member 'A::i' is never used.\n" - "[test.cpp:2]: (style) struct member 'B::pA' is never used.\n", + ASSERT_EQUALS("[test.cpp:1:16]: (style) struct member 'A::i' is never used. [unusedStructMember]\n" + "[test.cpp:2:22]: (style) struct member 'B::pA' is never used. [unusedStructMember]\n", errout_str()); } @@ -1970,10 +1971,10 @@ class TestUnusedVar : public TestFixture { " S s;\n" " int j;\n" "};\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) struct member 'S::p' is never used.\n" - "[test.cpp:3]: (style) struct member 'S::i' is never used.\n" - "[test.cpp:6]: (style) struct member 'T::s' is never used.\n" - "[test.cpp:7]: (style) struct member 'T::j' is never used.\n", + ASSERT_EQUALS("[test.cpp:2:8]: (style) struct member 'S::p' is never used. [unusedStructMember]\n" + "[test.cpp:3:9]: (style) struct member 'S::i' is never used. [unusedStructMember]\n" + "[test.cpp:6:7]: (style) struct member 'T::s' is never used. [unusedStructMember]\n" + "[test.cpp:7:9]: (style) struct member 'T::j' is never used. [unusedStructMember]\n", errout_str()); } @@ -2006,28 +2007,28 @@ class TestUnusedVar : public TestFixture { checkStructMemberUsage("class C {\n" " int i{};\n" "};\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) class member 'C::i' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:9]: (style) class member 'C::i' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("class C {\n" " int i{}, j{};\n" "public:\n" " int& get() { return i; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) class member 'C::j' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:14]: (style) class member 'C::j' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("class C {\n" "private:\n" " int i;\n" "};\n" "class D : public C {};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) class member 'C::i' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) class member 'C::i' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("class C {\n" "public:\n" " int i;\n" "};\n" "class D : C {};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) class member 'C::i' is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) class member 'C::i' is never used. [unusedStructMember]\n", errout_str()); checkStructMemberUsage("class C {\n" "public:\n" @@ -2077,15 +2078,15 @@ class TestUnusedVar : public TestFixture { " int i = 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" "{\n" " int i(0);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // if a is undefined then Cppcheck can't determine if "int i(a)" is a // * variable declaration @@ -2094,14 +2095,14 @@ class TestUnusedVar : public TestFixture { "{\n" " int i(a);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " int j = 0;\n" " int i(j);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -2109,7 +2110,7 @@ class TestUnusedVar : public TestFixture { " int & i = j;\n" " x(j);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -2117,7 +2118,7 @@ class TestUnusedVar : public TestFixture { " const int & i = j;\n" " x(j);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:19]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -2125,7 +2126,7 @@ class TestUnusedVar : public TestFixture { " int & i(j);\n" " x(j);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -2133,29 +2134,29 @@ class TestUnusedVar : public TestFixture { " const int & i(j);\n" " x(j);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " int * j = Data;\n" " int * i(j);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " int * j = Data;\n" " const int * i(j);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " bool i = false;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2163,8 +2164,8 @@ class TestUnusedVar : public TestFixture { " bool i = true;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2172,14 +2173,14 @@ class TestUnusedVar : public TestFixture { " char *i;\n" " i = fgets();\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:7]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // undefined variables are not reported because they may be classes with constructors functionVariableUsage("undefined foo()\n" "{\n" " undefined i = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (information) --check-library: Provide configuration for undefined\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:17]: (information) --check-library: Provide configuration for undefined [checkLibraryCheckType]\n", errout_str()); functionVariableUsage("undefined foo()\n" "{\n" @@ -2187,8 +2188,8 @@ class TestUnusedVar : public TestFixture { "}\n", dinit(FunctionVariableUsageOptions, $.cpp = false)); ASSERT_EQUALS( - "[test.c:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.c:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.c:3:17]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.c:3:15]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2196,8 +2197,8 @@ class TestUnusedVar : public TestFixture { " int i = undefined;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2205,8 +2206,8 @@ class TestUnusedVar : public TestFixture { " int * i = Data;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2214,8 +2215,8 @@ class TestUnusedVar : public TestFixture { " void * i = Data;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:14]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2223,8 +2224,8 @@ class TestUnusedVar : public TestFixture { " const void * i = Data;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:20]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2232,8 +2233,8 @@ class TestUnusedVar : public TestFixture { " struct S * i = DATA;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:16]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2241,29 +2242,29 @@ class TestUnusedVar : public TestFixture { " const struct S * i = DATA;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:24]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:22]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" "{\n" " struct S & i = j;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " const struct S & i = j;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:24]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " undefined * i = X;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:19]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:17]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2272,35 +2273,35 @@ class TestUnusedVar : public TestFixture { " int j = i;\n" "}"); ASSERT_EQUALS( - "[test.cpp:4]: (style) Variable 'j' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'j' is assigned a value that is never used.\n", // duplicate + "[test.cpp:4:11]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:9]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" "{\n" " int i[10] = { 0 };\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:15]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo(int n)\n" "{\n" " int i[n] = { 0 };\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:14]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " char i[10] = \"123456789\";\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:16]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " char *i = \"123456789\";\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2308,8 +2309,8 @@ class TestUnusedVar : public TestFixture { " int i = 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -2331,8 +2332,8 @@ class TestUnusedVar : public TestFixture { " d = code;\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'd' is assigned a value that is never used.\n" - "[test.cpp:7]: (style) Variable 'd' is assigned a value that is never used.\n", + ASSERT_EQUALS("[test.cpp:3:24]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:7:11]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2392,8 +2393,8 @@ class TestUnusedVar : public TestFixture { " d += code;\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'd' is assigned a value that is never used.\n" - "[test.cpp:7]: (style) Variable 'd' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:18]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:7:11]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -2452,8 +2453,8 @@ class TestUnusedVar : public TestFixture { " d += code;\n" " } while(code < 20);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'd' is assigned a value that is never used.\n" - "[test.cpp:7]: (style) Variable 'd' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:18]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:7:11]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -2545,8 +2546,8 @@ class TestUnusedVar : public TestFixture { " int i = 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:2:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); // extracttests.enable } @@ -2559,14 +2560,14 @@ class TestUnusedVar : public TestFixture { " int i;\n" " return i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); functionVariableUsage("bool foo()\n" "{\n" " bool i;\n" " return i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); // undefined variables are not reported because they may be classes with constructors functionVariableUsage("undefined foo()\n" @@ -2582,42 +2583,42 @@ class TestUnusedVar : public TestFixture { " return i;\n" "}\n", dinit(FunctionVariableUsageOptions, $.cpp = false)); - ASSERT_EQUALS("[test.c:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.c:3:15]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); functionVariableUsage("undefined *foo()\n" "{\n" " undefined * i;\n" " return i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:17]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); functionVariableUsage("int *foo()\n" "{\n" " int * i;\n" " return i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); functionVariableUsage("const int *foo()\n" "{\n" " const int * i;\n" " return i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:17]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); functionVariableUsage("struct S *foo()\n" "{\n" " struct S * i;\n" " return i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:16]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); functionVariableUsage("const struct S *foo()\n" "{\n" " const struct S * i;\n" " return i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:22]: (style) Variable 'i' is not assigned a value. [unassignedVariable]\n", errout_str()); // assume f() can write a functionVariableUsage("void foo()\n" @@ -2688,7 +2689,7 @@ class TestUnusedVar : public TestFixture { " ;\n" " else i = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar4() { @@ -2722,7 +2723,7 @@ class TestUnusedVar : public TestFixture { " for (int i=0;i<10;++i)\n" " b[i] = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'b[i]' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:14]: (style) Variable 'b[i]' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo() {\n" " int a = 0;\n" @@ -2730,7 +2731,7 @@ class TestUnusedVar : public TestFixture { " for (int i=0;i<10;++i)\n" " b[i] = ++a;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'b[i]' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:14]: (style) Variable 'b[i]' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo() {\n" " int b[10];\n" @@ -2743,7 +2744,7 @@ class TestUnusedVar : public TestFixture { " int b;\n" " *(&b) = 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable '*(&b)' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable '*(&b)' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar8() { @@ -2751,25 +2752,25 @@ class TestUnusedVar : public TestFixture { "{\n" " int i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " int i[2];\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " void * i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:12]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " const void * i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:18]: (style) Unused variable: i [unusedVariable]\n", errout_str()); // extracttests.start: struct A {int x;}; @@ -2777,69 +2778,69 @@ class TestUnusedVar : public TestFixture { "{\n" " A * i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " struct A * i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:16]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " const struct A * i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:22]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " int * i[2];\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", "", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", "", errout_str()); functionVariableUsage("void foo()\n" "{\n" " const int * i[2];\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", "", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", "", errout_str()); functionVariableUsage("void foo()\n" "{\n" " void * i[2];\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", "", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", "", errout_str()); functionVariableUsage("void foo()\n" "{\n" " const void * i[2];\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", "", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", "", errout_str()); functionVariableUsage("void foo()\n" "{\n" " struct A * i[2];\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", "", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", "", errout_str()); functionVariableUsage("void foo()\n" "{\n" " const struct A * i[2];\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", "", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", "", errout_str()); functionVariableUsage("void foo(int n)\n" "{\n" " int i[n];\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " int i = 0;\n" " int &j = i;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'j' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", + ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2847,8 +2848,8 @@ class TestUnusedVar : public TestFixture { " int i;\n" " int &j = i;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'j' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -2934,7 +2935,7 @@ class TestUnusedVar : public TestFixture { " a[0] = 0;\n" " x = a[0];\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:7]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // extracttests.start: int f(); functionVariableUsage("void foo()\n" @@ -2942,9 +2943,9 @@ class TestUnusedVar : public TestFixture { " int a, b, c;\n" " a = b = c = f();\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'c' is assigned a value that is never used.\n", + ASSERT_EQUALS("[test.cpp:4:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:11]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:15]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("int * foo()\n" @@ -2962,7 +2963,7 @@ class TestUnusedVar : public TestFixture { " for (int i = 0; i < 10; )\n" " a[i++] = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a[i++]' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:16]: (style) Variable 'a[i++]' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar10() { @@ -2975,9 +2976,9 @@ class TestUnusedVar : public TestFixture { " int i;\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n" - "[test.cpp:5]: (style) Unused variable: i\n" - "[test.cpp:7]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:5:13]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:7:13]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo(int x)\n" "{\n" @@ -2987,9 +2988,9 @@ class TestUnusedVar : public TestFixture { " else\n" " int i;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n" - "[test.cpp:5]: (style) Unused variable: i\n" - "[test.cpp:7]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:5:13]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:7:13]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo(int x)\n" "{\n" @@ -3000,10 +3001,10 @@ class TestUnusedVar : public TestFixture { " int i = 0;\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:7]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Unused variable: i\n" - "[test.cpp:5]: (style) Unused variable: i\n" - "[test.cpp:7]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:7:15]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:5:13]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:7:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo(int x)\n" @@ -3016,9 +3017,9 @@ class TestUnusedVar : public TestFixture { " }\n" " i = 1;\n" "}"); - ASSERT_EQUALS("[test.cpp:9]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:5]: (style) Unused variable: i\n" - "[test.cpp:7]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9:7]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:5:13]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:7:13]: (style) Unused variable: i [unusedVariable]\n", errout_str()); } void localvar11() { @@ -3032,8 +3033,8 @@ class TestUnusedVar : public TestFixture { " }\n" " x = a;\n" // redundant assignment "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:9]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:11]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:9:7]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // The variable 'a' is initialized. But the initialized value is // never used. It is only initialized for security reasons. @@ -3048,7 +3049,7 @@ class TestUnusedVar : public TestFixture { " return;\n" " x = a;\n" "}"); - ASSERT_EQUALS("[test.cpp:10]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:10:7]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar12() { @@ -3059,12 +3060,12 @@ class TestUnusedVar : public TestFixture { " a = b = c = d = e = f = 15;\n" "}"); ASSERT_EQUALS( - "[test.cpp:4]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'c' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'd' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'e' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'f' is assigned a value that is never used.\n", + "[test.cpp:4:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:11]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:15]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:19]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:23]: (style) Variable 'e' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:27]: (style) Variable 'f' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -3075,12 +3076,12 @@ class TestUnusedVar : public TestFixture { "}"); TODO_ASSERT_EQUALS( - "[test.cpp:4]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'c' is assigned a value that is never used.\n", + "[test.cpp:4:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", - "[test.cpp:4]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n", + "[test.cpp:4:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:11]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -3091,7 +3092,7 @@ class TestUnusedVar : public TestFixture { " int x;\n" " x = obj->ySize / 8;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:7]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar14() { @@ -3100,7 +3101,7 @@ class TestUnusedVar : public TestFixture { "{\n" " int a[10];\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n", errout_str()); } void localvar15() { @@ -3193,7 +3194,7 @@ class TestUnusedVar : public TestFixture { " data->info = k;\n" " line_start = ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:10]: (style) Variable 'line_start' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:10:16]: (style) Variable 'line_start' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // extracttests.enable } @@ -3211,8 +3212,8 @@ class TestUnusedVar : public TestFixture { " int c;\n" " c = *(a);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'c' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 'a' is not assigned a value.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:7]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:9]: (style) Variable 'a' is not assigned a value. [unassignedVariable]\n", errout_str()); } void localvar20() { // ticket #1799 @@ -3253,7 +3254,7 @@ class TestUnusedVar : public TestFixture { " a = b[c] = 0;\n" " return a;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'b[c]' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:14]: (style) Variable 'b[c]' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar24() { // ticket #1803 @@ -3292,7 +3293,7 @@ class TestUnusedVar : public TestFixture { " int param = 1;\n" " ptr->param = param++;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'param' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:23]: (style) Variable 'param' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar28() { // ticket #2205 @@ -3343,13 +3344,13 @@ class TestUnusedVar : public TestFixture { " C c;\n" // possibly some stream class " if (c >>= x) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (information) --check-library: Provide configuration for C\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (information) --check-library: Provide configuration for C [checkLibraryCheckType]\n", errout_str()); functionVariableUsage("void f(int x) {\n" " C c;\n" " if (c >>= x) {}\n" "}", dinit(FunctionVariableUsageOptions, $.cpp = false)); - ASSERT_EQUALS("[test.c:3]: (style) Variable 'c' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.c:3:11]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" " int x, y;\n" @@ -3596,7 +3597,7 @@ class TestUnusedVar : public TestFixture { functionVariableUsage("void f() {\n" " auto&& g = std::lock_guard { mutex };\n" "}\n"); - TODO_ASSERT_EQUALS("", "[test.cpp:2]: (style) Variable 'g' is assigned a value that is never used.\n", errout_str()); + TODO_ASSERT_EQUALS("", "[test.cpp:2:14]: (style) Variable 'g' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" " auto a = RAII();\n" @@ -3621,7 +3622,7 @@ class TestUnusedVar : public TestFixture { " int (SfxUndoManager::*retrieveCount)(bool) const\n" " = (flag) ? &SfxUndoManager::foo : &SfxUndoManager::bar;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'retrieveCount' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:9]: (style) Variable 'retrieveCount' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // extracttests.enable } @@ -3651,8 +3652,8 @@ class TestUnusedVar : public TestFixture { " const std::string x = Bar();\n" // <- warning "}"); ASSERT_EQUALS( - "[test.cpp:16]: (style) Variable 'x' is assigned a value that is never used.\n" - "[test.cpp:16]: (style) Variable 'x' is assigned a value that is never used.\n", // duplicate + "[test.cpp:16:25]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:16:23]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); } @@ -3685,13 +3686,13 @@ class TestUnusedVar : public TestFixture { " const Token *tok = nameToken();\n" " tok = tok->next();\n" // read+write "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'tok' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:7]: (style) Variable 'tok' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo() {\n" " int x = 4;\n" " x = 15 + x;\n" // read+write "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:5]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar52() { @@ -3713,7 +3714,7 @@ class TestUnusedVar : public TestFixture { " }\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:10]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo(int a, int loop) {\n" " bool x = false;\n" @@ -3749,8 +3750,8 @@ class TestUnusedVar : public TestFixture { " }\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' is assigned a value that is never used.\n" - "[test.cpp:6]: (style) Variable 'x' is assigned a value that is never used.\n", + ASSERT_EQUALS("[test.cpp:2:11]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:6:15]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -3769,7 +3770,7 @@ class TestUnusedVar : public TestFixture { " int x = 0;\n" " x++;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:6]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar58() { // #9901 - increment false positive @@ -3783,7 +3784,7 @@ class TestUnusedVar : public TestFixture { " int x = 0;\n" " if (x-- > 0) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar59() { // #9737 @@ -3817,27 +3818,27 @@ class TestUnusedVar : public TestFixture { " g(var);\n" " var = 2;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'var' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:9]: (style) Variable 'var' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar62() { functionVariableUsage("void f() {\n" // #10824 " S* s = nullptr;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:8]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" " S* s{};\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:9]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("int f() {\n" " int i = 0, j = 1;\n" " return i;\n" "}\n"); ASSERT_EQUALS( - "[test.cpp:2]: (style) Variable 'j' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 'j' is assigned a value that is never used.\n", // duplicate + "[test.cpp:2:18]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:16]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("int f() {\n" @@ -3845,8 +3846,8 @@ class TestUnusedVar : public TestFixture { " return j;\n" "}\n"); ASSERT_EQUALS( - "[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used.\n", // duplicate + "[test.cpp:2:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void f() {\n" // #10846 @@ -3861,7 +3862,7 @@ class TestUnusedVar : public TestFixture { " goto y;\n" " y:return;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:7]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar64() { // #9997 @@ -3880,9 +3881,9 @@ class TestUnusedVar : public TestFixture { " else\n" " q = s;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:10]: (style) Variable 'p' is assigned a value that is never used.\n" - "[test.cpp:11]: (style) Variable 'q' is assigned a value that is never used.\n" - "[test.cpp:14]: (style) Variable 'q' is assigned a value that is never used.\n", + ASSERT_EQUALS("[test.cpp:10:11]: (style) Variable 'p' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:11:11]: (style) Variable 'q' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:14:11]: (style) Variable 'q' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -3895,14 +3896,14 @@ class TestUnusedVar : public TestFixture { " continue;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 't' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:18]: (style) Variable 't' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" // #10006 " std::string s = \"\";\n" " try {}\n" " catch (...) {}\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:17]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvar66() { // #11143 @@ -3976,7 +3977,7 @@ class TestUnusedVar : public TestFixture { " int x;\n" " while (c) { x=10; }\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:16]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void dostuff(int x);\n" "void fun(int y, int c) {\n" @@ -3986,7 +3987,7 @@ class TestUnusedVar : public TestFixture { " if (y) { x=10; break; }\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:15]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void dostuff(int &x);\n" "void fun() {\n" @@ -3996,7 +3997,7 @@ class TestUnusedVar : public TestFixture { " if (y) { x=10; break; }\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6:15]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void fun() {\n" " int x = 0;\n" @@ -4027,8 +4028,8 @@ class TestUnusedVar : public TestFixture { " for (i = 0U; i < 2U; i++)\n" " sum += 123;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'sum' is assigned a value that is never used.\n" - "[test.cpp:5]: (style) Variable 'sum' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:13]: (style) Variable 'sum' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:5:13]: (style) Variable 'sum' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f(int c) {\n" // #7908 " int b = 0;\n" @@ -4040,7 +4041,7 @@ class TestUnusedVar : public TestFixture { " }\n" " h(b);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:7]: (style) Variable 'a' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7:15]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f(const std::vector& v) {\n" " while (g()) {\n" @@ -4092,9 +4093,9 @@ class TestUnusedVar : public TestFixture { " int a;\n" " int *b = &a;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Unused variable: a\n" - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n" + "[test.cpp:4:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -4102,9 +4103,9 @@ class TestUnusedVar : public TestFixture { " int a[10];\n" " int *b = a;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Unused variable: a\n" - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n" + "[test.cpp:4:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -4113,7 +4114,7 @@ class TestUnusedVar : public TestFixture { " int *b = &a;\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4123,7 +4124,7 @@ class TestUnusedVar : public TestFixture { " char *b = (char *)&a;\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4133,7 +4134,7 @@ class TestUnusedVar : public TestFixture { " char *b = (char *)(&a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4143,7 +4144,7 @@ class TestUnusedVar : public TestFixture { " const char *b = (const char *)&a;\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4153,7 +4154,7 @@ class TestUnusedVar : public TestFixture { " const char *b = (const char *)(&a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4163,7 +4164,7 @@ class TestUnusedVar : public TestFixture { " char *b = static_cast(&a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4173,7 +4174,7 @@ class TestUnusedVar : public TestFixture { " const char *b = static_cast(&a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4184,8 +4185,8 @@ class TestUnusedVar : public TestFixture { " int *b = &a;\n" "}"); ASSERT_EQUALS( - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'b' is assigned a value that is never used.\n", // duplicate + "[test.cpp:4:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); // a is not a local variable and b is aliased to it @@ -4194,8 +4195,8 @@ class TestUnusedVar : public TestFixture { " int *b = &a;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'b' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); // a is not a local variable and b is aliased to it @@ -4208,8 +4209,8 @@ class TestUnusedVar : public TestFixture { " }\n" "};"); ASSERT_EQUALS( - "[test.cpp:6]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:6]: (style) Variable 'b' is assigned a value that is never used.\n", // duplicate + "[test.cpp:6:16]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:6:14]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("int a;\n" @@ -4244,7 +4245,7 @@ class TestUnusedVar : public TestFixture { " int *b = a;\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4254,7 +4255,7 @@ class TestUnusedVar : public TestFixture { " char *b = (char *)a;\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4264,7 +4265,7 @@ class TestUnusedVar : public TestFixture { " char *b = (char *)(a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4274,7 +4275,7 @@ class TestUnusedVar : public TestFixture { " const char *b = (const char *)a;\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4284,7 +4285,7 @@ class TestUnusedVar : public TestFixture { " const char *b = (const char *)(a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4294,7 +4295,7 @@ class TestUnusedVar : public TestFixture { " char *b = static_cast(a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4304,7 +4305,7 @@ class TestUnusedVar : public TestFixture { " const char *b = static_cast(a);\n" " *b = 0;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -4417,9 +4418,9 @@ class TestUnusedVar : public TestFixture { " int *d = b;\n" " *d = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'c' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Unused variable: a\n" - "[test.cpp:5]: (style) Variable 'c' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:5:12]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n" + "[test.cpp:5:10]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -4430,8 +4431,7 @@ class TestUnusedVar : public TestFixture { " c = b;\n" " *c = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: a\n" - "", + ASSERT_EQUALS("[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -4465,9 +4465,9 @@ class TestUnusedVar : public TestFixture { " int * c = b - 10;\n" "}"); TODO_ASSERT_EQUALS( - "[test.cpp:4]: (style) Variable 'a' is assigned a value that is never used.\n", - "[test.cpp:5]: (style) Variable 'c' is assigned a value that is never used.\n" - "[test.cpp:5]: (style) Variable 'c' is assigned a value that is never used.\n", // duplicate + "[test.cpp:4:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", + "[test.cpp:5:13]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:5:11]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo()\n" @@ -4523,9 +4523,9 @@ class TestUnusedVar : public TestFixture { " char a[100];\n" " struct S * s = (struct S *)a;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Unused variable: a\n" - "[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:5:18]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" + "[test.cpp:5:16]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("struct S { char c[100]; };\n" @@ -4534,9 +4534,9 @@ class TestUnusedVar : public TestFixture { " char a[100];\n" " const struct S * s = (const struct S *)a;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Unused variable: a\n" - "[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:5:24]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" + "[test.cpp:5:22]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("struct S { char c[100]; };\n" @@ -4545,9 +4545,9 @@ class TestUnusedVar : public TestFixture { " char a[100];\n" " struct S * s = static_cast(a);\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Unused variable: a\n" - "[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:5:18]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" + "[test.cpp:5:16]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("struct S { char c[100]; };\n" @@ -4556,9 +4556,9 @@ class TestUnusedVar : public TestFixture { " char a[100];\n" " const struct S * s = static_cast(a);\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Unused variable: a\n" - "[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:5:24]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" + "[test.cpp:5:22]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("int a[10];\n" @@ -4572,7 +4572,7 @@ class TestUnusedVar : public TestFixture { " d = c;\n" " *d = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Unused variable: b\n", + ASSERT_EQUALS("[test.cpp:4:9]: (style) Unused variable: b [unusedVariable]\n", errout_str()); functionVariableUsage("int a[10];\n" @@ -4618,8 +4618,8 @@ class TestUnusedVar : public TestFixture { " int * a = &ab.a;\n" "}"); ASSERT_EQUALS( - "[test.cpp:4]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'a' is assigned a value that is never used.\n", // duplicate + "[test.cpp:4:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:11]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("struct AB { int a; int b; } ab;\n" @@ -4636,9 +4636,9 @@ class TestUnusedVar : public TestFixture { " struct AB ab;\n" " int * a = &ab.a;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'ab' is not assigned a value.\n" - "[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:15]: (style) Variable 'ab' is not assigned a value. [unassignedVariable]\n" + "[test.cpp:5:11]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("struct AB { int a; int b; };\n" @@ -4745,7 +4745,7 @@ class TestUnusedVar : public TestFixture { " srcdata = vdata;\n" " b(srcdata);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: buf\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Unused variable: buf [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -4817,7 +4817,7 @@ class TestUnusedVar : public TestFixture { " srcdata = vdata;\n" " b(srcdata);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: buf\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Unused variable: buf [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -4830,7 +4830,7 @@ class TestUnusedVar : public TestFixture { " srcdata = buf;\n" " b(srcdata);\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Unused variable: vdata\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:10]: (style) Unused variable: vdata [unusedVariable]\n", errout_str()); } void localvaralias7() { // ticket 1732 @@ -4925,9 +4925,9 @@ class TestUnusedVar : public TestFixture { " pb = b4;\n" " b(pb);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: b1\n" - "[test.cpp:4]: (style) Unused variable: b2\n" - "[test.cpp:5]: (style) Unused variable: b3\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Unused variable: b1 [unusedVariable]\n" + "[test.cpp:4:10]: (style) Unused variable: b2 [unusedVariable]\n" + "[test.cpp:5:10]: (style) Unused variable: b3 [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -5024,9 +5024,9 @@ class TestUnusedVar : public TestFixture { " pb = b4;\n" " b(pb);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: b1\n" - "[test.cpp:4]: (style) Unused variable: b2\n" - "[test.cpp:5]: (style) Unused variable: b3\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10]: (style) Unused variable: b1 [unusedVariable]\n" + "[test.cpp:4:10]: (style) Unused variable: b2 [unusedVariable]\n" + "[test.cpp:5:10]: (style) Unused variable: b3 [unusedVariable]\n", errout_str()); } void localvaralias9() { // ticket 1996 @@ -5095,7 +5095,7 @@ class TestUnusedVar : public TestFixture { " char a[4], *p=a;\n" " p = dostuff(p);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'p' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:7]: (style) Variable 'p' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("char * dostuff(char *&p);\n" "void f() {\n" @@ -5179,9 +5179,9 @@ class TestUnusedVar : public TestFixture { " const auto&& c = g();\n" " auto&& d = c;\n" "}\n"); - TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:7]: (style) Variable 'd' is assigned a value that is never used.\n", - "[test.cpp:7]: (style) Variable 'd' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:5:20]: (style) Variable 'b' is assigned a value that is never used.\n" + "[test.cpp:7:14]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n", + "[test.cpp:7:14]: (style) Variable 'd' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -5194,7 +5194,7 @@ class TestUnusedVar : public TestFixture { " b = false;\n" " if (*p) {}\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'j' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:10]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvaralias22() { // #11139 @@ -5254,8 +5254,8 @@ class TestUnusedVar : public TestFixture { " struct ABC abc = { 1, 2, 3 };\n" "}"); ASSERT_EQUALS( - "[test.cpp:4]: (style) Variable 'abc' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'abc' is assigned a value that is never used.\n", // duplicate + "[test.cpp:4:20]: (style) Variable 'abc' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:16]: (style) Variable 'abc' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); } @@ -5291,7 +5291,7 @@ class TestUnusedVar : public TestFixture { " return 0;\n" "}\n", dinit(FunctionVariableUsageOptions, $.cpp = false)); - ASSERT_EQUALS("[test.c:2]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.c:2:7]: (style) Unused variable: a [unusedVariable]\n", errout_str()); // extracttests.enable functionVariableUsage("struct A { int i; };\n" @@ -5307,7 +5307,7 @@ class TestUnusedVar : public TestFixture { " a.i = 0;\n" " return 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'a.i' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:9]: (style) Variable 'a.i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("struct A { int i; };\n" "int foo() {\n" @@ -5315,8 +5315,8 @@ class TestUnusedVar : public TestFixture { " return 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'a' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:9]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); // extracttests.disable @@ -5326,8 +5326,8 @@ class TestUnusedVar : public TestFixture { " return 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'a' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:9]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); // extracttests.enable @@ -5343,14 +5343,14 @@ class TestUnusedVar : public TestFixture { " A a;\n" " return 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:7]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("class A { int i; };\n" "int foo() {\n" " A a;\n" " return 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:7]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("class A { int i; public: A(); { } };\n" "int foo() {\n" @@ -5379,7 +5379,7 @@ class TestUnusedVar : public TestFixture { " A a;\n" " return 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:7]: (style) Unused variable: a [unusedVariable]\n", errout_str()); } void localvarStruct6() { @@ -5418,7 +5418,7 @@ class TestUnusedVar : public TestFixture { " aatt.a = 123;\n" " dostuff(p);\n" "}"); - ASSERT_EQUALS("[test.cpp:9]: (style) Variable 'aatt.a' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9:10]: (style) Variable 'aatt.a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("struct AB {\n" " int a;\n" @@ -5471,7 +5471,7 @@ class TestUnusedVar : public TestFixture { " s.x = 3;\n" " memcpy (&s, &s2, sizeof (S));\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 's.x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:9]: (style) Variable 's.x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvarStruct11() { // #10095 @@ -5532,7 +5532,7 @@ class TestUnusedVar : public TestFixture { " struct X x[10];\n" " x[0].a = 5;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'x[0].a' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:12]: (style) Variable 'x[0].a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvarUnion1() { @@ -5594,7 +5594,7 @@ class TestUnusedVar : public TestFixture { " }\n" " return false;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'first' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:15]: (style) Variable 'first' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvarIfElse() { @@ -5617,8 +5617,8 @@ class TestUnusedVar : public TestFixture { " return 1;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (style) Variable 'y' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'y' is assigned a value that is never used.\n", // duplicate + "[test.cpp:3:15]: (style) Variable 'y' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:13]: (style) Variable 'y' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("int foo(int x)\n" @@ -5678,8 +5678,8 @@ class TestUnusedVar : public TestFixture { " int b = 2;\n" " a |= b;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:5]: (style) Variable 'a' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:5:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo() {\n" " int a = 1;\n" @@ -5716,14 +5716,14 @@ class TestUnusedVar : public TestFixture { " int *a; a = b;\n" " fred += a;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (information) --check-library: Provide configuration for Fred\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:8]: (information) --check-library: Provide configuration for Fred [checkLibraryCheckType]\n", errout_str()); // extracttests.enable functionVariableUsage("void f(std::pair x) {\n" " std::pair fred;\n" // class with library configuration " fred = x;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'fred' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:8]: (style) Variable 'fred' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvarFor() { @@ -5871,24 +5871,24 @@ class TestUnusedVar : public TestFixture { " static std::string s;\n" " static const std::string cs;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n" - "[test.cpp:4]: (style) Unused variable: ci\n" - "[test.cpp:5]: (style) Unused variable: s\n" - "[test.cpp:6]: (style) Unused variable: cs\n", + ASSERT_EQUALS("[test.cpp:3:16]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:4:22]: (style) Unused variable: ci [unusedVariable]\n" + "[test.cpp:5:24]: (style) Unused variable: s [unusedVariable]\n" + "[test.cpp:6:30]: (style) Unused variable: cs [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " static int i = 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", + ASSERT_EQUALS("[test.cpp:3:16]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " static int i(0);\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'i' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -5897,7 +5897,7 @@ class TestUnusedVar : public TestFixture { " static int j = 0;\n" " static int i(j);\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'i' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:4:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -5909,7 +5909,7 @@ class TestUnusedVar : public TestFixture { " b[1] = 1;\n" " return x ? a : c;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'b' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:6:16]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); @@ -5970,14 +5970,14 @@ class TestUnusedVar : public TestFixture { " void* ptr = malloc(16);\n" " free(ptr);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:17]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " char* ptr = new char[16];\n" " delete[] ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); // extracttests.disable @@ -5986,14 +5986,14 @@ class TestUnusedVar : public TestFixture { " char* ptr = new ( nothrow ) char[16];\n" " delete[] ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" " char* ptr = new ( std::nothrow ) char[16];\n" " delete[] ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); // extracttests.enable @@ -6002,7 +6002,7 @@ class TestUnusedVar : public TestFixture { " char* ptr = new char;\n" " delete ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -6035,7 +6035,7 @@ class TestUnusedVar : public TestFixture { " std::cout << \"test\" << std::endl;\n" " delete fred;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'fred' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Variable 'fred' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("struct Fred { int a; Fred() : a(0) {} };\n" "void foo()\n" @@ -6044,7 +6044,7 @@ class TestUnusedVar : public TestFixture { " std::cout << \"test\" << std::endl;\n" " delete fred;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'fred' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Variable 'fred' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("void foo()\n" "{\n" @@ -6052,7 +6052,7 @@ class TestUnusedVar : public TestFixture { " std::cout << \"test\" << std::endl;\n" " free(fred);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'fred' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:18]: (style) Variable 'fred' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -6070,7 +6070,7 @@ class TestUnusedVar : public TestFixture { " Fred* ptr = (Fred*)malloc(sizeof(Fred));\n" " free(ptr);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:31]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("struct Fred { int i; };\n" "void foo()\n" @@ -6087,7 +6087,7 @@ class TestUnusedVar : public TestFixture { " struct Fred* ptr = (Fred*)malloc(sizeof(Fred));\n" " free(ptr);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:38]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("struct Fred { int i; };\n" "void foo()\n" @@ -6104,7 +6104,7 @@ class TestUnusedVar : public TestFixture { " Fred* ptr = new Fred();\n" " delete ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); // extracttests.disable @@ -6114,7 +6114,7 @@ class TestUnusedVar : public TestFixture { " Fred* ptr = new (nothrow ) Fred();\n" " delete ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("struct Fred { int i; };\n" "void foo()\n" @@ -6122,7 +6122,7 @@ class TestUnusedVar : public TestFixture { " Fred* ptr = new (std::nothrow) Fred();\n" " delete ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); // extracttests.enable @@ -6141,7 +6141,7 @@ class TestUnusedVar : public TestFixture { " struct Fred* ptr = new Fred();\n" " delete ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:18]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("struct Fred { int i; };\n" "void foo()\n" @@ -6158,7 +6158,7 @@ class TestUnusedVar : public TestFixture { " Fred* ptr = (Fred*)malloc(sizeof(Fred));\n" " free(ptr);\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:31]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("class Fred { public: int i; };\n" "void foo()\n" @@ -6175,7 +6175,7 @@ class TestUnusedVar : public TestFixture { " Fred* ptr = new Fred();\n" " delete ptr;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Variable 'ptr' is allocated memory that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4:11]: (style) Variable 'ptr' is allocated memory that is never used. [unusedAllocatedMemory]\n", errout_str()); functionVariableUsage("class Fred { public: int i; };\n" "void foo()\n" @@ -6258,7 +6258,7 @@ class TestUnusedVar : public TestFixture { functionVariableUsage("void f() {\n" // #11872 " char v[1][2];\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: v\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:10]: (style) Unused variable: v [unusedVariable]\n", errout_str()); } void localvararray6() { @@ -6276,28 +6276,28 @@ class TestUnusedVar : public TestFixture { functionVariableUsage("void foo() {\n" " std::string s;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: s\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:17]: (style) Unused variable: s [unusedVariable]\n", errout_str()); functionVariableUsage("void foo() {\n" " std::string s;\n" " s = \"foo\";\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 's' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:7]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo() {\n" " std::string s = \"foo\";\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", // duplicate + "[test.cpp:2:19]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:17]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void foo() {\n" // #8901 " const std::string s = \"foo\";\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", // duplicate + "[test.cpp:2:25]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:23]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("std::string foo() {\n" @@ -6315,12 +6315,12 @@ class TestUnusedVar : public TestFixture { functionVariableUsage("void f() {\n" " std::string s(\"foo\");\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:18]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" " std::string s{ \"foo\" };\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:18]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvarstring2() { // ticket #2929 @@ -6328,8 +6328,8 @@ class TestUnusedVar : public TestFixture { " std::string s;\n" " int i;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: s\n" - "[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:17]: (style) Unused variable: s [unusedVariable]\n" + "[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n", errout_str()); } void localvarconst1() { @@ -6337,8 +6337,8 @@ class TestUnusedVar : public TestFixture { " const bool b = true;\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (style) Variable 'b' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 'b' is assigned a value that is never used.\n", // duplicate + "[test.cpp:2:18]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:16]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); } @@ -6467,24 +6467,24 @@ class TestUnusedVar : public TestFixture { " std::string x = foo();\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (style) Variable 'x' is assigned a value that is never used.\n" - "[test.cpp:2]: (style) Variable 'x' is assigned a value that is never used.\n", // duplicate + "[test.cpp:2:19]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:17]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void f() {\n" " std::vector x;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: x\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:22]: (style) Unused variable: x [unusedVariable]\n", errout_str()); functionVariableUsage("void f() {\n" " std::vector x(100);\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:23]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" " std::vector x;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: x\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:26]: (style) Unused variable: x [unusedVariable]\n", errout_str()); functionVariableUsage("void f() {\n" " std::lock_guard lock(mutex_);\n" // Has a side-effect #4385 @@ -6508,12 +6508,12 @@ class TestUnusedVar : public TestFixture { " auto r = std::pair(\"a\", \"b\");\n" " auto s = std::pair{ \"a\", \"b\" };\n" "}\n"); - TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 'r' is assigned a value that is never used.\n" - "[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n", - "[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n", + TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:2:48]: (style) Variable 'p' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4]: (style) Variable 'r' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:5:18]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", + "[test.cpp:2:48]: (style) Variable 'p' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:42]: (style) Variable 'q' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f(std::span s) {\n" // #11545 @@ -6537,7 +6537,7 @@ class TestUnusedVar : public TestFixture { " break;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:23]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localVarClass() { @@ -6550,7 +6550,7 @@ class TestUnusedVar : public TestFixture { "void f() {\n" " C c;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: c\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:7]: (style) Unused variable: c [unusedVariable]\n", errout_str()); functionVariableUsage("class ExampleClass\n" // #10000 "{\n" @@ -6573,7 +6573,7 @@ class TestUnusedVar : public TestFixture { "{\n" " ExampleClass ex(1, 2, 3, 4);\n" "}"); - ASSERT_EQUALS("[test.cpp:20]: (style) Variable 'ex' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:20:19]: (style) Variable 'ex' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("class C { public: C(int); ~C(); };\n" "void f() {\n" @@ -6608,8 +6608,8 @@ class TestUnusedVar : public TestFixture { " auto a = std::make_shared();\n" " auto a2 = std::unique_ptr(new A());\n" "}\n"); - ASSERT_EQUALS("[test.cpp:7]: (style) Variable 'a' is assigned a value that is never used.\n" - "[test.cpp:8]: (style) Variable 'a2' is assigned a value that is never used.\n", // duplicate + ASSERT_EQUALS("[test.cpp:7:12]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:8:13]: (style) Variable 'a2' is assigned a value that is never used. [unreadVariable]\n", // duplicate errout_str()); functionVariableUsage("void g();\n" // #11094 @@ -6716,14 +6716,14 @@ class TestUnusedVar : public TestFixture { " A a4(nullptr);\n" " A a5(NULL);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's1' is assigned a value that is never used.\n" - "[test.cpp:3]: (style) Variable 's2' is assigned a value that is never used.\n" - "[test.cpp:4]: (style) Variable 's4' is assigned a value that is never used.\n" - "[test.cpp:5]: (style) Variable 's5' is assigned a value that is never used.\n" - "[test.cpp:9]: (style) Variable 'a1' is assigned a value that is never used.\n" - "[test.cpp:10]: (style) Variable 'a2' is assigned a value that is never used.\n" - "[test.cpp:11]: (style) Variable 'a4' is assigned a value that is never used.\n" - "[test.cpp:12]: (style) Variable 'a5' is assigned a value that is never used.\n", + ASSERT_EQUALS("[test.cpp:2:19]: (style) Variable 's1' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:3:19]: (style) Variable 's2' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:4:19]: (style) Variable 's4' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:5:19]: (style) Variable 's5' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:9:9]: (style) Variable 'a1' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:10:9]: (style) Variable 'a2' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:11:9]: (style) Variable 'a4' is assigned a value that is never used. [unreadVariable]\n" + "[test.cpp:12:9]: (style) Variable 'a5' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -6742,7 +6742,7 @@ class TestUnusedVar : public TestFixture { " }\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Variable 'X' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5:7]: (style) Variable 'X' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // #4558 functionVariableUsage("int f() {\n" @@ -6787,7 +6787,7 @@ class TestUnusedVar : public TestFixture { " auto lambda = []() {};\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:11]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("void f() {\n" // #9823 " auto cb = []() {\n" @@ -6795,7 +6795,7 @@ class TestUnusedVar : public TestFixture { " };\n" " (void)cb;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:13]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void f() {\n" // #9822 " int i;\n" @@ -6804,8 +6804,8 @@ class TestUnusedVar : public TestFixture { " };\n" " (void)cb;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: i\n" - "[test.cpp:4]: (style) Unused variable: i\n", + ASSERT_EQUALS("[test.cpp:2:9]: (style) Unused variable: i [unusedVariable]\n" + "[test.cpp:4:13]: (style) Unused variable: i [unusedVariable]\n", errout_str()); } @@ -6824,7 +6824,7 @@ class TestUnusedVar : public TestFixture { " int buf[6];\n" " Data data(buf);\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (information) --check-library: Provide configuration for Data\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:14]: (information) --check-library: Provide configuration for Data [checkLibraryCheckType]\n", errout_str()); } void localvarCpp11Initialization() { @@ -6838,12 +6838,12 @@ class TestUnusedVar : public TestFixture { functionVariableUsage("void f() {\n" " std::list>::value_type a{ 1, 2, 3, 4 };\n" "}\n"); - TODO_ASSERT_EQUALS("", "[test.cpp:2]: (information) --check-library: Provide configuration for std::list::value_type\n", errout_str()); + TODO_ASSERT_EQUALS("", "[test.cpp:2:44]: (information) --check-library: Provide configuration for std::list::value_type [checkLibraryCheckType]\n", errout_str()); functionVariableUsage("void f(int* p) {\n" " int* q{ p };\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'q' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:11]: (style) Variable 'q' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void localvarRangeBasedFor() { @@ -6888,7 +6888,7 @@ class TestUnusedVar : public TestFixture { functionVariableUsage("void f() {\n" // #10686 " std::array a;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: a\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:24]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("class A {};\n" // #9471 " namespace std {\n" @@ -6911,7 +6911,7 @@ class TestUnusedVar : public TestFixture { functionVariableUsage("int main() {\n" " void(*funcPtr)(void);\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: funcPtr\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:11]: (style) Unused variable: funcPtr [unusedVariable]\n", errout_str()); functionVariableUsage("int main() {\n" " void(*funcPtr)(void)(x);\n" @@ -6988,7 +6988,7 @@ class TestUnusedVar : public TestFixture { " const int* s[] = { p, p + 1, p + 2 };\n" " a = *(s[a] + b);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'a' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void usingNamespace() { @@ -7036,14 +7036,14 @@ class TestUnusedVar : public TestFixture { " int x = 0;\n" " std::for_each(ints.begin(), ints.end(), [&x](int i){ x += i; });\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'x' is assigned a value that is never used.\n", "", errout_str()); + TODO_ASSERT_EQUALS("[test.cpp:3:5]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", "", errout_str()); functionVariableUsage("int f(const std::vector& v) {\n" " auto it = std::find_if(v.begin(), v.end(), [&](int i) { return i > 0 && i < 7; });\n" " std::unordered_map> exprs;\n" " return *it;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: exprs\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:56]: (style) Unused variable: exprs [unusedVariable]\n", errout_str()); } void namespaces() { // #7557 @@ -7085,7 +7085,7 @@ class TestUnusedVar : public TestFixture { "void fun(std::string s) {\n" " s[10] = 123;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 's[10]' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:8]: (style) Variable 's[10]' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage( "void fun(short data[2]) {\n" @@ -7117,7 +7117,7 @@ class TestUnusedVar : public TestFixture { "}", dinit(FunctionVariableUsageOptions, $.cpp = false) ); - ASSERT_EQUALS("[test.c:1]: (style) Variable 'result.x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.c:1:35]: (style) Variable 'result.x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage( "struct Date { int x; };\n" @@ -7125,7 +7125,7 @@ class TestUnusedVar : public TestFixture { " result.x = 12;\n" "}" ); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'result.x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:35]: (style) Variable 'result.x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } // Unknown struct type @@ -7135,7 +7135,7 @@ class TestUnusedVar : public TestFixture { " foo.x = 123;\n" "}" ); - ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'foo.x' is assigned a value that is never used.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:9]: (style) Variable 'foo.x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } void argumentClass() { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 6eae26c65bc..5522f465356 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -54,6 +54,7 @@ class TestValueFlow : public TestFixture { ""; settings = settingsBuilder(settings).libraryxml(cfg).build(); + mNewTemplate = true; TEST_CASE(valueFlowNumber); TEST_CASE(valueFlowString); TEST_CASE(valueFlowTypeTraits); @@ -76,10 +77,14 @@ class TestValueFlow : public TestFixture { TEST_CASE(valueFlowBeforeConditionAssignIncDec); TEST_CASE(valueFlowBeforeConditionFunctionCall); TEST_CASE(valueFlowBeforeConditionGlobalVariables); + mNewTemplate = false; TEST_CASE(valueFlowBeforeConditionGoto); + mNewTemplate = true; TEST_CASE(valueFlowBeforeConditionIfElse); TEST_CASE(valueFlowBeforeConditionLoop); + mNewTemplate = false; TEST_CASE(valueFlowBeforeConditionMacro); + mNewTemplate = true; TEST_CASE(valueFlowBeforeConditionSizeof); TEST_CASE(valueFlowBeforeConditionSwitch); TEST_CASE(valueFlowBeforeConditionTernaryOp); @@ -165,7 +170,9 @@ class TestValueFlow : public TestFixture { TEST_CASE(valueFlowImpossibleUnknownConstant); TEST_CASE(valueFlowContainerEqual); + mNewTemplate = false; TEST_CASE(valueFlowBailoutIncompleteVar); + mNewTemplate = true; TEST_CASE(performanceIfCount); } @@ -1893,7 +1900,7 @@ class TestValueFlow : public TestFixture { " if (x == 123) {}\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y\n", + "[test.cpp:2:9]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y [valueFlowBailoutIncompleteVar]\n", errout_str()); } @@ -2034,7 +2041,7 @@ class TestValueFlow : public TestFixture { " y = ((x<0) ? x : ((x==2)?3:4));\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y\n", + "[test.cpp:2:5]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y [valueFlowBailoutIncompleteVar]\n", errout_str()); bailout("int f(int x) {\n" @@ -2099,7 +2106,7 @@ class TestValueFlow : public TestFixture { " if (x == 123) {}\n" "}"); ASSERT_EQUALS( - "[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable b\n", + "[test.cpp:2:21]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable b [valueFlowBailoutIncompleteVar]\n", errout_str()); code = "void f(int x, bool abc) {\n" @@ -2148,7 +2155,7 @@ class TestValueFlow : public TestFixture { " };\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:13]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", errout_str()); bailout("void f(int x, int y) {\n" @@ -2158,7 +2165,7 @@ class TestValueFlow : public TestFixture { " };\n" "}"); ASSERT_EQUALS( - "[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n", + "[test.cpp:3:13]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a [valueFlowBailoutIncompleteVar]\n", errout_str()); }