Skip to content

testrunner: aligned multiline template with new default #7534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ void TestFixture::reportErr(const ErrorMessage &msg)
void TestFixture::setTemplateFormat(const std::string &templateFormat)
{
if (templateFormat == "multiline") {
mTemplateFormat = "{file}:{line}:{severity}:{message}";
mTemplateLocation = "{file}:{line}:note:{info}";
mTemplateFormat = "[{file}:{line}:{column}]: {severity}:{inconclusive:inconclusive:} {message} [{id}]";
mTemplateLocation = "[{file}:{line}:{column}]: note: {info}";
}
else if (templateFormat == "simple") { // TODO: use the existing one in CmdLineParser
mTemplateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]";
Expand Down
46 changes: 23 additions & 23 deletions test/testbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3505,9 +3505,9 @@ class TestBufferOverrun : public TestFixture {
" char *p = malloc(10);\n"
" memset(p, 0, 20);\n"
"}");
ASSERT_EQUALS("test.cpp:3:error:Buffer is accessed out of bounds: p\n"
"test.cpp:2:note:Assign p, buffer with size 10\n"
"test.cpp:3:note:Buffer overrun\n", errout_str());
ASSERT_EQUALS("[test.cpp:3:12]: error: Buffer is accessed out of bounds: p [bufferAccessOutOfBounds]\n"
"[test.cpp:2:13]: note: Assign p, buffer with size 10\n"
"[test.cpp:3:12]: note: Buffer overrun\n", errout_str());

settings0 = settingsOld;
}
Expand Down Expand Up @@ -3557,33 +3557,33 @@ class TestBufferOverrun : public TestFixture {
" char a[2];\n"
" f(a);\n"
"}");
ASSERT_EQUALS("test.cpp:4:warning:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
"test.cpp:4:note:Function 'f' is called\n"
"test.cpp:1:note:Declaration of 1st function argument.\n"
"test.cpp:3:note:Passing buffer 'a' to function that is declared here\n"
"test.cpp:4:note:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
ASSERT_EQUALS("[test.cpp:4:5]: warning: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
"[test.cpp:4:5]: note: Function 'f' is called\n"
"[test.cpp:1:13]: note: Declaration of 1st function argument.\n"
"[test.cpp:3:10]: note: Passing buffer 'a' to function that is declared here\n"
"[test.cpp:4:5]: note: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());

check("void f(float a[10][3]);\n"
"void g() {\n"
" float a[2][3];\n"
" f(a);\n"
"}");
ASSERT_EQUALS("test.cpp:4:warning:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
"test.cpp:4:note:Function 'f' is called\n"
"test.cpp:1:note:Declaration of 1st function argument.\n"
"test.cpp:3:note:Passing buffer 'a' to function that is declared here\n"
"test.cpp:4:note:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
ASSERT_EQUALS("[test.cpp:4:5]: warning: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
"[test.cpp:4:5]: note: Function 'f' is called\n"
"[test.cpp:1:14]: note: Declaration of 1st function argument.\n"
"[test.cpp:3:11]: note: Passing buffer 'a' to function that is declared here\n"
"[test.cpp:4:5]: note: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());

check("void f(int a[20]);\n"
"void g() {\n"
" int a[2];\n"
" f(a);\n"
"}");
ASSERT_EQUALS("test.cpp:4:warning:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
"test.cpp:4:note:Function 'f' is called\n"
"test.cpp:1:note:Declaration of 1st function argument.\n"
"test.cpp:3:note:Passing buffer 'a' to function that is declared here\n"
"test.cpp:4:note:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
ASSERT_EQUALS("[test.cpp:4:5]: warning: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
"[test.cpp:4:5]: note: Function 'f' is called\n"
"[test.cpp:1:12]: note: Declaration of 1st function argument.\n"
"[test.cpp:3:9]: note: Passing buffer 'a' to function that is declared here\n"
"[test.cpp:4:5]: note: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());

check("void f(int a[]) {\n"
" switch (2) {\n"
Expand Down Expand Up @@ -3613,11 +3613,11 @@ class TestBufferOverrun : public TestFixture {
" f(b);\n"
" return 0;\n"
"}\n");
ASSERT_EQUALS("test.cpp:8:warning:Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
"test.cpp:8:note:Function 'f' is called\n"
"test.cpp:1:note:Declaration of 1st function argument.\n"
"test.cpp:7:note:Passing buffer 'b' to function that is declared here\n"
"test.cpp:8:note:Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument\n",
ASSERT_EQUALS("[test.cpp:8:5]: warning: Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
"[test.cpp:8:5]: note: Function 'f' is called\n"
"[test.cpp:1:12]: note: Declaration of 1st function argument.\n"
"[test.cpp:7:9]: note: Passing buffer 'b' to function that is declared here\n"
"[test.cpp:8:5]: note: Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument\n",
errout_str());
}

Expand Down
48 changes: 24 additions & 24 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8929,10 +8929,10 @@ class TestClass : public TestFixture {
" static C *mInstance;\n"
" void hello() {}\n"
"};");
ASSERT_EQUALS("test.cpp:3:warning:Calling method 'hello()' when 'this' might be invalid\n"
"test.cpp:5:note:Assuming 'mInstance' is used as 'this'\n"
"test.cpp:3:note:Delete 'mInstance', invalidating 'this'\n"
"test.cpp:3:note:Call method when 'this' is invalid\n",
ASSERT_EQUALS("[test.cpp:3:38]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
"[test.cpp:5:13]: note: Assuming 'mInstance' is used as 'this'\n"
"[test.cpp:3:20]: note: Delete 'mInstance', invalidating 'this'\n"
"[test.cpp:3:38]: note: Call method when 'this' is invalid\n",
errout_str());

checkThisUseAfterFree("class C {\n"
Expand All @@ -8942,10 +8942,10 @@ class TestClass : public TestFixture {
" static std::shared_ptr<C> mInstance;\n"
" void hello() {}\n"
"};");
ASSERT_EQUALS("test.cpp:3:warning:Calling method 'hello()' when 'this' might be invalid\n"
"test.cpp:5:note:Assuming 'mInstance' is used as 'this'\n"
"test.cpp:3:note:Delete 'mInstance', invalidating 'this'\n"
"test.cpp:3:note:Call method when 'this' is invalid\n",
ASSERT_EQUALS("[test.cpp:3:39]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
"[test.cpp:5:29]: note: Assuming 'mInstance' is used as 'this'\n"
"[test.cpp:3:20]: note: Delete 'mInstance', invalidating 'this'\n"
"[test.cpp:3:39]: note: Call method when 'this' is invalid\n",
errout_str());

checkThisUseAfterFree("class C {\n"
Expand All @@ -8956,10 +8956,10 @@ class TestClass : public TestFixture {
" void hello();\n"
" void reset() { mInstance.reset(); }\n"
"};");
ASSERT_EQUALS("test.cpp:3:warning:Calling method 'hello()' when 'this' might be invalid\n"
"test.cpp:5:note:Assuming 'mInstance' is used as 'this'\n"
"test.cpp:7:note:Delete 'mInstance', invalidating 'this'\n"
"test.cpp:3:note:Call method when 'this' is invalid\n",
ASSERT_EQUALS("[test.cpp:3:29]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
"[test.cpp:5:29]: note: Assuming 'mInstance' is used as 'this'\n"
"[test.cpp:7:18]: note: Delete 'mInstance', invalidating 'this'\n"
"[test.cpp:3:29]: note: Call method when 'this' is invalid\n",
errout_str());

// Use member..
Expand All @@ -8970,10 +8970,10 @@ class TestClass : public TestFixture {
" static C *self;\n"
" int x;\n"
"};");
ASSERT_EQUALS("test.cpp:3:warning:Using member 'x' when 'this' might be invalid\n"
"test.cpp:5:note:Assuming 'self' is used as 'this'\n"
"test.cpp:3:note:Delete 'self', invalidating 'this'\n"
"test.cpp:3:note:Call method when 'this' is invalid\n",
ASSERT_EQUALS("[test.cpp:3:33]: warning: Using member 'x' when 'this' might be invalid [thisUseAfterFree]\n"
"[test.cpp:5:13]: note: Assuming 'self' is used as 'this'\n"
"[test.cpp:3:20]: note: Delete 'self', invalidating 'this'\n"
"[test.cpp:3:33]: note: Call method when 'this' is invalid\n",
errout_str());

checkThisUseAfterFree("class C {\n"
Expand All @@ -8983,10 +8983,10 @@ class TestClass : public TestFixture {
" static C *self;\n"
" std::map<int,int> x;\n"
"};");
ASSERT_EQUALS("test.cpp:3:warning:Using member 'x' when 'this' might be invalid\n"
"test.cpp:5:note:Assuming 'self' is used as 'this'\n"
"test.cpp:3:note:Delete 'self', invalidating 'this'\n"
"test.cpp:3:note:Call method when 'this' is invalid\n",
ASSERT_EQUALS("[test.cpp:3:33]: warning: Using member 'x' when 'this' might be invalid [thisUseAfterFree]\n"
"[test.cpp:5:13]: note: Assuming 'self' is used as 'this'\n"
"[test.cpp:3:20]: note: Delete 'self', invalidating 'this'\n"
"[test.cpp:3:33]: note: Call method when 'this' is invalid\n",
errout_str());

// Assign 'shared_from_this()' to non-static smart pointer
Expand All @@ -8998,10 +8998,10 @@ class TestClass : public TestFixture {
" std::shared_ptr<C> mInstance;\n"
" void hello() {}\n"
"};");
ASSERT_EQUALS("test.cpp:4:warning:Calling method 'hello()' when 'this' might be invalid\n"
"test.cpp:6:note:Assuming 'mInstance' is used as 'this'\n"
"test.cpp:4:note:Delete 'mInstance', invalidating 'this'\n"
"test.cpp:4:note:Call method when 'this' is invalid\n",
ASSERT_EQUALS("[test.cpp:4:39]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
"[test.cpp:6:22]: note: Assuming 'mInstance' is used as 'this'\n"
"[test.cpp:4:20]: note: Delete 'mInstance', invalidating 'this'\n"
"[test.cpp:4:39]: note: Call method when 'this' is invalid\n",
errout_str());

// Avoid FP..
Expand Down
56 changes: 28 additions & 28 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,19 +789,19 @@ class TestCondition : public TestFixture {
" if (x) {}\n"
" else if (!x) {}\n"
"}");
ASSERT_EQUALS("test.cpp:3:style:Expression is always true because 'else if' condition is opposite to previous condition at line 2.\n"
"test.cpp:2:note:first condition\n"
"test.cpp:3:note:else if condition is opposite to first condition\n", errout_str());
ASSERT_EQUALS("[test.cpp:3:14]: style: Expression is always true because 'else if' condition is opposite to previous condition at line 2. [multiCondition]\n"
"[test.cpp:2:9]: note: first condition\n"
"[test.cpp:3:14]: note: else if condition is opposite to first condition\n", errout_str());

check("void f(int x) {\n"
" int y = x;\n"
" if (x) {}\n"
" else if (!y) {}\n"
"}");
ASSERT_EQUALS("test.cpp:4:style:Expression is always true because 'else if' condition is opposite to previous condition at line 3.\n"
"test.cpp:2:note:'y' is assigned value 'x' here.\n"
"test.cpp:3:note:first condition\n"
"test.cpp:4:note:else if condition is opposite to first condition\n", errout_str());
ASSERT_EQUALS("[test.cpp:4:14]: style: Expression is always true because 'else if' condition is opposite to previous condition at line 3. [multiCondition]\n"
"[test.cpp:2:13]: note: 'y' is assigned value 'x' here.\n"
"[test.cpp:3:9]: note: first condition\n"
"[test.cpp:4:14]: note: else if condition is opposite to first condition\n", errout_str());
}

void checkBadBitmaskCheck() {
Expand Down Expand Up @@ -6021,27 +6021,27 @@ class TestCondition : public TestFixture {
" if (x == y)\n"
" x = y;\n"
"}");
ASSERT_EQUALS("test.cpp:3:style:Assignment 'x=y' is redundant with condition 'x==y'.\n"
"test.cpp:2:note:Condition 'x==y'\n"
"test.cpp:3:note:Assignment 'x=y' is redundant\n", errout_str());
ASSERT_EQUALS("[test.cpp:3:11]: style: Assignment 'x=y' is redundant with condition 'x==y'. [duplicateConditionalAssign]\n"
"[test.cpp:2:11]: note: Condition 'x==y'\n"
"[test.cpp:3:11]: note: Assignment 'x=y' is redundant\n", errout_str());

check("void f(int& x, int y) {\n"
" if (x != y)\n"
" x = y;\n"
"}");
ASSERT_EQUALS("test.cpp:2:style:The statement 'if (x!=y) x=y' is logically equivalent to 'x=y'.\n"
"test.cpp:3:note:Assignment 'x=y'\n"
"test.cpp:2:note:Condition 'x!=y' is redundant\n", errout_str());
ASSERT_EQUALS("[test.cpp:2:11]: style: The statement 'if (x!=y) x=y' is logically equivalent to 'x=y'. [duplicateConditionalAssign]\n"
"[test.cpp:3:11]: note: Assignment 'x=y'\n"
"[test.cpp:2:11]: note: Condition 'x!=y' is redundant\n", errout_str());

check("void f(int& x, int y) {\n"
" if (x == y)\n"
" x = y;\n"
" else\n"
" x = 1;\n"
"}");
ASSERT_EQUALS("test.cpp:3:style:Assignment 'x=y' is redundant with condition 'x==y'.\n"
"test.cpp:2:note:Condition 'x==y'\n"
"test.cpp:3:note:Assignment 'x=y' is redundant\n", errout_str());
ASSERT_EQUALS("[test.cpp:3:11]: style: Assignment 'x=y' is redundant with condition 'x==y'. [duplicateConditionalAssign]\n"
"[test.cpp:2:11]: note: Condition 'x==y'\n"
"[test.cpp:3:11]: note: Assignment 'x=y' is redundant\n", errout_str());

check("void f(int& x, int y) {\n"
" if (x != y)\n"
Expand Down Expand Up @@ -6091,18 +6091,18 @@ class TestCondition : public TestFixture {
" }\n"
" bool b;\n"
"};\n");
ASSERT_EQUALS("test.cpp:4:style:The statement 'if (b) b=true' is redundant.\n"
"test.cpp:4:note:Assignment 'b=true'\n"
"test.cpp:4:note:Condition 'b' is redundant\n"
"test.cpp:5:style:The statement 'if (b) b=false' is logically equivalent to 'b=false'.\n"
"test.cpp:5:note:Assignment 'b=false'\n"
"test.cpp:5:note:Condition 'b' is redundant\n"
"test.cpp:6:style:The statement 'if (!b) b=true' is logically equivalent to 'b=true'.\n"
"test.cpp:6:note:Assignment 'b=true'\n"
"test.cpp:6:note:Condition '!b' is redundant\n"
"test.cpp:7:style:The statement 'if (!b) b=false' is redundant.\n"
"test.cpp:7:note:Assignment 'b=false'\n"
"test.cpp:7:note:Condition '!b' is redundant\n",
ASSERT_EQUALS("[test.cpp:4:13]: style: The statement 'if (b) b=true' is redundant. [duplicateConditionalAssign]\n"
"[test.cpp:4:18]: note: Assignment 'b=true'\n"
"[test.cpp:4:13]: note: Condition 'b' is redundant\n"
"[test.cpp:5:13]: style: The statement 'if (b) b=false' is logically equivalent to 'b=false'. [duplicateConditionalAssign]\n"
"[test.cpp:5:18]: note: Assignment 'b=false'\n"
"[test.cpp:5:13]: note: Condition 'b' is redundant\n"
"[test.cpp:6:13]: style: The statement 'if (!b) b=true' is logically equivalent to 'b=true'. [duplicateConditionalAssign]\n"
"[test.cpp:6:19]: note: Assignment 'b=true'\n"
"[test.cpp:6:13]: note: Condition '!b' is redundant\n"
"[test.cpp:7:13]: style: The statement 'if (!b) b=false' is redundant. [duplicateConditionalAssign]\n"
"[test.cpp:7:19]: note: Assignment 'b=false'\n"
"[test.cpp:7:13]: note: Condition '!b' is redundant\n",
errout_str());
}

Expand Down
Loading
Loading