[llvm-commits] [llvm] r155307 - in /llvm/trunk/lib: Support/YAMLParser.cpp Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp

Bill Wendling isanbard at gmail.com
Sun Apr 22 00:37:09 PDT 2012


On Apr 22, 2012, at 12:34 AM, Chandler Carruth wrote:

> On Sun, Apr 22, 2012 at 12:23 AM, Bill Wendling <isanbard at gmail.com> wrote:
> Author: void
> Date: Sun Apr 22 02:23:04 2012
> New Revision: 155307
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=155307&view=rev
> Log:
> Remove some potential warnings about variables used uninitialized.
> 
> I'm not thrilled with this change. I know that GCC has a broken uninitialized variable warning, but I don't think we should silence it this way. When we initialize these variables unnecessarily, we lose the ability to track actual bugs with tools like Valgrind.
> 
> Do these warnings really cause any problems? Newer GCC versions can turn them off with -Wno-maybe-uninitialized, and they're off in Clang for the same reason...

The .getAsInteger methods can return without assigning a value to the variable, so those seem like legitimate errors. The only one I would question is the Mips fix, which seems rather odd that it could get past the switch statement without assigning a value to the variable.

-bw

> Modified:
>    llvm/trunk/lib/Support/YAMLParser.cpp
>    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
> 
> Modified: llvm/trunk/lib/Support/YAMLParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLParser.cpp?rev=155307&r1=155306&r2=155307&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/YAMLParser.cpp (original)
> +++ llvm/trunk/lib/Support/YAMLParser.cpp Sun Apr 22 02:23:04 2012
> @@ -1732,7 +1732,7 @@
>           if (UnquotedValue.size() < 3)
>             // TODO: Report error.
>             break;
> -          unsigned int UnicodeScalarValue;
> +          unsigned int UnicodeScalarValue = 0;
>           UnquotedValue.substr(1, 2).getAsInteger(16, UnicodeScalarValue);
>           encodeUTF8(UnicodeScalarValue, Storage);
>           UnquotedValue = UnquotedValue.substr(2);
> @@ -1742,7 +1742,7 @@
>           if (UnquotedValue.size() < 5)
>             // TODO: Report error.
>             break;
> -          unsigned int UnicodeScalarValue;
> +          unsigned int UnicodeScalarValue = 0;
>           UnquotedValue.substr(1, 4).getAsInteger(16, UnicodeScalarValue);
>           encodeUTF8(UnicodeScalarValue, Storage);
>           UnquotedValue = UnquotedValue.substr(4);
> @@ -1752,7 +1752,7 @@
>           if (UnquotedValue.size() < 9)
>             // TODO: Report error.
>             break;
> -          unsigned int UnicodeScalarValue;
> +          unsigned int UnicodeScalarValue = 0;
>           UnquotedValue.substr(1, 8).getAsInteger(16, UnicodeScalarValue);
>           encodeUTF8(UnicodeScalarValue, Storage);
>           UnquotedValue = UnquotedValue.substr(8);
> 
> Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp?rev=155307&r1=155306&r2=155307&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp Sun Apr 22 02:23:04 2012
> @@ -194,7 +194,7 @@
> 
>   assert (Kind == MCExpr::SymbolRef);
> 
> -  Mips::Fixups FixupKind;
> +  Mips::Fixups FixupKind = Mips::Fixups(0);
> 
>   switch(cast<MCSymbolRefExpr>(Expr)->getKind()) {
>   case MCSymbolRefExpr::VK_Mips_GPREL:
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 





More information about the llvm-commits mailing list