Skip to content

Commit f381590

Browse files
committed
[analyzer] Change warnings to use the term uninitialized instead.
The prior change was using the message 'not meaningful and undefined'. This changes updates it to use the term uninitialized based on PR review feedback and discussion.
1 parent ec0b49a commit f381590

30 files changed

+138
-139
lines changed

clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using namespace ento;
2323
namespace {
2424
class UndefinedAssignmentChecker
2525
: public Checker<check::Bind> {
26-
const BugType BT{this, "Assigned value is undefined and not meaningful"};
26+
const BugType BT{this, "Assigned value is uninitialized"};
2727

2828
public:
2929
void checkBind(SVal location, SVal val, const Stmt *S,
@@ -57,8 +57,7 @@ void UndefinedAssignmentChecker::checkBind(SVal location, SVal val,
5757

5858
while (StoreE) {
5959
if (const UnaryOperator *U = dyn_cast<UnaryOperator>(StoreE)) {
60-
OS << "The expression is an uninitialized value, so the computed value "
61-
<< "is not meaningful";
60+
OS << "The expression uses uninitialized memory";
6261

6362
ex = U->getSubExpr();
6463
break;
@@ -67,8 +66,8 @@ void UndefinedAssignmentChecker::checkBind(SVal location, SVal val,
6766
if (const BinaryOperator *B = dyn_cast<BinaryOperator>(StoreE)) {
6867
if (B->isCompoundAssignmentOp()) {
6968
if (C.getSVal(B->getLHS()).isUndef()) {
70-
OS << "The left expression of the compound assignment is an "
71-
<< "uninitialized value, so the computed value is not meaningful";
69+
OS << "The left expression of the compound assignment uses "
70+
<< "uninitialized memory";
7271
ex = B->getLHS();
7372
break;
7473
}
@@ -89,7 +88,7 @@ void UndefinedAssignmentChecker::checkBind(SVal location, SVal val,
8988
for (auto *I : CD->inits()) {
9089
if (I->getInit()->IgnoreImpCasts() == StoreE) {
9190
OS << "Value assigned to field '" << I->getMember()->getName()
92-
<< "' in implicit constructor is undefined and not meaningful.";
91+
<< "' in implicit constructor is uninitialized";
9392
break;
9493
}
9594
}

clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,17 +2578,17 @@
25782578
</array>
25792579
<key>depth</key><integer>0</integer>
25802580
<key>extended_message</key>
2581-
<string>The left expression of the compound assignment is an uninitialized value, so the computed value is not meaningful</string>
2581+
<string>The left expression of the compound assignment uses uninitialized memory</string>
25822582
<key>message</key>
2583-
<string>The left expression of the compound assignment is an uninitialized value, so the computed value is not meaningful</string>
2583+
<string>The left expression of the compound assignment uses uninitialized memory</string>
25842584
</dict>
25852585
</array>
2586-
<key>description</key><string>The left expression of the compound assignment is an uninitialized value, so the computed value is not meaningful</string>
2586+
<key>description</key><string>The left expression of the compound assignment uses uninitialized memory</string>
25872587
<key>category</key><string>Logic error</string>
2588-
<key>type</key><string>Assigned value is undefined and not meaningful</string>
2588+
<key>type</key><string>Assigned value is uninitialized</string>
25892589
<key>check_name</key><string>core.uninitialized.Assign</string>
25902590
<!-- This hash is experimental and going to change! -->
2591-
<key>issue_hash_content_of_line_in_context</key><string>936a5fabf36091d0c1e1e1553232d6f5</string>
2591+
<key>issue_hash_content_of_line_in_context</key><string>324827600c298776167cd9562f71bda6</string>
25922592
<key>issue_context_kind</key><string>function</string>
25932593
<key>issue_context</key><string>test_objc_fast_enumeration_2</string>
25942594
<key>issue_hash_function_offset</key><string>5</string>

clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5864,17 +5864,17 @@
58645864
</array>
58655865
<key>depth</key><integer>0</integer>
58665866
<key>extended_message</key>
5867-
<string>The left expression of the compound assignment is an uninitialized value, so the computed value is not meaningful</string>
5867+
<string>The left expression of the compound assignment uses uninitialized memory</string>
58685868
<key>message</key>
5869-
<string>The left expression of the compound assignment is an uninitialized value, so the computed value is not meaningful</string>
5869+
<string>The left expression of the compound assignment uses uninitialized memory</string>
58705870
</dict>
58715871
</array>
5872-
<key>description</key><string>The left expression of the compound assignment is an uninitialized value, so the computed value is not meaningful</string>
5872+
<key>description</key><string>The left expression of the compound assignment uses uninitialized memory</string>
58735873
<key>category</key><string>Logic error</string>
5874-
<key>type</key><string>Assigned value is undefined and not meaningful</string>
5874+
<key>type</key><string>Assigned value is uninitialized</string>
58755875
<key>check_name</key><string>core.uninitialized.Assign</string>
58765876
<!-- This hash is experimental and going to change! -->
5877-
<key>issue_hash_content_of_line_in_context</key><string>c1d7b1284317d7e45bda4bfa6b3a281e</string>
5877+
<key>issue_hash_content_of_line_in_context</key><string>faa8858031ed123ff98cc23cf14d462f</string>
58785878
<key>issue_context_kind</key><string>function</string>
58795879
<key>issue_context</key><string>test_loop_fast_enumeration</string>
58805880
<key>issue_hash_function_offset</key><string>5</string>

clang/test/Analysis/a_flaky_crash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bool bar(S);
1414
void foo() {
1515
int x;
1616
if (true && bar(S()))
17-
++x; // expected-warning{{The expression is an uninitialized value, so the computed value is not meaningful}}
17+
++x; // expected-warning{{The expression uses uninitialized memory}}
1818
}
1919

2020
// 256 copies of the same run-line to make it crash more often when it breaks.

clang/test/Analysis/analysis-after-multiple-dtors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ int main() {
2323

2424
int x;
2525
int y = x;
26-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
26+
// expected-warning@-1{{Assigned value is uninitialized}}
2727
(void)y;
2828
}

clang/test/Analysis/array-init-loop.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void array_uninit() {
1919

2020
auto [a, b, c, d, e] = arr;
2121

22-
int x = e; // expected-warning{{Assigned value is undefined and not meaningful}}
22+
int x = e; // expected-warning{{Assigned value is uninitialized}}
2323
}
2424

2525
void lambda_init() {
@@ -168,7 +168,7 @@ struct S3_duplicate {
168168
void array_uninit_non_pod() {
169169
S3 arr[1];
170170

171-
auto [a] = arr; // expected-warning@159{{ in implicit constructor is undefined and not meaningful}}
171+
auto [a] = arr; // expected-warning@159{{ in implicit constructor is uninitialized}}
172172
}
173173

174174
void lambda_init_non_pod() {
@@ -191,7 +191,7 @@ void lambda_init_non_pod() {
191191
void lambda_uninit_non_pod() {
192192
S3_duplicate arr[4];
193193

194-
int l = [arr] { return arr[3].i; }(); // expected-warning@164{{ in implicit constructor is undefined and not meaningful }}
194+
int l = [arr] { return arr[3].i; }(); // expected-warning@164{{ in implicit constructor is uninitialized }}
195195
}
196196

197197
// If this struct is being copy/move constructed by the implicit ctors, ArrayInitLoopExpr

clang/test/Analysis/array-punned-region.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void array_struct_bitfield_1() {
2020
int array_struct_bitfield_2() {
2121
BITFIELD_CAST ff = {0};
2222
BITFIELD_CAST *pff = &ff;
23-
int a = *((int *)pff + 2); // expected-warning{{Assigned value is undefined and not meaningful [core.uninitialized.Assign]}}
23+
int a = *((int *)pff + 2); // expected-warning{{Assigned value is uninitialized [core.uninitialized.Assign]}}
2424
return a;
2525
}
2626

clang/test/Analysis/builtin_overflow_notes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ void test_overflow_note(int a, int b)
2323

2424
if (__builtin_add_overflow(a, b, &res)) { // expected-note {{Assuming overflow}}
2525
// expected-note@-1 {{Taking true branch}}
26-
int var = res; // expected-warning{{Assigned value is undefined and not meaningful}}
27-
// expected-note@-1 {{Assigned value is undefined and not meaningful}}
26+
int var = res; // expected-warning{{Assigned value is uninitialized}}
27+
// expected-note@-1 {{Assigned value is uninitialized}}
2828
return;
2929
}
3030
}

clang/test/Analysis/call-invalidation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ int testStdCtorDoesNotInvalidateParentObject() {
197197
int testStdCtorDoesNotInvalidateParentObjectSwapped() {
198198
StdWrappingOpaqueSwapped obj;
199199
int x = obj.o.nested_member; // no-garbage: std::Opaque::ctor might initialized this
200-
int y = obj.uninit; // expected-warning {{Assigned value is undefined and not meaningful}}
200+
int y = obj.uninit; // expected-warning {{Assigned value is uninitialized}}
201201
return x + y;
202202
}
203203

@@ -277,6 +277,6 @@ struct StdWrappingFancyOpaque {
277277
int testNestedStdNamespacesAndRecords() {
278278
StdWrappingFancyOpaque obj;
279279
int x = obj.o.nested_member; // no-garbage: ctor
280-
int y = obj.uninit; // expected-warning {{Assigned value is undefined and not meaningful}}
280+
int y = obj.uninit; // expected-warning {{Assigned value is uninitialized}}
281281
return x + y;
282282
}

clang/test/Analysis/ctor-array.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ struct s {
1212
void a1(void) {
1313
s arr[3];
1414
int x = arr[0].x;
15-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
15+
// expected-warning@-1{{Assigned value is uninitialized}}
1616
}
1717

1818
void a2(void) {
1919
s arr[3];
2020
int x = arr[1].x;
21-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
21+
// expected-warning@-1{{Assigned value is uninitialized}}
2222
}
2323

2424
void a3(void) {
2525
s arr[3];
2626
int x = arr[2].x;
27-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
27+
// expected-warning@-1{{Assigned value is uninitialized}}
2828
}
2929

3030
struct s2 {
@@ -37,23 +37,23 @@ void b1(void) {
3737

3838
clang_analyzer_eval(arr[0].y == 2); // expected-warning{{TRUE}}
3939
int x = arr[0].x;
40-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
40+
// expected-warning@-1{{Assigned value is uninitialized}}
4141
}
4242

4343
void b2(void) {
4444
s2 arr[3];
4545

4646
clang_analyzer_eval(arr[1].y == 2); // expected-warning{{TRUE}}
4747
int x = arr[1].x;
48-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
48+
// expected-warning@-1{{Assigned value is uninitialized}}
4949
}
5050

5151
void b3(void) {
5252
s2 arr[3];
5353

5454
clang_analyzer_eval(arr[2].y == 2); // expected-warning{{TRUE}}
5555
int x = arr[2].x;
56-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
56+
// expected-warning@-1{{Assigned value is uninitialized}}
5757
}
5858

5959
void c1(void) {
@@ -70,7 +70,7 @@ void c1(void) {
7070

7171
clang_analyzer_eval(arr[1].y == 2); // expected-warning{{TRUE}}
7272
int x = arr[1].x;
73-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
73+
// expected-warning@-1{{Assigned value is uninitialized}}
7474
}
7575
}
7676

@@ -100,15 +100,15 @@ void e1(void) {
100100
clang_analyzer_eval(arr[1].arr[1].y == 2); // expected-warning{{TRUE}}
101101

102102
int x = arr[1].sarr[1].x;
103-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
103+
// expected-warning@-1{{Assigned value is uninitialized}}
104104
}
105105

106106
void f1(void) {
107107
s2 arr[2][2];
108108

109109
clang_analyzer_eval(arr[1][1].y == 2); // expected-warning{{TRUE}}
110110
int x = arr[1][1].x;
111-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
111+
// expected-warning@-1{{Assigned value is uninitialized}}
112112
}
113113

114114
struct s5 {
@@ -168,14 +168,14 @@ void h2(void) {
168168
s a[2][2], b[2][2];
169169

170170
int x = a[1][1].x;
171-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
171+
// expected-warning@-1{{Assigned value is uninitialized}}
172172
}
173173

174174
void h3(void) {
175175
s a[2][2], b[2][2];
176176

177177
int x = b[1][1].y;
178-
// expected-warning@-1{{Assigned value is undefined and not meaningful}}
178+
// expected-warning@-1{{Assigned value is uninitialized}}
179179
}
180180

181181
struct Base {

0 commit comments

Comments
 (0)