https://github.com/benedekaibas created https://github.com/llvm/llvm-project/pull/228777
`generateMinimalDiagForBlockEdge` currently has double spaces for loop condition notes. It was introduced in https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20080407/005074.html. There is no comment in the commit or doc comment that it is intentional. Also other emitted notes in the same function use a single space. This issue came up in #228045 While fixing this issue I have also went through the comments in the `BugReporter.cpp` and fixed some typos. >From 600f59de4d1e8ae27877dbdc3c4ea8271dc13b2e 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 | 14 +++++------ 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, 33 insertions(+), 33 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 25d10df604bda..0b994c446c96b 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -98,7 +98,7 @@ void BugReporterContext::anchor() {} namespace { -/// A (CallPiece, node assiciated with its CallEnter) pair. +/// A (CallPiece, node associated with its CallEnter) pair. using CallWithEntry = std::pair<PathDiagnosticCallPiece *, const ExplodedNode *>; using CallWithEntryStack = SmallVector<CallWithEntry, 6>; @@ -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; @@ -2257,7 +2257,7 @@ static void insertToInterestingnessMap( // Even if this symbol/region was already marked as interesting as a // condition, if we later mark it as interesting again but with // thorough tracking, overwrite it. Entities marked with thorough - // interestiness are the most important (or most interesting, if you will), + // interestingness are the most important (or most interesting, if you will), // and we wouldn't like to downplay their importance. switch (TKind) { @@ -2343,7 +2343,7 @@ PathSensitiveBugReport::getInterestingnessKind(SVal V) const { if (!SKind) return RKind; - // If either is marked with throrough tracking, return that, we wouldn't like + // If either is marked with thorough tracking, return that, we wouldn't like // to downplay a note's importance by 'only' mentioning it as a condition. switch(*RKind) { case bugreporter::TrackingKind::Thorough: @@ -2728,7 +2728,7 @@ BugPathInfo *BugPathGetter::getNextBugPath() { } /// CompactMacroExpandedPieces - This function postprocesses a PathDiagnostic -/// object and collapses PathDiagosticPieces that are expanded by macros. +/// object and collapses PathDiagnosticPieces that are expanded by macros. static void CompactMacroExpandedPieces(PathPieces &path, const SourceManager& SM) { using MacroStackTy = std::vector< @@ -2984,7 +2984,7 @@ void BugReporter::emitReport(std::unique_ptr<BugReport> R) { llvm::FoldingSetNodeID ID; R->Profile(ID); - // Lookup the equivance class. If there isn't one, create it. + // Lookup the equivalence class. If there isn't one, create it. llvm::FoldingSetInsertToken InsertToken; BugReportEquivClass *EQ = EQClasses.lookup(ID, InsertToken); diff --git a/clang/test/Analysis/dangling-ptr-deref.cpp b/clang/test/Analysis/dangling-ptr-deref.cpp index 8572b6416f150..1c026b5528921 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 c61738ce7b136..76cf9e3e24285 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 a3f030dfe9882..7bd61fe0db4d0 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 fbcb72dee160a..fa8e9c2f3d696 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 507720a47ea7d..53612174897c7 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 b762992b6a8f0..76f9641729de5 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 fa7893c9a21c8..a123c41c651e6 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
