https://github.com/benedekaibas updated https://github.com/llvm/llvm-project/pull/228777
>From c7121f0eb13a1d5350a0a00c62688c79fd5740e1 Mon Sep 17 00:00:00 2001 From: benedekaibas <[email protected]> Date: Sat, 3 Oct 2026 23:27:55 +0200 Subject: [PATCH] [analyzer] Fix double space in generateMinimalDiagForBlockEdge emitted notes --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 4 ++-- clang/test/Analysis/dangling-ptr-deref.cpp | 2 +- .../diagnostics/track_subexpressions.cpp | 4 ++-- clang/test/Analysis/loop-widening-notes.cpp | 8 +++---- clang/test/Analysis/loop-widening.cpp | 4 ++-- clang/test/Analysis/return-ptr-range.cpp | 4 ++-- .../track-control-dependency-conditions.cpp | 6 ++--- clang/test/Analysis/use-after-move.cpp | 24 +++++++++---------- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 25d10df604bda1..595f6b0090b41d 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -972,7 +972,7 @@ void PathDiagnosticBuilder::generateMinimalDiagForBlockEdge( C.getActivePath().push_front( std::make_shared<PathDiagnosticControlFlowPiece>( - Start, End, "Loop condition is false. Exiting loop")); + Start, End, "Loop condition is false. Exiting loop")); } break; @@ -996,7 +996,7 @@ void PathDiagnosticBuilder::generateMinimalDiagForBlockEdge( C.getActivePath().push_front( std::make_shared<PathDiagnosticControlFlowPiece>( - Start, End, "Loop condition is true. Entering loop body")); + Start, End, "Loop condition is true. Entering loop body")); } break; diff --git a/clang/test/Analysis/dangling-ptr-deref.cpp b/clang/test/Analysis/dangling-ptr-deref.cpp index 8572b6416f150f..1c026b5528921b 100644 --- a/clang/test/Analysis/dangling-ptr-deref.cpp +++ b/clang/test/Analysis/dangling-ptr-deref.cpp @@ -72,7 +72,7 @@ void test_case_six() { void test_case_seven() { int *ptr = nullptr; - // expected-note@+3 {{Loop condition is true. Entering loop body}} + // expected-note@+3 {{Loop condition is true. Entering loop body}} // expected-note@+2 {{Assuming 'i' is >= 10}} // expected-note@+1 {{Loop condition is false. Execution continues on line}} for (int i = 0; i < 10; ++i) { // expected-note {{'i' initialized to 0}} diff --git a/clang/test/Analysis/diagnostics/track_subexpressions.cpp b/clang/test/Analysis/diagnostics/track_subexpressions.cpp index c61738ce7b136d..76cf9e3e242850 100644 --- a/clang/test/Analysis/diagnostics/track_subexpressions.cpp +++ b/clang/test/Analysis/diagnostics/track_subexpressions.cpp @@ -37,7 +37,7 @@ void testArrayIndexTracking() { int arr[10]; for (int i = 0; i < 3; ++i) - // expected-note@-1 3{{Loop condition is true. Entering loop body}} + // expected-note@-1 3{{Loop condition is true. Entering loop body}} // expected-note@-2 {{Loop condition is false. Execution continues on line 43}} arr[i] = 0; int x = getInt(); @@ -69,7 +69,7 @@ void testArrayIndexTracking() { int arr[2][10]; for (int i = 0; i < 3; ++i) - // expected-note@-1 3{{Loop condition is true. Entering loop body}} + // expected-note@-1 3{{Loop condition is true. Entering loop body}} // expected-note@-2 {{Loop condition is false. Execution continues on line 75}} arr[1][i] = 0; int x = getInt(); diff --git a/clang/test/Analysis/loop-widening-notes.cpp b/clang/test/Analysis/loop-widening-notes.cpp index a3f030dfe98826..7bd61fe0db4d0f 100644 --- a/clang/test/Analysis/loop-widening-notes.cpp +++ b/clang/test/Analysis/loop-widening-notes.cpp @@ -7,7 +7,7 @@ int test_for_bug_25609() { if (p_a == 0) // expected-note {{Assuming 'p_a' is equal to null}} // expected-note@-1 {{Taking true branch}} bar(); - for (int i = 0; // expected-note {{Loop condition is true. Entering loop body}} + for (int i = 0; // expected-note {{Loop condition is true. Entering loop body}} // expected-note@-1 {{Loop condition is false. Execution continues on line 16}} ++i, // expected-note {{Value assigned to 'p_a'}} i < flag_a; @@ -22,7 +22,7 @@ int flag_b; int while_analyzer_output() { flag_b = 100; int num = 10; - while (flag_b-- > 0) { // expected-note {{Loop condition is true. Entering loop body}} + while (flag_b-- > 0) { // expected-note {{Loop condition is true. Entering loop body}} // expected-note@-1 {{Value assigned to 'num'}} // expected-note@-2 {{Loop condition is false. Execution continues on line 30}} num = flag_b; @@ -43,7 +43,7 @@ int flag_c; int do_while_analyzer_output() { int num = 10; do { // expected-note {{Loop condition is true. Execution continues on line 47}} - // expected-note@-1 {{Loop condition is false. Exiting loop}} + // expected-note@-1 {{Loop condition is false. Exiting loop}} num--; } while (flag_c-- > 0); //expected-note {{Value assigned to 'num'}} int local = 0; @@ -57,7 +57,7 @@ int do_while_analyzer_output() { int flag_d; int test_for_loop() { int num = 10; - for (int i = 0; // expected-note {{Loop condition is true. Entering loop body}} + for (int i = 0; // expected-note {{Loop condition is true. Entering loop body}} // expected-note@-1 {{Loop condition is false. Execution continues on line 67}} new int(10), // expected-note {{Value assigned to 'num'}} i < flag_d; diff --git a/clang/test/Analysis/loop-widening.cpp b/clang/test/Analysis/loop-widening.cpp index fbcb72dee160ae..fa8e9c2f3d6968 100644 --- a/clang/test/Analysis/loop-widening.cpp +++ b/clang/test/Analysis/loop-widening.cpp @@ -14,8 +14,8 @@ void fn1() { A a; A *b = &a; - for (;;) { // expected-note{{Loop condition is true. Entering loop body}} - // expected-note@-1{{Loop condition is true. Entering loop body}} + for (;;) { // expected-note{{Loop condition is true. Entering loop body}} + // expected-note@-1{{Loop condition is true. Entering loop body}} // expected-note@-2{{Value assigned to 'b'}} // no crash during bug report construction diff --git a/clang/test/Analysis/return-ptr-range.cpp b/clang/test/Analysis/return-ptr-range.cpp index 507720a47ea7d5..53612174897c75 100644 --- a/clang/test/Analysis/return-ptr-range.cpp +++ b/clang/test/Analysis/return-ptr-range.cpp @@ -8,7 +8,7 @@ int arr[10]; // expected-note{{Original object declared here}} expected-note{{Or int *ptr; int *test_global_ptr() { - do { // expected-note{{Loop condition is false. Exiting loop}} + do { // expected-note{{Loop condition is false. Exiting loop}} int x = conjure_index(); ptr = arr + x; // expected-note{{Value assigned to 'ptr'}} if (x != 20) // expected-note{{Assuming 'x' is equal to 20}} @@ -22,7 +22,7 @@ int *test_global_ptr() { int *test_local_ptr() { int *local_ptr; - do { // expected-note{{Loop condition is false. Exiting loop}} + do { // expected-note{{Loop condition is false. Exiting loop}} int x = conjure_index(); local_ptr = arr + x; // expected-note{{Value assigned to 'local_ptr'}} if (x != 20) // expected-note{{Assuming 'x' is equal to 20}} diff --git a/clang/test/Analysis/track-control-dependency-conditions.cpp b/clang/test/Analysis/track-control-dependency-conditions.cpp index b762992b6a8f0b..76f9641729de5d 100644 --- a/clang/test/Analysis/track-control-dependency-conditions.cpp +++ b/clang/test/Analysis/track-control-dependency-conditions.cpp @@ -858,7 +858,7 @@ void f(int flag) { bar(); assert(cond1); // expected-note-re{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}} // expected-note-re@-1{{{{^}}Taking false branch{{$}}}} - // expected-note-re@-2{{{{^}}Loop condition is false. Exiting loop{{$}}}} + // expected-note-re@-2{{{{^}}Loop condition is false. Exiting loop{{$}}}} if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}} // expected-note-re@-1{{{{^}}Taking true branch{{$}}}} @@ -902,7 +902,7 @@ void f(int flag) { // expected-note-re@-2{{{{^}}Left side of '&&' is true{{$}}}} // expected-note-re@-3{{{{^}}Assuming the condition is false{{$}}}} // expected-note-re@-4{{{{^}}Taking false branch{{$}}}} - // expected-note-re@-5{{{{^}}Loop condition is false. Exiting loop{{$}}}} + // expected-note-re@-5{{{{^}}Loop condition is false. Exiting loop{{$}}}} if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}} // expected-note-re@-1{{{{^}}Taking true branch{{$}}}} @@ -945,7 +945,7 @@ void f(int flag) { // expected-note-re@-1{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}} // expected-note-re@-2{{{{^}}Left side of '||' is true{{$}}}} // expected-note-re@-3{{{{^}}Taking false branch{{$}}}} - // expected-note-re@-4{{{{^}}Loop condition is false. Exiting loop{{$}}}} + // expected-note-re@-4{{{{^}}Loop condition is false. Exiting loop{{$}}}} if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}} // expected-note-re@-1{{{{^}}Taking true branch{{$}}}} diff --git a/clang/test/Analysis/use-after-move.cpp b/clang/test/Analysis/use-after-move.cpp index fa7893c9a21c8b..a123c41c651e60 100644 --- a/clang/test/Analysis/use-after-move.cpp +++ b/clang/test/Analysis/use-after-move.cpp @@ -303,8 +303,8 @@ void loopTest() { } { A a; - for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} - // peaceful-note@-1 {{Loop condition is true. Entering loop body}} + for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} + // peaceful-note@-1 {{Loop condition is true. Entering loop body}} // peaceful-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} rightRefCall(std::move(a)); // no-warning } @@ -317,8 +317,8 @@ void loopTest() { } { A a; - for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} - // peaceful-note@-1 {{Loop condition is true. Entering loop body}} + for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} + // peaceful-note@-1 {{Loop condition is true. Entering loop body}} // peaceful-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} leftRefCall(a); // no-warning } @@ -331,8 +331,8 @@ void loopTest() { } { A a; - for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} - // peaceful-note@-1 {{Loop condition is true. Entering loop body}} + for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} + // peaceful-note@-1 {{Loop condition is true. Entering loop body}} // peaceful-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} constCopyOrMoveCall(a); // no-warning } @@ -345,8 +345,8 @@ void loopTest() { } { A a; - for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} - // peaceful-note@-1 {{Loop condition is true. Entering loop body}} + for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} + // peaceful-note@-1 {{Loop condition is true. Entering loop body}} // peaceful-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} moveInsideFunctionCall(a); // no-warning } @@ -359,16 +359,16 @@ void loopTest() { } { A a; - for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} - // peaceful-note@-1 {{Loop condition is true. Entering loop body}} + for (int i = 0; i < 2; i++) { // peaceful-note {{Loop condition is true. Entering loop body}} + // peaceful-note@-1 {{Loop condition is true. Entering loop body}} // peaceful-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} copyOrMoveCall(a); // no-warning } } { A a; - for (int i = 0; i < bignum(); i++) { // peaceful-note {{Loop condition is true. Entering loop body}} - // peaceful-note@-1 {{Loop condition is true. Entering loop body}} + for (int i = 0; i < bignum(); i++) { // peaceful-note {{Loop condition is true. Entering loop body}} + // peaceful-note@-1 {{Loop condition is true. Entering loop body}} constCopyOrMoveCall(std::move(a)); // peaceful-note {{Object 'a' is moved}} // peaceful-warning@-1 {{Moved-from object 'a' is moved}} // peaceful-note@-2 {{Moved-from object 'a' is moved}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
