]> granicus.if.org Git - llvm/commit
[MIPS GlobalISel] Silence uninitialized variable warning
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 11 Mar 2019 10:39:15 +0000 (10:39 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 11 Mar 2019 10:39:15 +0000 (10:39 +0000)
commitf3ff35c66b59f9ba0fe7d59874e7dac6a828c0a4
tree7ffe3bba391f8164ecd6c13d55e4d28fc450236f
parente7f4ae297ee798d0acc8facf889ddfee7957c9f4
[MIPS GlobalISel] Silence uninitialized variable warning

The control flow here cannot ever use the uninitialized value, but it's
too hard for the compiler to figure that out. Clang warns:

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2600:28: error: variable 'CarrySum' is used uninitialized whenever 'for' loop exits because its condition is false [-Werror,-Wsometimes-uninitialized]
      for (unsigned i = 2; i < Factors.size(); ++i)
                           ^~~~~~~~~~~~~~~~~~
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2604:26: note: uninitialized use occurs here
    CarrySumPrevDstIdx = CarrySum;
                         ^~~~~~~~
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2600:28: note: remove the condition if it is always true
      for (unsigned i = 2; i < Factors.size(); ++i)
                           ^~~~~~~~~~~~~~~~~~
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2583:22: note: initialize the variable 'CarrySum' to silence this warning
    unsigned CarrySum;
                     ^
                      = 0

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355818 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/GlobalISel/LegalizerHelper.cpp