[clang] [analyzer] Fix double space in generateMinimalDiagForBlockEdge emitted notes (PR #228777)
Benedek Kaibas via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 15 06:07:33 PDT 2026
https://github.com/benedekaibas updated https://github.com/llvm/llvm-project/pull/228777
>From c7121f0eb13a1d5350a0a00c62688c79fd5740e1 Mon Sep 17 00:00:00 2001
From: benedekaibas <kaibas01 at allegheny.edu>
Date: Sat, 3 Oct 2026 23:27:55 +0200
Subject: [PATCH 1/2] [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 at +3 {{Loop condition is true. Entering loop body}}
+ // expected-note at +3 {{Loop condition is true. Entering loop body}}
// expected-note at +2 {{Assuming 'i' is >= 10}}
// expected-note at +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 at -1 3{{Loop condition is true. Entering loop body}}
+ // expected-note at -1 3{{Loop condition is true. Entering loop body}}
// expected-note at -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 at -1 3{{Loop condition is true. Entering loop body}}
+ // expected-note at -1 3{{Loop condition is true. Entering loop body}}
// expected-note at -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 at -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 at -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 at -1 {{Value assigned to 'num'}}
// expected-note at -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 at -1 {{Loop condition is false. Exiting loop}}
+ // expected-note at -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 at -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 at -1{{Loop condition is true. Entering loop body}}
+ for (;;) { // expected-note{{Loop condition is true. Entering loop body}}
+ // expected-note at -1{{Loop condition is true. Entering loop body}}
// expected-note at -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 at -1{{{{^}}Taking false branch{{$}}}}
- // expected-note-re at -2{{{{^}}Loop condition is false. Exiting loop{{$}}}}
+ // expected-note-re at -2{{{{^}}Loop condition is false. Exiting loop{{$}}}}
if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
// expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
@@ -902,7 +902,7 @@ void f(int flag) {
// expected-note-re at -2{{{{^}}Left side of '&&' is true{{$}}}}
// expected-note-re at -3{{{{^}}Assuming the condition is false{{$}}}}
// expected-note-re at -4{{{{^}}Taking false branch{{$}}}}
- // expected-note-re at -5{{{{^}}Loop condition is false. Exiting loop{{$}}}}
+ // expected-note-re at -5{{{{^}}Loop condition is false. Exiting loop{{$}}}}
if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
// expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
@@ -945,7 +945,7 @@ void f(int flag) {
// expected-note-re at -1{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}}
// expected-note-re at -2{{{{^}}Left side of '||' is true{{$}}}}
// expected-note-re at -3{{{{^}}Taking false branch{{$}}}}
- // expected-note-re at -4{{{{^}}Loop condition is false. Exiting loop{{$}}}}
+ // expected-note-re at -4{{{{^}}Loop condition is false. Exiting loop{{$}}}}
if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
// expected-note-re at -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 at -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 at -1 {{Loop condition is true. Entering loop body}}
// peaceful-note at -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 at -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 at -1 {{Loop condition is true. Entering loop body}}
// peaceful-note at -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 at -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 at -1 {{Loop condition is true. Entering loop body}}
// peaceful-note at -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 at -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 at -1 {{Loop condition is true. Entering loop body}}
// peaceful-note at -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 at -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 at -1 {{Loop condition is true. Entering loop body}}
// peaceful-note at -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 at -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 at -1 {{Loop condition is true. Entering loop body}}
constCopyOrMoveCall(std::move(a)); // peaceful-note {{Object 'a' is moved}}
// peaceful-warning at -1 {{Moved-from object 'a' is moved}}
// peaceful-note at -2 {{Moved-from object 'a' is moved}}
>From efb65443dd0b1ce7cc3917bbaf2779a97bbce3f3 Mon Sep 17 00:00:00 2001
From: benedekaibas <kaibas01 at allegheny.edu>
Date: Thu, 15 Oct 2026 15:06:59 +0200
Subject: [PATCH 2/2] Convert double spaces to single after sentence endings in
the CSA.
---
clang/docs/ReleaseNotes.md | 1 +
.../Checkers/CheckObjCInstMethSignature.cpp | 4 +--
.../Checkers/CheckSecuritySyntaxOnly.cpp | 11 ++++----
.../Checkers/MacOSXAPIChecker.cpp | 4 +--
.../RetainCountDiagnostics.cpp | 4 +--
.../Checkers/StackAddrEscapeChecker.cpp | 2 +-
.../Checkers/UnixAPIChecker.cpp | 2 +-
clang/test/Analysis/const-method-call.cpp | 2 +-
.../cxx-uninitialized-object-ptr-ref.cpp | 12 ++++----
clang/test/Analysis/dispatch-once.m | 4 +--
.../test/Analysis/incorrect-checker-names.cpp | 4 +--
.../test/Analysis/retain-release-path-notes.m | 4 +--
clang/test/Analysis/security-syntax-checks.m | 28 +++++++++----------
clang/test/Analysis/stack-addr-ps.cpp | 4 +--
.../Analysis/stack-capture-leak-no-arc.mm | 4 +--
clang/test/Analysis/stackaddrleak.c | 4 +--
clang/test/Analysis/stackaddrleak.cpp | 2 +-
17 files changed, 49 insertions(+), 47 deletions(-)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index d6c40a2920cf5a..21a7483a2d4eac 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -1053,6 +1053,7 @@ The `alpha.cplusplus.UseAfterLifetimeEnd` checker was renamed to `alpha.core.Use
#### Diagnostic changes
- For self-assignments during initialization (`T v = v;`), `core.uninitialized.Assign` will not report them as uninitialized accesses (except C++ reference types), and the checks will be delayed until the first accesses of these variables; `deadcode.DeadStores` will not report them as dead stores. (#GH187530)
+- The Clang Static Analyzer's emitted diagnostics (warnings, notes) now consistently have one space after sentence endings (#GH228777). The RFC for this change can be found here: https://discourse.llvm.org/t/rfc-standardization-of-reports-sentence-spacing/92428
(release-notes-sanitizers)=
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
index c8fe5c2ccf384e..010c7589cfca12 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
@@ -56,11 +56,11 @@ static void CompareReturnTypes(const ObjCMethodDecl *MethDerived,
<< "', defines the instance method '";
MethDerived->getSelector().print(os);
os << "' whose return type is '" << ResDerived
- << "'. A method with the same name (same selector) is also defined in "
+ << "'. A method with the same name (same selector) is also defined in "
"class '"
<< *MethAncestor->getClassInterface() << "' and has a return type of '"
<< ResAncestor
- << "'. These two types are incompatible, and may result in undefined "
+ << "'. These two types are incompatible, and may result in undefined "
"behavior for clients of these classes.";
PathDiagnosticLocation MethDLoc =
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
index 797e1efc7e8ca5..eeb6c99c91c6da 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -588,7 +588,7 @@ void WalkAST::checkCall_mktemp(const CallExpr *CE, const FunctionDecl *FD) {
"Potential insecure temporary file in call 'mktemp'",
"Security",
"Call to function 'mktemp' is insecure as it always "
- "creates or uses insecure temporary file. Use 'mkstemp' "
+ "creates or uses insecure temporary file. Use 'mkstemp' "
"instead",
CELoc, CE->getCallee()->getSourceRange());
}
@@ -893,7 +893,7 @@ void WalkAST::checkCall_rand(const CallExpr *CE, const FunctionDecl *FD) {
llvm::raw_svector_ostream os2(buf2);
os2 << "Function '" << *FD
<< "' is obsolete because it implements a poor random number generator."
- << " Use 'arc4random' instead";
+ << " Use 'arc4random' instead";
PathDiagnosticLocation CELoc =
PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
@@ -922,8 +922,9 @@ void WalkAST::checkCall_random(const CallExpr *CE, const FunctionDecl *FD) {
"'random' is not a secure random number generator",
"Security",
"The 'random' function produces a sequence of values that "
- "an adversary may be able to predict. Use 'arc4random' "
- "instead", CELoc, CE->getCallee()->getSourceRange());
+ "an adversary may be able to predict. Use 'arc4random' "
+ "instead",
+ CELoc, CE->getCallee()->getSourceRange());
}
//===----------------------------------------------------------------------===//
@@ -1064,7 +1065,7 @@ void WalkAST::checkUncheckedReturnValue(CallExpr *CE) {
SmallString<256> buf2;
llvm::raw_svector_ostream os2(buf2);
os2 << "The return value from the call to '" << *FD
- << "' is not checked. If an error occurs in '" << *FD
+ << "' is not checked. If an error occurs in '" << *FD
<< "', the following code may execute with unexpected privileges";
PathDiagnosticLocation CELoc =
diff --git a/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
index 6439e6cedac085..9de17198f6bc4f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -125,10 +125,10 @@ void MacOSXAPIChecker::CheckDispatchOnce(CheckerContext &C, const CallExpr *CE,
} else {
os << " stack allocated memory";
}
- os << " for the predicate value. Using such transient memory for "
+ os << " for the predicate value. Using such transient memory for "
"the predicate is potentially dangerous.";
if (SuggestStatic)
- os << " Perhaps you intended to declare the variable as 'static'?";
+ os << " Perhaps you intended to declare the variable as 'static'?";
ExplodedNode *N = C.generateErrorNode();
if (!N)
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index 59d11c4d8ae2cf..10a75aa5874d98 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -746,7 +746,7 @@ RefLeakReportVisitor::getEndPath(const ExplodedNode *EndN,
os << "whose name ('" << MD->getSelector().getAsString()
<< "') does not start with "
"'copy', 'mutableCopy', 'alloc' or 'new'."
- " This violates the naming convention rules"
+ " This violates the naming convention rules"
" given in the Memory Management Guide for Cocoa";
}
} else {
@@ -754,7 +754,7 @@ RefLeakReportVisitor::getEndPath(const ExplodedNode *EndN,
ObjKind K = RV->getObjKind();
if (K == ObjKind::ObjC || K == ObjKind::CF) {
os << "whose name ('" << *FD
- << "') does not contain 'Copy' or 'Create'. This violates the "
+ << "') does not contain 'Copy' or 'Create'. This violates the "
"naming convention rules given in the Memory Management Guide "
"for Core Foundation";
} else if (RV->getObjKind() == ObjKind::OS) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index db307d3ac549f6..3ccfb7e15dda20 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -585,7 +585,7 @@ void StackAddrEscapeChecker::checkEndFunction(const ReturnStmt *RS,
// Generate a report for this bug.
const StringRef CommonSuffix =
- " upon returning to the caller. This will be a dangling reference";
+ " upon returning to the caller. This will be a dangling reference";
SmallString<128> Buf;
llvm::raw_svector_ostream Out(Buf);
const SourceRange Range = genName(Out, Referred, Ctx.getASTContext());
diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index e51a74f7259752..0a55d1da7f91bc 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -435,7 +435,7 @@ void UnixAPIMisuseChecker::CheckPthreadOnce(CheckerContext &C,
os << " the local variable '" << VR->getDecl()->getName() << '\'';
else
os << " stack allocated memory";
- os << " for the \"control\" value. Using such transient memory for "
+ os << " for the \"control\" value. Using such transient memory for "
"the control value is potentially dangerous.";
if (isa<VarRegion>(R) && R->hasMemorySpace<StackLocalsSpaceRegion>(state))
os << " Perhaps you intended to declare the variable as 'static'?";
diff --git a/clang/test/Analysis/const-method-call.cpp b/clang/test/Analysis/const-method-call.cpp
index b37ce17447bdd2..47467043363eac 100644
--- a/clang/test/Analysis/const-method-call.cpp
+++ b/clang/test/Analysis/const-method-call.cpp
@@ -314,6 +314,6 @@ template <typename R> class callable<R()> {
void entry() {
callable<bool()>{}.call().const_method();
- // expected-warning at -1 {{Address of stack memory associated with temporary object of type 'callable<bool ()>' is still referred to by the static variable 'L' upon returning to the caller. This will be a dangling reference}}
+ // expected-warning at -1 {{Address of stack memory associated with temporary object of type 'callable<bool ()>' is still referred to by the static variable 'L' upon returning to the caller. This will be a dangling reference}}
}
} // namespace gh77378
diff --git a/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp b/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
index fddd6c8c3d6dfc..87ad5be8fb52f7 100644
--- a/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -86,7 +86,7 @@ struct UntypedAllocaTest {
// expected-warning-re at +3 {{Address of stack memory allocated by call to \
alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
-stack upon returning to the caller. This will be a dangling reference}}
+stack upon returning to the caller. This will be a dangling reference}}
UntypedAllocaTest() : allocaPtr(__builtin_alloca(sizeof(int))) {
// All good!
}
@@ -104,7 +104,7 @@ struct TypedAllocaTest1 {
: allocaPtr(static_cast<int *>(__builtin_alloca(sizeof(int)))) {}
// expected-warning-re at -2 {{Address of stack memory allocated by call to \
alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
-stack upon returning to the caller. This will be a dangling reference}}
+stack upon returning to the caller. This will be a dangling reference}}
};
void fTypedAllocaTest1() {
@@ -117,7 +117,7 @@ struct TypedAllocaTest2 {
// expected-warning-re at +5 {{Address of stack memory allocated by call to \
alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
-stack upon returning to the caller. This will be a dangling reference}}
+stack upon returning to the caller. This will be a dangling reference}}
TypedAllocaTest2()
: allocaPtr(static_cast<int *>(__builtin_alloca(sizeof(int)))) {
*allocaPtr = 55555;
@@ -370,7 +370,7 @@ class VoidPointerRRefTest1 {
public:
// expected-warning at +3 {{Address of stack memory associated with local \
variable 'vptr' is still referred to by a temporary object on the stack \
-upon returning to the caller. This will be a dangling reference}}
+upon returning to the caller. This will be a dangling reference}}
VoidPointerRRefTest1(void *vptr, char) : vptrrref(static_cast<void *&&>(vptr)) { // expected-warning {{binding reference member 'vptrrref' to stack allocated parameter 'vptr'}}
// All good!
}
@@ -388,7 +388,7 @@ class VoidPointerRRefTest2 {
public:
// expected-warning at +3 {{Address of stack memory associated with local \
variable 'vptr' is still referred to by a temporary object on the stack \
-upon returning to the caller. This will be a dangling reference}}
+upon returning to the caller. This will be a dangling reference}}
VoidPointerRRefTest2(void **vptr, char) : vpptrrref(static_cast<void **&&>(vptr)) { // expected-warning {{binding reference member 'vpptrrref' to stack allocated parameter 'vptr'}}
// All good!
}
@@ -406,7 +406,7 @@ class VoidPointerLRefTest {
public:
// expected-warning at +3 {{Address of stack memory associated with local \
variable 'vptr' is still referred to by a temporary object on the stack \
-upon returning to the caller. This will be a dangling reference}}
+upon returning to the caller. This will be a dangling reference}}
VoidPointerLRefTest(void *vptr, char) : vptrrref(static_cast<void *&>(vptr)) { // expected-warning {{binding reference member 'vptrrref' to stack allocated parameter 'vptr'}}
// All good!
}
diff --git a/clang/test/Analysis/dispatch-once.m b/clang/test/Analysis/dispatch-once.m
index fa84f563815dd6..045aded3fd192e 100644
--- a/clang/test/Analysis/dispatch-once.m
+++ b/clang/test/Analysis/dispatch-once.m
@@ -21,7 +21,7 @@
void test_stack(void) {
dispatch_once_t once;
- dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 'once' for the predicate value. Using such transient memory for the predicate is potentially dangerous. Perhaps you intended to declare the variable as 'static'?}}
+ dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 'once' for the predicate value. Using such transient memory for the predicate is potentially dangerous. Perhaps you intended to declare the variable as 'static'?}}
}
void test_static_local(void) {
@@ -32,7 +32,7 @@ void test_static_local(void) {
void test_heap_var(void) {
dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
// Use regexps to check that we're NOT suggesting to make this static.
- dispatch_once(once, ^{}); // expected-warning-re{{{{^Call to 'dispatch_once' uses heap-allocated memory for the predicate value. Using such transient memory for the predicate is potentially dangerous$}}}}
+ dispatch_once(once, ^{}); // expected-warning-re{{{{^Call to 'dispatch_once' uses heap-allocated memory for the predicate value. Using such transient memory for the predicate is potentially dangerous$}}}}
}
void test_external_pointer(dispatch_once_t *once) {
diff --git a/clang/test/Analysis/incorrect-checker-names.cpp b/clang/test/Analysis/incorrect-checker-names.cpp
index 8dee0b6f468581..3808b2b4f84ac5 100644
--- a/clang/test/Analysis/incorrect-checker-names.cpp
+++ b/clang/test/Analysis/incorrect-checker-names.cpp
@@ -16,5 +16,5 @@ char const *p;
void f0() {
char const str[] = "This will change";
p = str;
-} // expected-warning at -1{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference [core.StackAddressEscape]}}
-// expected-note at -2{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
+} // expected-warning at -1{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference [core.StackAddressEscape]}}
+// expected-note at -2{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
diff --git a/clang/test/Analysis/retain-release-path-notes.m b/clang/test/Analysis/retain-release-path-notes.m
index 3c193c1e2bc4fd..5e5d32b0b1553e 100644
--- a/clang/test/Analysis/retain-release-path-notes.m
+++ b/clang/test/Analysis/retain-release-path-notes.m
@@ -112,7 +112,7 @@ CFTypeRef CFCopyRuleViolation (void) {
CFTypeRef CFGetRuleViolation (void) {
CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type 'CFTypeRef' with a +1 retain count}}
- return object; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation}}
+ return object; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation}}
}
@implementation Foo (FundamentalMemoryManagementRules)
@@ -133,7 +133,7 @@ - (id)copyViolationKeyedSubscript {
- (id)getViolation {
id result = [[Foo alloc] init]; // expected-note{{Method returns an instance of Foo with a +1 retain count}}
- return result; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa}}
+ return result; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa}}
}
- (id)copyAutorelease {
diff --git a/clang/test/Analysis/security-syntax-checks.m b/clang/test/Analysis/security-syntax-checks.m
index 154f0c1bae427c..e4699541dff63c 100644
--- a/clang/test/Analysis/security-syntax-checks.m
+++ b/clang/test/Analysis/security-syntax-checks.m
@@ -100,8 +100,8 @@ void test_getpw(void) {
void test_setuid(void)
{
- setuid(2); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
- setuid(0); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
+ setuid(2); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
+ setuid(0); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
if (setuid (2) != 0)
abort();
@@ -113,8 +113,8 @@ void test_setuid(void)
check(setuid (2)); // no-warning
- setreuid(2,2); // expected-warning{{The return value from the call to 'setreuid' is not checked. If an error occurs in 'setreuid', the following code may execute with unexpected privileges}}
- setregid(2,2); // expected-warning{{The return value from the call to 'setregid' is not checked. If an error occurs in 'setregid', the following code may execute with unexpected privileges}}
+ setreuid(2,2); // expected-warning{{The return value from the call to 'setreuid' is not checked. If an error occurs in 'setreuid', the following code may execute with unexpected privileges}}
+ setregid(2,2); // expected-warning{{The return value from the call to 'setregid' is not checked. If an error occurs in 'setregid', the following code may execute with unexpected privileges}}
}
// CWE-338: Use of cryptographically weak prng
@@ -135,16 +135,16 @@ void test_rand(void)
unsigned short a[7];
unsigned b;
- rand(); // expected-warning{{Function 'rand' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- drand48(); // expected-warning{{Function 'drand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- erand48(a); // expected-warning{{Function 'erand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- jrand48(a); // expected-warning{{Function 'jrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- lcong48(a); // expected-warning{{Function 'lcong48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- lrand48(); // expected-warning{{Function 'lrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- mrand48(); // expected-warning{{Function 'mrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- nrand48(a); // expected-warning{{Function 'nrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- rand_r(&b); // expected-warning{{Function 'rand_r' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
- random(); // expected-warning{{The 'random' function produces a sequence of values that an adversary may be able to predict. Use 'arc4random' instead}}
+ rand(); // expected-warning{{Function 'rand' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ drand48(); // expected-warning{{Function 'drand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ erand48(a); // expected-warning{{Function 'erand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ jrand48(a); // expected-warning{{Function 'jrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ lcong48(a); // expected-warning{{Function 'lcong48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ lrand48(); // expected-warning{{Function 'lrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ mrand48(); // expected-warning{{Function 'mrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ nrand48(a); // expected-warning{{Function 'nrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ rand_r(&b); // expected-warning{{Function 'rand_r' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ random(); // expected-warning{{The 'random' function produces a sequence of values that an adversary may be able to predict. Use 'arc4random' instead}}
}
char *mktemp(char *buf);
diff --git a/clang/test/Analysis/stack-addr-ps.cpp b/clang/test/Analysis/stack-addr-ps.cpp
index 0ca7b074143065..3a14ce0ca55de5 100644
--- a/clang/test/Analysis/stack-addr-ps.cpp
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -373,7 +373,7 @@ void ***param_ptr_to_ptr_to_ptr_return(void ***ppp) {
int local = 0;
**ppp = &local;
return ppp;
- // expected-warning at -1 {{Address of stack memory associated with local variable 'local' is still referred to by the caller variable 'ppp' upon returning to the caller. This will be a dangling reference}}
+ // expected-warning at -1 {{Address of stack memory associated with local variable 'local' is still referred to by the caller variable 'ppp' upon returning to the caller. This will be a dangling reference}}
}
void param_ptr_to_ptr_to_ptr_caller(void** pp) {
@@ -568,7 +568,7 @@ S returned_struct_with_ptr_callee() {
int local = 42;
S s;
s.p = &local;
- return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} expected-warning{{Address of stack memory associated with local variable 'local' is still referred to by the caller variable 's' upon returning to the caller. This will be a dangling reference}}
+ return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} expected-warning{{Address of stack memory associated with local variable 'local' is still referred to by the caller variable 's' upon returning to the caller. This will be a dangling reference}}
}
S leak_through_field_of_returned_object() {
diff --git a/clang/test/Analysis/stack-capture-leak-no-arc.mm b/clang/test/Analysis/stack-capture-leak-no-arc.mm
index 71145d05072d77..03b3811be38327 100644
--- a/clang/test/Analysis/stack-capture-leak-no-arc.mm
+++ b/clang/test/Analysis/stack-capture-leak-no-arc.mm
@@ -40,7 +40,7 @@ dispatch_block_t test_block_inside_block_async_leak() {
// called.
void output_block(dispatch_block_t * blk) {
int x = 0;
- *blk = ^{ f(x); }; // expected-warning {{Address of stack-allocated block declared on line 43 is still referred to by the caller variable 'blk' upon returning to the caller. This will be a dangling reference [core.StackAddressEscape]}}
+ *blk = ^{ f(x); }; // expected-warning {{Address of stack-allocated block declared on line 43 is still referred to by the caller variable 'blk' upon returning to the caller. This will be a dangling reference [core.StackAddressEscape]}}
}
// The block literal captures nothing thus is treated as a constant.
@@ -54,7 +54,7 @@ void test_block_leak() {
__block dispatch_block_t blk;
int x = 0;
dispatch_block_t p = ^{
- blk = ^{ // expected-warning {{Address of stack-allocated block declared on line 57 is still referred to by the caller variable 'blk' upon returning to the caller. This will be a dangling reference [core.StackAddressEscape]}}
+ blk = ^{ // expected-warning {{Address of stack-allocated block declared on line 57 is still referred to by the caller variable 'blk' upon returning to the caller. This will be a dangling reference [core.StackAddressEscape]}}
f(x);
};
};
diff --git a/clang/test/Analysis/stackaddrleak.c b/clang/test/Analysis/stackaddrleak.c
index 96bd4e4ea19e5f..1ec129333a7fec 100644
--- a/clang/test/Analysis/stackaddrleak.c
+++ b/clang/test/Analysis/stackaddrleak.c
@@ -7,7 +7,7 @@ char const *p;
void f0(void) {
char const str[] = "This will change";
p = str;
-} // expected-warning at -1{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
+} // expected-warning at -1{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
void f1(void) {
char const str[] = "This will change";
@@ -17,7 +17,7 @@ void f1(void) {
void f2(void) {
p = (const char *) __builtin_alloca(12);
-} // expected-warning at -1{{Address of stack memory allocated by call to alloca() on line 19 is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
+} // expected-warning at -1{{Address of stack memory allocated by call to alloca() on line 19 is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
// PR 7383 - previously the stack address checker would crash on this example
// because it would attempt to do a direct load from 'pr7383_list'.
diff --git a/clang/test/Analysis/stackaddrleak.cpp b/clang/test/Analysis/stackaddrleak.cpp
index df202a2fee7762..74120fd9fdd4e8 100644
--- a/clang/test/Analysis/stackaddrleak.cpp
+++ b/clang/test/Analysis/stackaddrleak.cpp
@@ -18,7 +18,7 @@ struct myfunction {
myfunction create_func() {
int n;
auto c = [&n] {};
- return c; // expected-warning {{Address of stack memory associated with local variable 'n' returned to caller}} expected-warning{{Address of stack memory associated with local variable 'n' is still referred to by a temporary object on the stack upon returning to the caller. This will be a dangling reference}}
+ return c; // expected-warning {{Address of stack memory associated with local variable 'n' returned to caller}} expected-warning{{Address of stack memory associated with local variable 'n' is still referred to by a temporary object on the stack upon returning to the caller. This will be a dangling reference}}
}
void gh_66221() {
create_func()();
More information about the cfe-commits
mailing list