[llvm] r176134 - Try to get rid of a -wunitialized warning: explicitly initialize the pointer

Chandler Carruth chandlerc at google.com
Tue Feb 26 15:44:00 PST 2013


On Tue, Feb 26, 2013 at 3:04 PM, Eli Bendersky <eliben at google.com> wrote:

> Author: eliben
> Date: Tue Feb 26 17:04:17 2013
> New Revision: 176134
>
> URL: http://llvm.org/viewvc/llvm-project?rev=176134&view=rev
> Log:
> Try to get rid of a -wunitialized warning: explicitly initialize the
> pointer
> to NULL and use asserts to check in relevant places.
>

I assume GCC's -Wuninitialized?

I thought we turned that off due to the false positives like this.

I'm really opposed to littering the code with dead stores to placate this
warning. It undermines our ability to use Valgrind to catch actual
uninitialized bugs.


>
> Modified:
>     llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>
> Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=176134&r1=176133&r2=176134&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
> +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Tue Feb 26 17:04:17 2013
> @@ -427,7 +427,7 @@ int main(int argc, char **argv) {
>    OwningPtr<MCSubtargetInfo>
>      STI(TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
>
> -  MCInstPrinter *IP;
> +  MCInstPrinter *IP = NULL;
>    if (FileType == OFT_AssemblyFile) {
>      IP =
>        TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI,
> *STI);
> @@ -465,10 +465,12 @@ int main(int argc, char **argv) {
>      Res = AssembleInput(ProgName, TheTarget, SrcMgr, Ctx, *Str, *MAI,
> *STI);
>      break;
>    case AC_MDisassemble:
> +    assert(IP && "Expected assembly output");
>      IP->setUseMarkup(1);
>      disassemble = true;
>      break;
>    case AC_HDisassemble:
> +    assert(IP && "Expected assembly output");
>      IP->setPrintImmHex(1);
>      disassemble = true;
>      break;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130226/3e82f739/attachment.html>


More information about the llvm-commits mailing list