Try to get rid of a -wunitialized warning: explicitly initialize the pointer
authorEli Bendersky <eliben@google.com>
Tue, 26 Feb 2013 23:04:17 +0000 (23:04 +0000)
committerEli Bendersky <eliben@google.com>
Tue, 26 Feb 2013 23:04:17 +0000 (23:04 +0000)
to NULL and use asserts to check in relevant places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176134 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-mc/llvm-mc.cpp

index 68f1a70bb218764ce4f9221cc223a639c9dc028e..243899bb881c59f29b9669941cb17fb80f91330a 100644 (file)
@@ -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;