[analyzer] Update the undefined assignment checker diagnostics to not use the term 'garbage' (#126596)

A clang user pointed out that messages for the static analyzer undefined
assignment checker use the term ‘garbage’, which might have a negative
connotation to some users. This change updates the messages to use the
term ‘uninitialized’. This is the usual reason why a value is undefined
in the static analyzer and describes the logical error that a programmer
should take action to fix.

Out-of-bounds reads can also produce undefined values in the static
analyzer. The right long-term design is to have to the array bounds
checker cover out-of-bounds reads, so we do not cover that case in the
updated messages. The recent improvements to the array bounds checker
make it a candidate to add to the core set of checkers.

rdar://133418644
This commit is contained in:
David Tarditi
2025-02-26 13:57:33 +01:00
committed by GitHub
parent a00586171c
commit 8138d85f63
30 changed files with 139 additions and 140 deletions

View File

@@ -23,7 +23,7 @@ using namespace ento;
namespace {
class UndefinedAssignmentChecker
: public Checker<check::Bind> {
const BugType BT{this, "Assigned value is garbage or undefined"};
const BugType BT{this, "Assigned value is uninitialized"};
public:
void checkBind(SVal location, SVal val, const Stmt *S,
@@ -57,8 +57,7 @@ void UndefinedAssignmentChecker::checkBind(SVal location, SVal val,
while (StoreE) {
if (const UnaryOperator *U = dyn_cast<UnaryOperator>(StoreE)) {
OS << "The expression is an uninitialized value. "
"The computed value will also be garbage";
OS << "The expression uses uninitialized memory";
ex = U->getSubExpr();
break;
@@ -67,8 +66,8 @@ void UndefinedAssignmentChecker::checkBind(SVal location, SVal val,
if (const BinaryOperator *B = dyn_cast<BinaryOperator>(StoreE)) {
if (B->isCompoundAssignmentOp()) {
if (C.getSVal(B->getLHS()).isUndef()) {
OS << "The left expression of the compound assignment is an "
"uninitialized value. The computed value will also be garbage";
OS << "The left expression of the compound assignment uses "
<< "uninitialized memory";
ex = B->getLHS();
break;
}
@@ -89,7 +88,7 @@ void UndefinedAssignmentChecker::checkBind(SVal location, SVal val,
for (auto *I : CD->inits()) {
if (I->getInit()->IgnoreImpCasts() == StoreE) {
OS << "Value assigned to field '" << I->getMember()->getName()
<< "' in implicit constructor is garbage or undefined";
<< "' in implicit constructor is uninitialized";
break;
}
}

View File

@@ -2578,17 +2578,17 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage</string>
<string>The left expression of the compound assignment uses uninitialized memory</string>
<key>message</key>
<string>The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage</string>
<string>The left expression of the compound assignment uses uninitialized memory</string>
</dict>
</array>
<key>description</key><string>The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage</string>
<key>description</key><string>The left expression of the compound assignment uses uninitialized memory</string>
<key>category</key><string>Logic error</string>
<key>type</key><string>Assigned value is garbage or undefined</string>
<key>type</key><string>Assigned value is uninitialized</string>
<key>check_name</key><string>core.uninitialized.Assign</string>
<!-- This hash is experimental and going to change! -->
<key>issue_hash_content_of_line_in_context</key><string>025372576cd3ba6716044f93a51c978c</string>
<key>issue_hash_content_of_line_in_context</key><string>324827600c298776167cd9562f71bda6</string>
<key>issue_context_kind</key><string>function</string>
<key>issue_context</key><string>test_objc_fast_enumeration_2</string>
<key>issue_hash_function_offset</key><string>5</string>

View File

@@ -5864,17 +5864,17 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage</string>
<string>The left expression of the compound assignment uses uninitialized memory</string>
<key>message</key>
<string>The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage</string>
<string>The left expression of the compound assignment uses uninitialized memory</string>
</dict>
</array>
<key>description</key><string>The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage</string>
<key>description</key><string>The left expression of the compound assignment uses uninitialized memory</string>
<key>category</key><string>Logic error</string>
<key>type</key><string>Assigned value is garbage or undefined</string>
<key>type</key><string>Assigned value is uninitialized</string>
<key>check_name</key><string>core.uninitialized.Assign</string>
<!-- This hash is experimental and going to change! -->
<key>issue_hash_content_of_line_in_context</key><string>21c774309bdfd487c3d09a61a671bbcc</string>
<key>issue_hash_content_of_line_in_context</key><string>faa8858031ed123ff98cc23cf14d462f</string>
<key>issue_context_kind</key><string>function</string>
<key>issue_context</key><string>test_loop_fast_enumeration</string>
<key>issue_hash_function_offset</key><string>5</string>

View File

@@ -14,7 +14,7 @@ bool bar(S);
void foo() {
int x;
if (true && bar(S()))
++x; // expected-warning{{The expression is an uninitialized value. The computed value will also be garbage}}
++x; // expected-warning{{The expression uses uninitialized memory}}
}
// 256 copies of the same run-line to make it crash more often when it breaks.

View File

@@ -23,6 +23,6 @@ int main() {
int x;
int y = x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
(void)y;
}

View File

@@ -19,7 +19,7 @@ void array_uninit() {
auto [a, b, c, d, e] = arr;
int x = e; // expected-warning{{Assigned value is garbage or undefined}}
int x = e; // expected-warning{{Assigned value is uninitialized}}
}
void lambda_init() {
@@ -168,7 +168,7 @@ struct S3_duplicate {
void array_uninit_non_pod() {
S3 arr[1];
auto [a] = arr; // expected-warning@159{{ in implicit constructor is garbage or undefined }}
auto [a] = arr; // expected-warning@159{{ in implicit constructor is uninitialized}}
}
void lambda_init_non_pod() {
@@ -191,7 +191,7 @@ void lambda_init_non_pod() {
void lambda_uninit_non_pod() {
S3_duplicate arr[4];
int l = [arr] { return arr[3].i; }(); // expected-warning@164{{ in implicit constructor is garbage or undefined }}
int l = [arr] { return arr[3].i; }(); // expected-warning@164{{ in implicit constructor is uninitialized }}
}
// If this struct is being copy/move constructed by the implicit ctors, ArrayInitLoopExpr

View File

@@ -20,7 +20,7 @@ void array_struct_bitfield_1() {
int array_struct_bitfield_2() {
BITFIELD_CAST ff = {0};
BITFIELD_CAST *pff = &ff;
int a = *((int *)pff + 2); // expected-warning{{Assigned value is garbage or undefined [core.uninitialized.Assign]}}
int a = *((int *)pff + 2); // expected-warning{{Assigned value is uninitialized [core.uninitialized.Assign]}}
return a;
}

View File

@@ -23,8 +23,8 @@ void test_overflow_note(int a, int b)
if (__builtin_add_overflow(a, b, &res)) { // expected-note {{Assuming overflow}}
// expected-note@-1 {{Taking true branch}}
int var = res; // expected-warning{{Assigned value is garbage or undefined}}
// expected-note@-1 {{Assigned value is garbage or undefined}}
int var = res; // expected-warning{{Assigned value is uninitialized}}
// expected-note@-1 {{Assigned value is uninitialized}}
return;
}
}

View File

@@ -197,7 +197,7 @@ int testStdCtorDoesNotInvalidateParentObject() {
int testStdCtorDoesNotInvalidateParentObjectSwapped() {
StdWrappingOpaqueSwapped obj;
int x = obj.o.nested_member; // no-garbage: std::Opaque::ctor might initialized this
int y = obj.uninit; // expected-warning {{Assigned value is garbage or undefined}}
int y = obj.uninit; // expected-warning {{Assigned value is uninitialized}}
return x + y;
}
@@ -277,6 +277,6 @@ struct StdWrappingFancyOpaque {
int testNestedStdNamespacesAndRecords() {
StdWrappingFancyOpaque obj;
int x = obj.o.nested_member; // no-garbage: ctor
int y = obj.uninit; // expected-warning {{Assigned value is garbage or undefined}}
int y = obj.uninit; // expected-warning {{Assigned value is uninitialized}}
return x + y;
}

View File

@@ -12,19 +12,19 @@ struct s {
void a1(void) {
s arr[3];
int x = arr[0].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
void a2(void) {
s arr[3];
int x = arr[1].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
void a3(void) {
s arr[3];
int x = arr[2].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
struct s2 {
@@ -37,7 +37,7 @@ void b1(void) {
clang_analyzer_eval(arr[0].y == 2); // expected-warning{{TRUE}}
int x = arr[0].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
void b2(void) {
@@ -45,7 +45,7 @@ void b2(void) {
clang_analyzer_eval(arr[1].y == 2); // expected-warning{{TRUE}}
int x = arr[1].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
void b3(void) {
@@ -53,7 +53,7 @@ void b3(void) {
clang_analyzer_eval(arr[2].y == 2); // expected-warning{{TRUE}}
int x = arr[2].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
void c1(void) {
@@ -70,7 +70,7 @@ void c1(void) {
clang_analyzer_eval(arr[1].y == 2); // expected-warning{{TRUE}}
int x = arr[1].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
}
@@ -100,7 +100,7 @@ void e1(void) {
clang_analyzer_eval(arr[1].arr[1].y == 2); // expected-warning{{TRUE}}
int x = arr[1].sarr[1].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
void f1(void) {
@@ -108,7 +108,7 @@ void f1(void) {
clang_analyzer_eval(arr[1][1].y == 2); // expected-warning{{TRUE}}
int x = arr[1][1].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
struct s5 {
@@ -168,14 +168,14 @@ void h2(void) {
s a[2][2], b[2][2];
int x = a[1][1].x;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
void h3(void) {
s a[2][2], b[2][2];
int x = b[1][1].y;
// expected-warning@-1{{Assigned value is garbage or undefined}}
// expected-warning@-1{{Assigned value is uninitialized}}
}
struct Base {

View File

@@ -145,24 +145,24 @@ namespace PODUninitialized {
NonPOD() {}
NonPOD(const NonPOD &Other)
: x(Other.x), y(Other.y) // expected-warning {{undefined}}
: x(Other.x), y(Other.y) // expected-warning {{uninitialized}}
{
}
NonPOD(NonPOD &&Other)
: x(Other.x), y(Other.y) // expected-warning {{undefined}}
: x(Other.x), y(Other.y) // expected-warning {{uninitialized}}
{
}
NonPOD &operator=(const NonPOD &Other)
{
x = Other.x;
y = Other.y; // expected-warning {{undefined}}
y = Other.y; // expected-warning {{uninitialized}}
return *this;
}
NonPOD &operator=(NonPOD &&Other)
{
x = Other.x;
y = Other.y; // expected-warning {{undefined}}
y = Other.y; // expected-warning {{uninitialized}}
return *this;
}
};
@@ -175,23 +175,23 @@ namespace PODUninitialized {
Inner() {}
Inner(const Inner &Other)
: x(Other.x), y(Other.y) // expected-warning {{undefined}}
: x(Other.x), y(Other.y) // expected-warning {{uninitialized}}
{
}
Inner(Inner &&Other)
: x(Other.x), y(Other.y) // expected-warning {{undefined}}
: x(Other.x), y(Other.y) // expected-warning {{uninitialized}}
{
}
Inner &operator=(const Inner &Other)
{
x = Other.x; // expected-warning {{undefined}}
x = Other.x; // expected-warning {{uninitialized}}
y = Other.y;
return *this;
}
Inner &operator=(Inner &&Other)
{
x = Other.x; // expected-warning {{undefined}}
x = Other.x; // expected-warning {{uninitialized}}
y = Other.y;
return *this;
}

View File

@@ -47,8 +47,8 @@ int initFromBlock(void) {
int p; // expected-note{{'p' declared without an initial value}}
initializer1(&p, 0); // expected-note{{Calling 'initializer1'}}
// expected-note@-1{{Returning from 'initializer1'}}
z = p; // expected-warning{{Assigned value is garbage or undefined}}
// expected-note@-1{{Assigned value is garbage or undefined}}
z = p; // expected-warning{{Assigned value is uninitialized}}
// expected-note@-1{{Assigned value is uninitialized}}
}();
return z;
}

View File

@@ -113,9 +113,9 @@ void random_access_read1(int index) {
case 0:
// c[0] is not mutated by fread.
if (success) {
char p = c[0]; // expected-warning {{Assigned value is garbage or undefined}} We kept the first byte intact.
char p = c[0]; // expected-warning {{Assigned value is uninitialized}} We kept the first byte intact.
} else {
char p = c[0]; // expected-warning {{Assigned value is garbage or undefined}} We kept the first byte intact.
char p = c[0]; // expected-warning {{Assigned value is uninitialized}} We kept the first byte intact.
}
break;
@@ -147,9 +147,9 @@ void random_access_read1(int index) {
case 3:
// c[3] is not mutated by fread.
if (success) {
long p = c[3]; // expected-warning {{Assigned value is garbage or undefined}}
long p = c[3]; // expected-warning {{Assigned value is uninitialized}}
} else {
long p = c[3]; // expected-warning {{Assigned value is garbage or undefined}}
long p = c[3]; // expected-warning {{Assigned value is uninitialized}}
}
break;
}
@@ -169,10 +169,10 @@ void random_access_read2(int b) {
clang_analyzer_isTainted(p); // expected-warning {{YES}}
clang_analyzer_dump(p); // expected-warning {{conj_}}
} else {
int p = buffer[0]; // expected-warning {{Assigned value is garbage or undefined}}
int p = buffer[0]; // expected-warning {{Assigned value is uninitialized}}
}
} else {
int p = buffer[0]; // expected-warning {{Assigned value is garbage or undefined}}
int p = buffer[0]; // expected-warning {{Assigned value is uninitialized}}
}
fclose(fp);
}
@@ -283,9 +283,9 @@ void compound_read2(void) {
if (fp) {
struct S s; // s.a is not touched by fread.
if (1 == fread(&s.b, sizeof(s.b), 1, fp)) {
long p = s.a; // expected-warning {{Assigned value is garbage or undefined}}
long p = s.a; // expected-warning {{Assigned value is uninitialized}}
} else {
long p = s.a; // expected-warning {{Assigned value is garbage or undefined}}
long p = s.a; // expected-warning {{Assigned value is uninitialized}}
}
fclose(fp);
}
@@ -296,9 +296,9 @@ void var_read(void) {
if (fp) {
int a, b; // 'a' is not touched by fread.
if (1 == fread(&b, sizeof(b), 1, fp)) {
long p = a; // expected-warning{{Assigned value is garbage or undefined}}
long p = a; // expected-warning{{Assigned value is uninitialized}}
} else {
long p = a; // expected-warning{{Assigned value is garbage or undefined}}
long p = a; // expected-warning{{Assigned value is uninitialized}}
}
fclose(fp);
}

View File

@@ -9,8 +9,8 @@ public:
// Warning is in a weird position because the body of the constructor is
// missing. Specify which field is being assigned.
class C { // expected-warning{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
// expected-note@-1{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
class C { // expected-warning{{Value assigned to field 'y' in implicit constructor is uninitialized}}
// expected-note@-1{{Value assigned to field 'y' in implicit constructor is uninitialized}}
int x, y;
S s;
@@ -34,8 +34,8 @@ public:
// It is not necessary to specify which field is being assigned to.
C(const C &c):
x(c.x),
y(c.y) // expected-warning{{Assigned value is garbage or undefined}}
// expected-note@-1{{Assigned value is garbage or undefined}}
y(c.y) // expected-warning{{Assigned value is uninitialized}}
// expected-note@-1{{Assigned value is uninitialized}}
{}
};
@@ -53,8 +53,8 @@ public:
S(const S &) {}
};
class C { // expected-warning{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
// expected-note@-1{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
class C { // expected-warning{{Value assigned to field 'y' in implicit constructor is uninitialized}}
// expected-note@-1{{Value assigned to field 'y' in implicit constructor is uninitialized}}
int x, y;
S s;

View File

@@ -49,13 +49,13 @@ void glob_array_index2(void) {
void glob_invalid_index1(void) {
int x = -42;
int res = glob_arr1[x]; // expected-warning{{garbage or undefined}}
int res = glob_arr1[x]; // expected-warning{{uninitialized}}
}
void glob_invalid_index2(void) {
const int *ptr = glob_arr1;
int x = 42;
int res = ptr[x]; // expected-warning{{garbage or undefined}}
int res = ptr[x]; // expected-warning{{uninitialized}}
}
const int glob_arr2[3][3] = {[0][0] = 1, [1][1] = 5, [2][0] = 7};
@@ -81,12 +81,12 @@ void negative_index(void) {
void glob_invalid_index3(void) {
int x = -1, y = -1;
int res = glob_arr2[x][y]; // expected-warning{{garbage or undefined}}
int res = glob_arr2[x][y]; // expected-warning{{uninitialized}}
}
void glob_invalid_index4(void) {
int x = 3, y = 2;
int res = glob_arr2[x][y]; // expected-warning{{garbage or undefined}}
int res = glob_arr2[x][y]; // expected-warning{{uninitialized}}
}
const int glob_arr_no_init[10];
@@ -106,12 +106,12 @@ void glob_arr_index5(void) {
void glob_invalid_index5(void) {
int x = 42;
int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
int res = glob_arr3[x]; // expected-warning{{uninitialized}}
}
void glob_invalid_index6(void) {
int x = -42;
int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
int res = glob_arr3[x]; // expected-warning{{uninitialized}}
}
const int glob_arr4[]; // IncompleteArrayType
@@ -126,10 +126,10 @@ void glob_arr_index6(void) {
void glob_invalid_index7(void) {
int x = 42;
int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
int res = glob_arr4[x]; // expected-warning{{uninitialized}}
}
void glob_invalid_index8(void) {
int x = -42;
int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
int res = glob_arr4[x]; // expected-warning{{uninitialized}}
}

View File

@@ -24,7 +24,7 @@ void glob_array_index1() {
void glob_invalid_index1() {
const int *ptr = glob_arr1;
int idx = -42;
auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
auto x = ptr[idx]; // expected-warning{{uninitialized}}
}
void glob_symbolic_index1(int idx) {
@@ -44,13 +44,13 @@ void glob_ptr_index1() {
void glob_invalid_index2() {
const int *ptr = glob_arr2;
int idx = 42;
auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
auto x = ptr[idx]; // expected-warning{{uninitialized}}
}
const float glob_arr3[] = {
0.0000, 0.0235, 0.0470, 0.0706, 0.0941, 0.1176};
float no_warn_garbage_value() {
return glob_arr3[0]; // no-warning (garbage or undefined)
return glob_arr3[0]; // no-warning (not meaningful)
}
int const glob_arr4[4][2] = {};
@@ -62,13 +62,13 @@ void glob_array_index2() {
void glob_invalid_index3() {
int idx = -42;
auto x = glob_arr4[1][idx]; // expected-warning{{garbage or undefined}}
auto x = glob_arr4[1][idx]; // expected-warning{{uninitialized}}
}
void glob_invalid_index4() {
const int *ptr = glob_arr4[1];
int idx = -42;
auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
auto x = ptr[idx]; // expected-warning{{uninitialized}}
}
int const glob_arr5[4][2] = {{1}, 3, 4, 5};
@@ -94,13 +94,13 @@ void glob_ptr_index2() {
void glob_invalid_index5() {
int idx = -42;
auto x = glob_arr5[1][idx]; // expected-warning{{garbage or undefined}}
auto x = glob_arr5[1][idx]; // expected-warning{{uninitialized}}
}
void glob_invalid_index6() {
int const *ptr = &glob_arr5[1][0];
int idx = 42;
auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
auto x = ptr[idx]; // expected-warning{{uninitialized}}
}
extern const int glob_arr_no_init[10];
@@ -138,13 +138,13 @@ void glob_ptr_index3() {
void glob_invalid_index7() {
int idx = -42;
auto x = glob_arr6[idx]; // expected-warning{{garbage or undefined}}
auto x = glob_arr6[idx]; // expected-warning{{uninitialized}}
}
void glob_invalid_index8() {
const char *ptr = glob_arr6;
int idx = 42;
auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
auto x = ptr[idx]; // expected-warning{{uninitialized}}
}
char const glob_arr7[5] = {"123"};
@@ -158,13 +158,13 @@ void glob_array_index6() {
void glob_invalid_index9() {
int idx = -42;
auto x = glob_arr7[idx]; // expected-warning{{garbage or undefined}}
auto x = glob_arr7[idx]; // expected-warning{{uninitialized}}
}
void glob_invalid_index10() {
const char *ptr = glob_arr7;
int idx = 42;
auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
auto x = ptr[idx]; // expected-warning{{uninitialized}}
}
char const *const glob_ptr8 = "123";
@@ -180,12 +180,12 @@ void glob_ptr_index4() {
void glob_invalid_index11() {
int idx = -42;
auto x = glob_ptr8[idx]; // expected-warning{{garbage or undefined}}
auto x = glob_ptr8[idx]; // expected-warning{{uninitialized}}
}
void glob_invalid_index12() {
int idx = 42;
// FIXME: Should warn {{garbage or undefined}}
// FIXME: Should warn {{uninitialized}}
// We should take into account a declaration in which the literal is used.
auto x = glob_ptr8[idx]; // no-warning
}

View File

@@ -40,7 +40,7 @@ void test_nonzero(void) {
return;
for (i = 0; i < 10; i++) {
t = list[i]; // expected-warning{{undefined}}
t = list[i]; // expected-warning{{uninitialized}}
foo(t);
}
kfree(list);
@@ -55,7 +55,7 @@ void test_indeterminate(int flags) {
return;
for (i = 0; i < 10; i++) {
t = list[i]; // expected-warning{{undefined}}
t = list[i]; // expected-warning{{uninitialized}}
foo(t);
}
kfree(list);
@@ -93,7 +93,7 @@ void test_3arg_malloc_nonzero(struct malloc_type *mtp) {
return;
for (i = 0; i < 10; i++) {
t = list[i]; // expected-warning{{undefined}}
t = list[i]; // expected-warning{{uninitialized}}
foo(t);
}
kfree(list);
@@ -108,7 +108,7 @@ void test_3arg_malloc_indeterminate(struct malloc_type *mtp, int flags) {
return;
for (i = 0; i < 10; i++) {
t = list[i]; // expected-warning{{undefined}}
t = list[i]; // expected-warning{{uninitialized}}
foo(t);
}
kfree(list);

View File

@@ -244,7 +244,7 @@ void mallocCastToFP(void) {
// This tests that malloc() buffers are undefined by default
char mallocGarbage (void) {
char *buf = malloc(2);
char result = buf[1]; // expected-warning{{undefined}}
char result = buf[1]; // expected-warning{{uninitialized}}
free(buf);
return result;
}

View File

@@ -735,7 +735,7 @@ void mallocCastToFP(void) {
// This tests that 'malloc()' buffers are undefined by default
char mallocGarbage (void) {
char *buf = malloc(2);
char result = buf[1]; // expected-warning{{undefined}}
char result = buf[1]; // expected-warning{{uninitialized}}
free(buf);
return result;
}

View File

@@ -15,7 +15,7 @@ int rdar93730392(void) {
int extra = (2 + foo_rdar9373039 ("Clang") + ((4 - ((unsigned int) (2 + foo_rdar9373039 ("Clang")) % 4)) % 4)) + (2 + foo_rdar9373039 ("1.0") + ((4 - ((unsigned int) (2 + foo_rdar9373039 ("1.0")) % 4)) % 4)); // expected-warning {{never read}}
for (int i = 0 ; i < size_rdar9373039 ; ++i)
j += x; // expected-warning {{garbage}}
j += x; // expected-warning {{uninitialized}}
return j;
}
@@ -156,7 +156,7 @@ int rdar_12075238_(unsigned long count) {
// Test that we handle an uninitialized value within a logical expression.
void PR14635(int *p) {
int a = 0, b;
*p = a || b; // expected-warning {{Assigned value is garbage or undefined}}
*p = a || b; // expected-warning {{Assigned value is uninitialized}}
}
// Test handling floating point values with unary '!'.

View File

@@ -121,16 +121,16 @@ namespace SynthesizedAssignment {
void testNoWarning() {
B v, u;
u = v; // expected-warning@110{{Assigned value is garbage or undefined}}
u = v; // expected-warning@110{{Assigned value is uninitialized}}
// expected-note@-1{{Calling defaulted copy assignment operator for 'B'}}
// expected-note@110{{Assigned value is garbage or undefined}}
// expected-note@110{{Assigned value is uninitialized}}
}
void testNoWarningMove() {
B v, u;
u = static_cast<B &&>(v); // expected-warning@111{{Assigned value is garbage or undefined}}
u = static_cast<B &&>(v); // expected-warning@111{{Assigned value is uninitialized}}
// expected-note@-1{{Calling defaulted move assignment operator for 'B'}}
// expected-note@111{{Assigned value is garbage or undefined}}
// expected-note@111{{Assigned value is uninitialized}}
}
void testConsistency() {

View File

@@ -118,7 +118,7 @@ struct TS {
};
int* f5() {
int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-warning{{reference 'i' is not yet bound to a value when used within its own initialization}}
int& i = i; // expected-warning {{Assigned value is uninitialized}} expected-warning{{reference 'i' is not yet bound to a value when used within its own initialization}}
return &i;
}

View File

@@ -34,7 +34,7 @@ char stackBased3 (int *x) {
char heapBased1 (void) {
char *buf = malloc(2);
buf[0] = 'a';
char result = buf[1]; // expected-warning{{undefined}}
char result = buf[1]; // expected-warning{{uninitialized}}
free(buf);
return result;
}
@@ -42,7 +42,7 @@ char heapBased1 (void) {
char heapBased2 (void) {
char *buf = malloc(2);
buf[1] = 'a';
char result = buf[0]; // expected-warning{{undefined}}
char result = buf[0]; // expected-warning{{uninitialized}}
free(buf);
return result;
}

View File

@@ -94,8 +94,8 @@ void f_6_1(void) {
void f_7(void) {
int z; // expected-note {{'z' declared without an initial value}}
int y=z; // expected-warning {{Assigned value is garbage or undefined}}
// expected-note@-1 {{Assigned value is garbage or undefined}}
int y=z; // expected-warning {{Assigned value is uninitialized}}
// expected-note@-1 {{Assigned value is uninitialized}}
doStuff3(y);
}
@@ -133,26 +133,26 @@ void f_12(void) {
// https://bugs.llvm.org/show_bug.cgi?id=35419
void f11_0(void) {
int x; // expected-note {{'x' declared without an initial value}}
x++; // expected-warning {{The expression is an uninitialized value. The computed value will also be garbage}}
// expected-note@-1 {{The expression is an uninitialized value. The computed value will also be garbage}}
x++; // expected-warning {{The expression uses uninitialized memory}}
// expected-note@-1 {{The expression uses uninitialized memory}}
clang_analyzer_warnIfReached(); // no-warning
}
void f11_1(void) {
int x; // expected-note {{'x' declared without an initial value}}
++x; // expected-warning {{The expression is an uninitialized value. The computed value will also be garbage}}
// expected-note@-1 {{The expression is an uninitialized value. The computed value will also be garbage}}
++x; // expected-warning {{The expression uses uninitialized memory}}
// expected-note@-1 {{The expression uses uninitialized memory}}
clang_analyzer_warnIfReached(); // no-warning
}
void f11_2(void) {
int x; // expected-note {{'x' declared without an initial value}}
x--; // expected-warning {{The expression is an uninitialized value. The computed value will also be garbage}}
// expected-note@-1 {{The expression is an uninitialized value. The computed value will also be garbage}}
x--; // expected-warning {{The expression uses uninitialized memory}}
// expected-note@-1 {{The expression uses uninitialized memory}}
clang_analyzer_warnIfReached(); // no-warning
}
void f11_3(void) {
int x; // expected-note {{'x' declared without an initial value}}
--x; // expected-warning {{The expression is an uninitialized value. The computed value will also be garbage}}
// expected-note@-1 {{The expression is an uninitialized value. The computed value will also be garbage}}
--x; // expected-warning {{The expression uses uninitialized memory}}
// expected-note@-1 {{The expression uses uninitialized memory}}
clang_analyzer_warnIfReached(); // no-warning
}

View File

@@ -68,11 +68,11 @@ int& f6_1_sub(int &p) {
void f6_1(void) {
int t; // expected-note{{'t' declared without an initial value}}
int p = f6_1_sub(t); //expected-warning {{Assigned value is garbage or undefined}}
int p = f6_1_sub(t); //expected-warning {{Assigned value is uninitialized}}
//expected-note@-1 {{Passing value via 1st parameter 'p'}}
//expected-note@-2 {{Calling 'f6_1_sub'}}
//expected-note@-3 {{Returning from 'f6_1_sub'}}
//expected-note@-4 {{Assigned value is garbage or undefined}}
//expected-note@-4 {{Assigned value is uninitialized}}
int q = p;
doStuff6(q);
}

View File

@@ -7,7 +7,7 @@ void array_value_a(void) {
auto [a, b] = arr;
arr[0] = 0;
int x = a; // expected-warning{{Assigned value is garbage or undefined}}
int x = a; // expected-warning{{Assigned value is uninitialized}}
}
void array_value_b(void) {
@@ -30,7 +30,7 @@ void array_value_c(void) {
clang_analyzer_eval(b == arr[1]); // expected-warning{{TRUE}}
int y = b; // no-warning
int x = a; // expected-warning{{Assigned value is garbage or undefined}}
int x = a; // expected-warning{{Assigned value is uninitialized}}
}
void array_value_d(void) {
@@ -43,7 +43,7 @@ void array_value_d(void) {
clang_analyzer_eval(b == arr[1]); // expected-warning{{TRUE}}
int y = b; // no-warning
int x = c; // expected-warning{{Assigned value is garbage or undefined}}
int x = c; // expected-warning{{Assigned value is uninitialized}}
}
void array_value_e(void) {
@@ -72,13 +72,13 @@ void array_value_f(void) {
clang_analyzer_eval(i == 0); // expected-warning{{TRUE}}
int a = i; // no-warning
int b = j; // expected-warning{{Assigned value is garbage or undefined}}
int b = j; // expected-warning{{Assigned value is uninitialized}}
}
void array_lref_a(void) {
int arr[2];
auto &[a, b] = arr;
int x = a; // expected-warning{{Assigned value is garbage or undefined}}
int x = a; // expected-warning{{Assigned value is uninitialized}}
}
void array_lref_b(void) {
@@ -100,7 +100,7 @@ void array_lref_c(void) {
clang_analyzer_eval(a == 1); // expected-warning{{TRUE}}
int x = a; // no-warning
int y = b; // expected-warning{{Assigned value is garbage or undefined}}
int y = b; // expected-warning{{Assigned value is uninitialized}}
}
void array_lref_d(void) {
@@ -113,7 +113,7 @@ void array_lref_d(void) {
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
int y = b; // no-warning
int x = a; // expected-warning{{Assigned value is garbage or undefined}}
int x = a; // expected-warning{{Assigned value is uninitialized}}
}
void array_lref_e(void) {
@@ -126,7 +126,7 @@ void array_lref_e(void) {
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
int y = b; // no-warning
int x = c; // expected-warning{{Assigned value is garbage or undefined}}
int x = c; // expected-warning{{Assigned value is uninitialized}}
}
void array_lref_f(void) {
@@ -155,13 +155,13 @@ void array_lref_g(void) {
clang_analyzer_eval(i == 0); // expected-warning{{TRUE}}
int a = i; // no-warning
int b = j; // expected-warning{{Assigned value is garbage or undefined}}
int b = j; // expected-warning{{Assigned value is uninitialized}}
}
void array_rref_a(void) {
int arr[2];
auto &&[a, b] = arr;
int x = a; // expected-warning{{Assigned value is garbage or undefined}}
int x = a; // expected-warning{{Assigned value is uninitialized}}
}
void array_rref_b(void) {
@@ -183,7 +183,7 @@ void array_rref_c(void) {
clang_analyzer_eval(a == 1); // expected-warning{{TRUE}}
int x = a; // no-warning
int y = b; // expected-warning{{Assigned value is garbage or undefined}}
int y = b; // expected-warning{{Assigned value is uninitialized}}
}
void array_rref_d(void) {
@@ -196,7 +196,7 @@ void array_rref_d(void) {
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
int y = b; // no-warning
int x = a; // expected-warning{{Assigned value is garbage or undefined}}
int x = a; // expected-warning{{Assigned value is uninitialized}}
}
void array_rref_e(void) {
@@ -209,7 +209,7 @@ void array_rref_e(void) {
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
int y = b; // no-warning
int x = c; // expected-warning{{Assigned value is garbage or undefined}}
int x = c; // expected-warning{{Assigned value is uninitialized}}
}
void array_rref_f(void) {
@@ -238,7 +238,7 @@ void array_rref_g(void) {
clang_analyzer_eval(i == 0); // expected-warning{{TRUE}}
int a = i; // no-warning
int b = j; // expected-warning{{Assigned value is garbage or undefined}}
int b = j; // expected-warning{{Assigned value is uninitialized}}
}
void array_change_a(void) {
@@ -276,7 +276,7 @@ void array_small_a(void) {
auto [a, b, c, d, e] = arr;
int x = e; // expected-warning{{Assigned value is garbage or undefined}}
int x = e; // expected-warning{{Assigned value is uninitialized}}
}
void array_big_a(void) {

View File

@@ -12,7 +12,7 @@ void a(void) {
auto [i, j] = tst;
int x = i; // expected-warning{{Assigned value is garbage or undefined}}
int x = i; // expected-warning{{Assigned value is uninitialized}}
}
void b(void) {
@@ -22,7 +22,7 @@ void b(void) {
auto [i, j] = tst;
clang_analyzer_eval(i == 1); // expected-warning{{TRUE}}
int y = j; // expected-warning{{Assigned value is garbage or undefined}}
int y = j; // expected-warning{{Assigned value is uninitialized}}
}
void c(void) {
@@ -30,7 +30,7 @@ void c(void) {
auto &[i, j] = tst;
int x = i; // expected-warning{{Assigned value is garbage or undefined}}
int x = i; // expected-warning{{Assigned value is uninitialized}}
}
void d(void) {
@@ -43,7 +43,7 @@ void d(void) {
i = 2;
clang_analyzer_eval(tst.a == 2); // expected-warning{{TRUE}}
int y = j; // expected-warning{{Assigned value is garbage or undefined}}
int y = j; // expected-warning{{Assigned value is uninitialized}}
}
void e(void) {
@@ -63,7 +63,7 @@ void f(void) {
auto &&[i, j] = tst;
int x = i; // expected-warning{{Assigned value is garbage or undefined}}
int x = i; // expected-warning{{Assigned value is uninitialized}}
}
void g(void) {
@@ -73,7 +73,7 @@ void g(void) {
auto &&[i, j] = tst;
clang_analyzer_eval(i == 1); // expected-warning{{TRUE}}
int y = j; // expected-warning{{Assigned value is garbage or undefined}}
int y = j; // expected-warning{{Assigned value is uninitialized}}
}
struct s2 {

View File

@@ -525,7 +525,7 @@ void uninit_a(void) {
auto [a, b] = u;
int x = a; // expected-warning{{Assigned value is garbage or undefined}}
int x = a; // expected-warning{{Assigned value is uninitialized}}
}
void uninit_b(void) {
@@ -533,7 +533,7 @@ void uninit_b(void) {
auto [a, b] = u;
int x = b; // expected-warning{{Assigned value is garbage or undefined}}
int x = b; // expected-warning{{Assigned value is uninitialized}}
}
GENERATE_TUPLE_LIKE_STRUCT(UninitCall, int);

View File

@@ -34,8 +34,8 @@ void test_uninit_pos(void) {
struct TestUninit v1 = { 0, 0 };
struct TestUninit v2 = test_uninit_aux();
int z; // expected-note{{'z' declared without an initial value}}
v1.y = z; // expected-warning{{Assigned value is garbage or undefined}}
// expected-note@-1{{Assigned value is garbage or undefined}}
v1.y = z; // expected-warning{{Assigned value is uninitialized}}
// expected-note@-1{{Assigned value is uninitialized}}
test_unit_aux2(v2.x + v1.y);
}
void test_uninit_pos_2(void) {
@@ -78,8 +78,8 @@ void testFoo(Foo *o) {
void rdar_7780304(void) {
typedef struct s_r7780304 { int x; } s_r7780304;
s_r7780304 b;
b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}}
// expected-note@-1{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}}
b.x |= 1; // expected-warning{{The left expression of the compound assignment uses uninitialized memory}}
// expected-note@-1{{The left expression of the compound assignment uses uninitialized memory}}
}

View File

@@ -124,7 +124,7 @@ void zeroSizeArrayLambdaCaptureUndefined1() {
int n;
auto l = [arr, n]{
int x = n; //expected-warning{{Assigned value is garbage or undefined}}
int x = n; //expected-warning{{Assigned value is uninitialized}}
(void) x;
};
@@ -137,7 +137,7 @@ void zeroSizeArrayLambdaCaptureUndefined2() {
int n;
[arr, n]{
int x = n; //expected-warning{{Assigned value is garbage or undefined}}
int x = n; //expected-warning{{Assigned value is uninitialized}}
(void) x;
}();
}