https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/211038
From 1bd480d6d17c956635a4ddb844e2b57c0bb4104b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= <[email protected]> Date: Tue, 21 Jul 2026 18:17:29 +0200 Subject: [PATCH 1/2] [clang][analyzer] Improved message of CallAndMessageChecker at calls with uninitialized argument --- .../Checkers/CallAndMessageChecker.cpp | 24 +++++++-- clang/test/Analysis/PR40625.cpp | 2 +- ...ll-and-message-argpointeeinitializedness.c | 8 +-- ...-and-message-argpointeeinitializedness.cpp | 8 +-- clang/test/Analysis/call-and-message.c | 6 +-- clang/test/Analysis/exercise-ps.c | 2 +- clang/test/Analysis/uninit-const.c | 52 +++++++++---------- clang/test/Analysis/uninit-const.cpp | 12 ++--- 8 files changed, 65 insertions(+), 49 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp index 10efda33821c0..92ded1ff8e639 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -321,12 +321,27 @@ bool CallAndMessageChecker::uninitRefOrPointer(CheckerContext &C, SVal V, const SVal PointeeV = State->getSVal(SValMemRegion, PointeeT); const Expr *ArgEx = Call.getArgExpr(ArgumentNumber); + auto DescribeArgument = [ParamT, PointeeT, + &Call](bool ArgIsStruct) -> std::string { + if (PointeeT.isConstQualified()) + return llvm::formatv( + "This argument is const{0} and {1} input data of the function", + ParamT->isPointerType() ? " pointer" : "", + ArgIsStruct ? "may contain" : "is likely"); + else + return llvm::formatv( + "Function '{0}' expects {1}this argument to be initialized", + cast<NamedDecl>(Call.getDecl())->getNameAsString(), + ParamT->isPointerType() ? "memory pointed to by " : ""); + }; + if (PointeeV.isUndef()) { if (ExplodedNode *N = C.generateErrorNode()) { std::string Msg = llvm::formatv( - "{0}{1} function call argument is {2} uninitialized value", + "{0}{1} function call argument {2} an uninitialized value; {3}", ArgumentNumber + 1, llvm::getOrdinalSuffix(ArgumentNumber + 1), - ParamT->isPointerType() ? "a pointer to" : "an"); + ParamT->isPointerType() ? "points to" : "is", + DescribeArgument(/*ArgIsStruct=*/false)); auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, N); R->addRange(Call.getArgSourceRange(ArgumentNumber)); if (ArgEx) @@ -346,9 +361,10 @@ bool CallAndMessageChecker::uninitRefOrPointer(CheckerContext &C, SVal V, if (F.Find(D->getRegion())) { if (ExplodedNode *N = C.generateErrorNode()) { std::string Msg = llvm::formatv( - "{0}{1} function call argument {2} an uninitialized value{3}", + "{0}{1} function call argument {2} an uninitialized value{3}; {4}", (ArgumentNumber + 1), llvm::getOrdinalSuffix(ArgumentNumber + 1), - ParamT->isPointerType() ? "points to" : "references", F.FieldChain); + ParamT->isPointerType() ? "points to" : "is", F.FieldChain, + DescribeArgument(/*ArgIsStruct=*/true)); auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, N); R->addRange(Call.getArgSourceRange(ArgumentNumber)); if (ArgEx) diff --git a/clang/test/Analysis/PR40625.cpp b/clang/test/Analysis/PR40625.cpp index 5ebe2122945e6..d4be2e7390357 100644 --- a/clang/test/Analysis/PR40625.cpp +++ b/clang/test/Analysis/PR40625.cpp @@ -5,7 +5,7 @@ void f(const int *end); void g(const int (&arrr)[10]) { - f(arrr); // expected-warning{{1st function call argument is a pointer to uninitialized value}} + f(arrr); // expected-warning{{1st function call argument points to an uninitialized value;}} } void h() { diff --git a/clang/test/Analysis/call-and-message-argpointeeinitializedness.c b/clang/test/Analysis/call-and-message-argpointeeinitializedness.c index 2fc4b9f9f523e..5da7641e3b6d1 100644 --- a/clang/test/Analysis/call-and-message-argpointeeinitializedness.c +++ b/clang/test/Analysis/call-and-message-argpointeeinitializedness.c @@ -30,7 +30,7 @@ extern time_t mktime(struct tm *timeptr); void uninit_mbrlen(const char *mbs) { mbstate_t state; - mbrlen(mbs, 1, &state); // expected-warning{{3rd function call argument points to an uninitialized value}} + mbrlen(mbs, 1, &state); // expected-warning{{3rd function call argument points to an uninitialized value; Function 'mbrlen' expects memory pointed to by this argument to be initialized}} } void init_mbrlen(const char *mbs) { @@ -42,16 +42,16 @@ void init_mbrlen(const char *mbs) { void uninit_wcsnrtombs(const wchar_t *src) { char dst[10]; mbstate_t state; - wcsnrtombs(dst, &src, 1, 2, &state); // expected-warning{{5th function call argument points to an uninitialized value}} + wcsnrtombs(dst, &src, 1, 2, &state); // expected-warning{{5th function call argument points to an uninitialized value; Function 'wcsnrtombs' expects memory pointed to by this argument to be initialized}} } void uninit_mbrtoc16(const char *s) { char16_t pc16[10]; mbstate_t state; - mbrtoc16(pc16, s, 1, &state); // expected-warning{{4th function call argument points to an uninitialized value}} + mbrtoc16(pc16, s, 1, &state); // expected-warning{{4th function call argument points to an uninitialized value; Function 'mbrtoc16' expects memory pointed to by this argument to be initialized}} } void uninit_mktime() { struct tm time; - mktime(&time); // expected-warning{{1st function call argument points to an uninitialized value}} + mktime(&time); // expected-warning{{1st function call argument points to an uninitialized value; Function 'mktime' expects memory pointed to by this argument to be initialized}} } diff --git a/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp b/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp index bf84f8d88fe95..d0d4801031243 100644 --- a/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp +++ b/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp @@ -31,8 +31,8 @@ void uninit_val_p() { void uninit_val_r() { S s; - doStuffR(s); // initializedness-partial-warning{{1st function call argument references an uninitialized value (e.g., field: 'a')}} \ - // initializedness-complete-warning{{1st function call argument references an uninitialized value}} + doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., field: 'a'); This argument is const and may contain input data of the function}} \ + // initializedness-complete-warning{{1st function call argument is an uninitialized value; This argument is const and may contain input data of the function}} } S *uninit_new() { @@ -88,11 +88,11 @@ void uninit_static() { void uninit_val_partial_1() { S s; s.a = 1; - doStuffR(s); // initializedness-partial-warning{{1st function call argument references an uninitialized value (e.g., via the field chain: 'b.c')}} + doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., via the field chain: 'b.c'); This argument is const and may contain input data of the function}} } void uninit_val_partial_2() { S s; s.b.c = 1; - doStuffR(s); // initializedness-partial-warning{{1st function call argument references an uninitialized value (e.g., field: 'a')}} + doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., field: 'a'); This argument is const and may contain input data of the function}} } diff --git a/clang/test/Analysis/call-and-message.c b/clang/test/Analysis/call-and-message.c index 5f34635123426..0b81c86254f4b 100644 --- a/clang/test/Analysis/call-and-message.c +++ b/clang/test/Analysis/call-and-message.c @@ -21,7 +21,7 @@ void doStuff_pointerToConstInt(const int *u){}; void pointee_uninit(void) { int i; int *p = &i; - doStuff_pointerToConstInt(p); // expected-warning{{1st function call argument is a pointer to uninitialized value [core.CallAndMessage]}} + doStuff_pointerToConstInt(p); // expected-warning{{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function [core.CallAndMessage]}} } typedef struct S { @@ -33,12 +33,12 @@ void doStuff_pointerToConstStruct(const S *s){}; void pointee_uninit_struct(void) { S s; S *p = &s; - doStuff_pointerToConstStruct(p); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'a') [core.CallAndMessage]}} + doStuff_pointerToConstStruct(p); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'a'); This argument is const pointer and may contain input data of the function [core.CallAndMessage]}} } void pointee_uninit_struct_1(void) { S s; s.a = 2; - doStuff_pointerToConstStruct(&s); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'b') [core.CallAndMessage]}} + doStuff_pointerToConstStruct(&s); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'b'); This argument is const pointer and may contain input data of the function [core.CallAndMessage]}} } void pointee_uninit_struct_2(void) { S s = {}; diff --git a/clang/test/Analysis/exercise-ps.c b/clang/test/Analysis/exercise-ps.c index 21d97a364e190..4af5d04a224e7 100644 --- a/clang/test/Analysis/exercise-ps.c +++ b/clang/test/Analysis/exercise-ps.c @@ -31,7 +31,7 @@ static void f2(void *buf) { // what type of value do we expect. void f3(void *dest) { void *src = __builtin_alloca(5); - memcpy(dest, src, 1); // expected-warning{{2nd function call argument is a pointer to uninitialized value}} + memcpy(dest, src, 1); // expected-warning{{2nd function call argument points to an uninitialized value; Function 'memcpy' expects memory pointed to by this argument to be initialized}} } // Reproduce crash from GH#94496. When array is used as subcript to another array, CSA cannot model it diff --git a/clang/test/Analysis/uninit-const.c b/clang/test/Analysis/uninit-const.c index f8c89644dd306..8a2c9be585c8c 100644 --- a/clang/test/Analysis/uninit-const.c +++ b/clang/test/Analysis/uninit-const.c @@ -30,16 +30,16 @@ void doStuff_variadic(const int *u, ...){}; void f_1(void) { int t; // expected-note {{'t' declared without an initial value}} int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } void f_1_1(void) { int t; // expected-note {{'t' declared without an initial value}} int *tp1 = &t; // expected-note {{'tp1' initialized here}} int *tp2 = tp1; // expected-note {{'tp2' initialized to the value of 'tp1'}} - doStuff_pointerToConstInt(tp2); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp2); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } @@ -54,8 +54,8 @@ void f_2(void) { // expected-note@-2{{Returning from 'f_2_sub'}} // expected-note@-3{{'p' initialized here}} int *tp = p; // expected-note {{'tp' initialized to the value of 'p'}} - doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } int z; @@ -71,14 +71,14 @@ void f_4(void) { void f_5(void) { int ta[5]; // expected-note {{'ta' declared without an initial value}} int *tp = ta; // expected-note {{'tp' initialized here}} - doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } void f_5_1(void) { int ta[5]; // expected-note {{'ta' declared without an initial value}} - doStuff_pointerToConstInt(ta); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(ta); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } void f_6(void) { @@ -108,20 +108,20 @@ void f_8(void) { void f_9(void) { int a[6]; // expected-note {{'a' declared without an initial value}} int const *ptau = a; // expected-note {{'ptau' initialized here}} - doStuff_arrayOfConstInt(ptau); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_arrayOfConstInt(ptau); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } void f_10(void) { int a[6]; // expected-note {{'a' declared without an initial value}} - doStuff_arrayOfConstInt(a); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_arrayOfConstInt(a); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } void f_11(void) { int t[10]; //expected-note {{'t' declared without an initial value}} - doStuff_constStaticSizedArray(t); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_constStaticSizedArray(t); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } void f_12(void) { @@ -161,8 +161,8 @@ int f_malloc_1(void) { ptr = (int *)malloc(sizeof(int)); // expected-note {{Value assigned to 'ptr'}} - doStuff_pointerToConstInt(ptr); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(ptr); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} free(ptr); return 0; } @@ -183,16 +183,16 @@ void f_variadic_unp_unv(void) { int t; // expected-note {{'t' declared without an initial value}} int v; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,v); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,v); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } // uninit pointer, init val void f_variadic_unp_inv(void) { int t; // expected-note {{'t' declared without an initial value}} int v = 3; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,v); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,v); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } // init pointer, uninit val @@ -227,8 +227,8 @@ void f_variadic_unp_inp(void) { int u=3; int *vp = &u ; int *tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,vp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,vp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } //init pointer, uninit pointer @@ -246,6 +246,6 @@ void f_variadic_unp_unp(void) { int u; int *vp = &u ; int *tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,vp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,vp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} } diff --git a/clang/test/Analysis/uninit-const.cpp b/clang/test/Analysis/uninit-const.cpp index 2ad833b3613fb..d559487d9cba8 100644 --- a/clang/test/Analysis/uninit-const.cpp +++ b/clang/test/Analysis/uninit-const.cpp @@ -38,8 +38,8 @@ int f9(void) { // a pointer to an uninitialized value is stored. ptr = new int; // expected-note{{Storing uninitialized value}} // expected-note@-1{{Value assigned to 'ptr'}} - doStuff_uninit(ptr); // expected-warning{{1st function call argument is a pointer to uninitialized value [core.CallAndMessage]}} - // expected-note@-1{{1st function call argument is a pointer to uninitialized value}} + doStuff_uninit(ptr); // expected-warning{{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function [core.CallAndMessage]}} + // expected-note@-1{{1st function call argument points to an uninitialized value;}} delete ptr; return 0; } @@ -111,8 +111,8 @@ void f6(void) { void f5(void) { int t; // expected-note {{'t' declared without an initial value}} int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_uninit(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_uninit(tp); // expected-warning {{1st function call argument points to an uninitialized value;}} + // expected-note@-1 {{1st function call argument points to an uninitialized value;}} } @@ -139,6 +139,6 @@ void f1(void) { void f_uninit(void) { int x; // expected-note {{'x' declared without an initial value}} - doStuff_uninit(&x); // expected-warning {{1st function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} + doStuff_uninit(&x); // expected-warning {{1st function call argument points to an uninitialized value;}} + // expected-note@-1 {{1st function call argument points to an uninitialized value;}} } From a02422bc2f4fe6313230838b31d9521a7d4441da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= <[email protected]> Date: Fri, 31 Jul 2026 17:58:34 +0200 Subject: [PATCH 2/2] changed second message part to lower case --- .../Checkers/CallAndMessageChecker.cpp | 4 +- ...ll-and-message-argpointeeinitializedness.c | 8 +-- ...-and-message-argpointeeinitializedness.cpp | 8 +-- clang/test/Analysis/call-and-message.c | 6 +-- clang/test/Analysis/exercise-ps.c | 2 +- clang/test/Analysis/uninit-const.c | 52 +++++++++---------- clang/test/Analysis/uninit-const.cpp | 2 +- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp index 92ded1ff8e639..3997da0ba5dc5 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -325,12 +325,12 @@ bool CallAndMessageChecker::uninitRefOrPointer(CheckerContext &C, SVal V, &Call](bool ArgIsStruct) -> std::string { if (PointeeT.isConstQualified()) return llvm::formatv( - "This argument is const{0} and {1} input data of the function", + "this argument is const{0} and {1} input data of the function", ParamT->isPointerType() ? " pointer" : "", ArgIsStruct ? "may contain" : "is likely"); else return llvm::formatv( - "Function '{0}' expects {1}this argument to be initialized", + "function '{0}' expects {1}this argument to be initialized", cast<NamedDecl>(Call.getDecl())->getNameAsString(), ParamT->isPointerType() ? "memory pointed to by " : ""); }; diff --git a/clang/test/Analysis/call-and-message-argpointeeinitializedness.c b/clang/test/Analysis/call-and-message-argpointeeinitializedness.c index 5da7641e3b6d1..bee3aaf8e2b69 100644 --- a/clang/test/Analysis/call-and-message-argpointeeinitializedness.c +++ b/clang/test/Analysis/call-and-message-argpointeeinitializedness.c @@ -30,7 +30,7 @@ extern time_t mktime(struct tm *timeptr); void uninit_mbrlen(const char *mbs) { mbstate_t state; - mbrlen(mbs, 1, &state); // expected-warning{{3rd function call argument points to an uninitialized value; Function 'mbrlen' expects memory pointed to by this argument to be initialized}} + mbrlen(mbs, 1, &state); // expected-warning{{3rd function call argument points to an uninitialized value; function 'mbrlen' expects memory pointed to by this argument to be initialized}} } void init_mbrlen(const char *mbs) { @@ -42,16 +42,16 @@ void init_mbrlen(const char *mbs) { void uninit_wcsnrtombs(const wchar_t *src) { char dst[10]; mbstate_t state; - wcsnrtombs(dst, &src, 1, 2, &state); // expected-warning{{5th function call argument points to an uninitialized value; Function 'wcsnrtombs' expects memory pointed to by this argument to be initialized}} + wcsnrtombs(dst, &src, 1, 2, &state); // expected-warning{{5th function call argument points to an uninitialized value; function 'wcsnrtombs' expects memory pointed to by this argument to be initialized}} } void uninit_mbrtoc16(const char *s) { char16_t pc16[10]; mbstate_t state; - mbrtoc16(pc16, s, 1, &state); // expected-warning{{4th function call argument points to an uninitialized value; Function 'mbrtoc16' expects memory pointed to by this argument to be initialized}} + mbrtoc16(pc16, s, 1, &state); // expected-warning{{4th function call argument points to an uninitialized value; function 'mbrtoc16' expects memory pointed to by this argument to be initialized}} } void uninit_mktime() { struct tm time; - mktime(&time); // expected-warning{{1st function call argument points to an uninitialized value; Function 'mktime' expects memory pointed to by this argument to be initialized}} + mktime(&time); // expected-warning{{1st function call argument points to an uninitialized value; function 'mktime' expects memory pointed to by this argument to be initialized}} } diff --git a/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp b/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp index d0d4801031243..388f505f3155e 100644 --- a/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp +++ b/clang/test/Analysis/call-and-message-argpointeeinitializedness.cpp @@ -31,8 +31,8 @@ void uninit_val_p() { void uninit_val_r() { S s; - doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., field: 'a'); This argument is const and may contain input data of the function}} \ - // initializedness-complete-warning{{1st function call argument is an uninitialized value; This argument is const and may contain input data of the function}} + doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., field: 'a'); this argument is const and may contain input data of the function}} \ + // initializedness-complete-warning{{1st function call argument is an uninitialized value; this argument is const and may contain input data of the function}} } S *uninit_new() { @@ -88,11 +88,11 @@ void uninit_static() { void uninit_val_partial_1() { S s; s.a = 1; - doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., via the field chain: 'b.c'); This argument is const and may contain input data of the function}} + doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., via the field chain: 'b.c'); this argument is const and may contain input data of the function}} } void uninit_val_partial_2() { S s; s.b.c = 1; - doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., field: 'a'); This argument is const and may contain input data of the function}} + doStuffR(s); // initializedness-partial-warning{{1st function call argument is an uninitialized value (e.g., field: 'a'); this argument is const and may contain input data of the function}} } diff --git a/clang/test/Analysis/call-and-message.c b/clang/test/Analysis/call-and-message.c index 0b81c86254f4b..f1ba4848b75ea 100644 --- a/clang/test/Analysis/call-and-message.c +++ b/clang/test/Analysis/call-and-message.c @@ -21,7 +21,7 @@ void doStuff_pointerToConstInt(const int *u){}; void pointee_uninit(void) { int i; int *p = &i; - doStuff_pointerToConstInt(p); // expected-warning{{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function [core.CallAndMessage]}} + doStuff_pointerToConstInt(p); // expected-warning{{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function [core.CallAndMessage]}} } typedef struct S { @@ -33,12 +33,12 @@ void doStuff_pointerToConstStruct(const S *s){}; void pointee_uninit_struct(void) { S s; S *p = &s; - doStuff_pointerToConstStruct(p); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'a'); This argument is const pointer and may contain input data of the function [core.CallAndMessage]}} + doStuff_pointerToConstStruct(p); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'a'); this argument is const pointer and may contain input data of the function [core.CallAndMessage]}} } void pointee_uninit_struct_1(void) { S s; s.a = 2; - doStuff_pointerToConstStruct(&s); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'b'); This argument is const pointer and may contain input data of the function [core.CallAndMessage]}} + doStuff_pointerToConstStruct(&s); // expected-warning{{1st function call argument points to an uninitialized value (e.g., field: 'b'); this argument is const pointer and may contain input data of the function [core.CallAndMessage]}} } void pointee_uninit_struct_2(void) { S s = {}; diff --git a/clang/test/Analysis/exercise-ps.c b/clang/test/Analysis/exercise-ps.c index 4af5d04a224e7..a2cb8c5295e0f 100644 --- a/clang/test/Analysis/exercise-ps.c +++ b/clang/test/Analysis/exercise-ps.c @@ -31,7 +31,7 @@ static void f2(void *buf) { // what type of value do we expect. void f3(void *dest) { void *src = __builtin_alloca(5); - memcpy(dest, src, 1); // expected-warning{{2nd function call argument points to an uninitialized value; Function 'memcpy' expects memory pointed to by this argument to be initialized}} + memcpy(dest, src, 1); // expected-warning{{2nd function call argument points to an uninitialized value; function 'memcpy' expects memory pointed to by this argument to be initialized}} } // Reproduce crash from GH#94496. When array is used as subcript to another array, CSA cannot model it diff --git a/clang/test/Analysis/uninit-const.c b/clang/test/Analysis/uninit-const.c index 8a2c9be585c8c..beb7a3ff762f4 100644 --- a/clang/test/Analysis/uninit-const.c +++ b/clang/test/Analysis/uninit-const.c @@ -30,16 +30,16 @@ void doStuff_variadic(const int *u, ...){}; void f_1(void) { int t; // expected-note {{'t' declared without an initial value}} int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } void f_1_1(void) { int t; // expected-note {{'t' declared without an initial value}} int *tp1 = &t; // expected-note {{'tp1' initialized here}} int *tp2 = tp1; // expected-note {{'tp2' initialized to the value of 'tp1'}} - doStuff_pointerToConstInt(tp2); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_pointerToConstInt(tp2); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } @@ -54,8 +54,8 @@ void f_2(void) { // expected-note@-2{{Returning from 'f_2_sub'}} // expected-note@-3{{'p' initialized here}} int *tp = p; // expected-note {{'tp' initialized to the value of 'p'}} - doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } int z; @@ -71,14 +71,14 @@ void f_4(void) { void f_5(void) { int ta[5]; // expected-note {{'ta' declared without an initial value}} int *tp = ta; // expected-note {{'tp' initialized here}} - doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } void f_5_1(void) { int ta[5]; // expected-note {{'ta' declared without an initial value}} - doStuff_pointerToConstInt(ta); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_pointerToConstInt(ta); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } void f_6(void) { @@ -108,20 +108,20 @@ void f_8(void) { void f_9(void) { int a[6]; // expected-note {{'a' declared without an initial value}} int const *ptau = a; // expected-note {{'ptau' initialized here}} - doStuff_arrayOfConstInt(ptau); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_arrayOfConstInt(ptau); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } void f_10(void) { int a[6]; // expected-note {{'a' declared without an initial value}} - doStuff_arrayOfConstInt(a); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_arrayOfConstInt(a); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } void f_11(void) { int t[10]; //expected-note {{'t' declared without an initial value}} - doStuff_constStaticSizedArray(t); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_constStaticSizedArray(t); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } void f_12(void) { @@ -161,8 +161,8 @@ int f_malloc_1(void) { ptr = (int *)malloc(sizeof(int)); // expected-note {{Value assigned to 'ptr'}} - doStuff_pointerToConstInt(ptr); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_pointerToConstInt(ptr); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} free(ptr); return 0; } @@ -183,16 +183,16 @@ void f_variadic_unp_unv(void) { int t; // expected-note {{'t' declared without an initial value}} int v; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,v); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_variadic(tp,v); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } // uninit pointer, init val void f_variadic_unp_inv(void) { int t; // expected-note {{'t' declared without an initial value}} int v = 3; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,v); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_variadic(tp,v); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } // init pointer, uninit val @@ -227,8 +227,8 @@ void f_variadic_unp_inp(void) { int u=3; int *vp = &u ; int *tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,vp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_variadic(tp,vp); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } //init pointer, uninit pointer @@ -246,6 +246,6 @@ void f_variadic_unp_unp(void) { int u; int *vp = &u ; int *tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,vp); // expected-warning {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} - // expected-note@-1 {{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function}} + doStuff_variadic(tp,vp); // expected-warning {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} + // expected-note@-1 {{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function}} } diff --git a/clang/test/Analysis/uninit-const.cpp b/clang/test/Analysis/uninit-const.cpp index d559487d9cba8..417e1f16b707d 100644 --- a/clang/test/Analysis/uninit-const.cpp +++ b/clang/test/Analysis/uninit-const.cpp @@ -38,7 +38,7 @@ int f9(void) { // a pointer to an uninitialized value is stored. ptr = new int; // expected-note{{Storing uninitialized value}} // expected-note@-1{{Value assigned to 'ptr'}} - doStuff_uninit(ptr); // expected-warning{{1st function call argument points to an uninitialized value; This argument is const pointer and is likely input data of the function [core.CallAndMessage]}} + doStuff_uninit(ptr); // expected-warning{{1st function call argument points to an uninitialized value; this argument is const pointer and is likely input data of the function [core.CallAndMessage]}} // expected-note@-1{{1st function call argument points to an uninitialized value;}} delete ptr; return 0; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
