llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-static-analyzer-1 Author: David Tarditi (dtarditi) <details> <summary>Changes</summary> A clang user pointed out that messages for the static analyzer undefined assignment checker use the term 'garbage'. This is kind of snarky and also imprecise. This change replaces the term 'garbage' in those messages with 'not meaningful'. It moves the term 'undefined' to be first in the messages because of the possible ambiguous parsing of the term 'not meaningful and undefined'. That could be parsed as '(not meaningful) and undefined' or 'not (meaningful and undefined'). The use of the term 'meaningless' was considered, but not chosen because it has two meanings in English. One meaning is 'without meaning'. The other meaning is 'having no point'. The 2nd meaning could be construed as indicating the computation could be deleted. rdar://133418644 --- Patch is 42.29 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126596.diff 25 Files Affected: - (modified) clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp (+5-5) - (modified) clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist (+5-5) - (modified) clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist (+5-5) - (modified) clang/test/Analysis/a_flaky_crash.cpp (+1-1) - (modified) clang/test/Analysis/analysis-after-multiple-dtors.cpp (+1-1) - (modified) clang/test/Analysis/array-init-loop.cpp (+3-3) - (modified) clang/test/Analysis/array-punned-region.c (+1-1) - (modified) clang/test/Analysis/builtin_overflow_notes.c (+2-2) - (modified) clang/test/Analysis/call-invalidation.cpp (+2-2) - (modified) clang/test/Analysis/ctor-array.cpp (+11-11) - (modified) clang/test/Analysis/diagnostics/no-store-func-path-notes.m (+2-2) - (modified) clang/test/Analysis/fread.c (+10-10) - (modified) clang/test/Analysis/implicit-ctor-undef-value.cpp (+6-6) - (modified) clang/test/Analysis/initialization.c (+8-8) - (modified) clang/test/Analysis/initialization.cpp (+13-13) - (modified) clang/test/Analysis/misc-ps.c (+2-2) - (modified) clang/test/Analysis/operator-calls.cpp (+4-4) - (modified) clang/test/Analysis/stack-addr-ps.cpp (+1-1) - (modified) clang/test/Analysis/uninit-const.c (+10-10) - (modified) clang/test/Analysis/uninit-const.cpp (+2-2) - (modified) clang/test/Analysis/uninit-structured-binding-array.cpp (+15-15) - (modified) clang/test/Analysis/uninit-structured-binding-struct.cpp (+6-6) - (modified) clang/test/Analysis/uninit-structured-binding-tuple.cpp (+2-2) - (modified) clang/test/Analysis/uninit-vals.m (+4-4) - (modified) clang/test/Analysis/zero-size-non-pod-array.cpp (+2-2) ``````````diff diff --git a/clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp index ddc6cc9e8202c7c..bdf705279351496 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp @@ -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 undefined and not meaningful"}; public: void checkBind(SVal location, SVal val, const Stmt *S, @@ -57,8 +57,8 @@ 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 is an uninitialized value, so the computed value " + << "is not meaningful"; ex = U->getSubExpr(); break; @@ -68,7 +68,7 @@ void UndefinedAssignmentChecker::checkBind(SVal location, SVal val, 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"; + << "uninitialized value, so the computed value is not meaningful"; ex = B->getLHS(); break; } @@ -89,7 +89,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 undefined and not meaningful."; break; } } diff --git a/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist b/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist index 31b6286b4465e4d..dd731e705c9b0b2 100644 --- a/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist +++ b/clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist @@ -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 is an uninitialized value, so the computed value is not meaningful</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 is an uninitialized value, so the computed value is not meaningful</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 is an uninitialized value, so the computed value is not meaningful</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 undefined and not meaningful</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>936a5fabf36091d0c1e1e1553232d6f5</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> diff --git a/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist b/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist index 8b8cc3239bd4bd8..392474d24487c6b 100644 --- a/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist +++ b/clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist @@ -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 is an uninitialized value, so the computed value is not meaningful</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 is an uninitialized value, so the computed value is not meaningful</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 is an uninitialized value, so the computed value is not meaningful</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 undefined and not meaningful</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>c1d7b1284317d7e45bda4bfa6b3a281e</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> diff --git a/clang/test/Analysis/a_flaky_crash.cpp b/clang/test/Analysis/a_flaky_crash.cpp index f350c1e1280cf3e..5a3fa25f82baa4c 100644 --- a/clang/test/Analysis/a_flaky_crash.cpp +++ b/clang/test/Analysis/a_flaky_crash.cpp @@ -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 is an uninitialized value, so the computed value is not meaningful}} } // 256 copies of the same run-line to make it crash more often when it breaks. diff --git a/clang/test/Analysis/analysis-after-multiple-dtors.cpp b/clang/test/Analysis/analysis-after-multiple-dtors.cpp index a8f6d38fbd1bbfc..c202752ee1a56b9 100644 --- a/clang/test/Analysis/analysis-after-multiple-dtors.cpp +++ b/clang/test/Analysis/analysis-after-multiple-dtors.cpp @@ -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 undefined and not meaningful}} (void)y; } diff --git a/clang/test/Analysis/array-init-loop.cpp b/clang/test/Analysis/array-init-loop.cpp index b28468b7f560b2c..cb26bda95abf881 100644 --- a/clang/test/Analysis/array-init-loop.cpp +++ b/clang/test/Analysis/array-init-loop.cpp @@ -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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful }} } // If this struct is being copy/move constructed by the implicit ctors, ArrayInitLoopExpr diff --git a/clang/test/Analysis/array-punned-region.c b/clang/test/Analysis/array-punned-region.c index d319fd7367ec5b0..c997611e2d3a75b 100644 --- a/clang/test/Analysis/array-punned-region.c +++ b/clang/test/Analysis/array-punned-region.c @@ -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 undefined and not meaningful [core.uninitialized.Assign]}} return a; } diff --git a/clang/test/Analysis/builtin_overflow_notes.c b/clang/test/Analysis/builtin_overflow_notes.c index 20f333a4a6cca56..e8d0e60ad80b046 100644 --- a/clang/test/Analysis/builtin_overflow_notes.c +++ b/clang/test/Analysis/builtin_overflow_notes.c @@ -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 undefined and not meaningful}} + // expected-note@-1 {{Assigned value is undefined and not meaningful}} return; } } diff --git a/clang/test/Analysis/call-invalidation.cpp b/clang/test/Analysis/call-invalidation.cpp index fb2b892b31a1f73..96869c5abeabba8 100644 --- a/clang/test/Analysis/call-invalidation.cpp +++ b/clang/test/Analysis/call-invalidation.cpp @@ -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 undefined and not meaningful}} 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 undefined and not meaningful}} return x + y; } diff --git a/clang/test/Analysis/ctor-array.cpp b/clang/test/Analysis/ctor-array.cpp index 52600b314b010f3..4a35df7834d6abd 100644 --- a/clang/test/Analysis/ctor-array.cpp +++ b/clang/test/Analysis/ctor-array.cpp @@ -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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful}} } } @@ -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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful}} } 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 undefined and not meaningful}} } struct Base { diff --git a/clang/test/Analysis/diagnostics/no-store-func-path-notes.m b/clang/test/Analysis/diagnostics/no-store-func-path-notes.m index 4826b38b98a56b3..c972b85771e5357 100644 --- a/clang/test/Analysis/diagnostics/no-store-func-path-notes.m +++ b/clang/test/Analysis/diagnostics/no-store-func-path-notes.m @@ -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 undefined and not meaningful}} + // expected-note@-1{{Assigned value is undefined and not meaningful}} }(); return z; } diff --git a/clang/test/Analysis/fread.c b/clang/test/Analysis/fread.c index 8dc998ea1e899d0..61b72122d328e17 100644 --- a/clang/test/Analysis/fread.c +++ b/clang/test/Analysis/fread.c @@ -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 undefined and not meaningful}} 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 undefined and not meaningful}} 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 undefined and not meaningful}} } else { - long p = c[3]; // expected-warning {{Assigned value is garbage or undefined}} + long p = c[3]; // expected-warning {{Assigned value is undefined and not meaningful}} } 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 undefined and not meaningful}} } } else { - int p = buffer[0]; // expected-warning {{Assigned value is garbage or undefined}} + int p = buffer[0]; // expected-warning {{Assigned value is undefined and not meaningful}} } 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 undefined and not meaningful}} } else { - long p = s.a; // expected-warning {{Assigned value is garbage or undefined}} + long p = s.a; // expected-warning {{Assigned value is undefined and not meaningful}} } 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 undefined and not meaningful}} } else { - long p = a; // expected-warning{{Assigned value is garbage or undefined}} + long p = a; // expected-warning{{Assigned value is undefined and not meaningful}} } fclose(fp); } diff --git a/clang/test/Analysis/implicit-ctor-undef-value.cpp b/clang/test/Analysis/implicit-ctor-undef-value.cpp index 87824c0533a0a36..f5d805609e5cce6 100644 --- a/clang/test/Analysis/implicit-ctor-undef-value.cpp +++ b/clang/test/Analysis/implicit-ctor-undef-value.cpp @@ -9,8 +9,8 @@ struct S { // 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 undefined and not meaningful}} + // expected-note@-1{{Value assigned to field 'y' in implicit constructor is undefined and not meaningful}} int x, y; S s; @@ -34,8 +34,8 @@ class C { // 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 undefined and not meaningful}} + // expected-note@-1{{Assigned value is undefined and not meaningful}} {} }; @@ -53,8 +53,8 @@ struct S { 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 undefined and not meaningful}} + // expected-note@-1{{Value assigned to field 'y' in implicit constructor is undefined and not meaningful}} int x, y; S s; diff --git a/clang/test/Analysis/initialization.c b/clang/test/Analysis/initialization.c index d394a902ffeb78c..daa40662477d93c 100644 --- a/clang/test/Analysis/initialization.c +++ b/clang/test/Analysis/initialization.c @@ -49,13 +49,13 @@ void glob... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/126596 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits