Commit 030df51e authored by Mikael Holmen's avatar Mikael Holmen
Browse files

[ARM] Fix compiler warning

Without this fix clang 3.6 complains with:

../lib/Target/ARM/ARMAsmPrinter.cpp:1473:18: error: variable 'BranchTarget' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
      } else if (MI->getOperand(1).isSymbol()) {
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/Target/ARM/ARMAsmPrinter.cpp:1479:22: note: uninitialized use occurs here
      MCInst.addExpr(BranchTarget);
                     ^~~~~~~~~~~~
../lib/Target/ARM/ARMAsmPrinter.cpp:1473:14: note: remove the 'if' if its condition is always true
      } else if (MI->getOperand(1).isSymbol()) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/Target/ARM/ARMAsmPrinter.cpp:1465:33: note: initialize the variable 'BranchTarget' to silence this warning
      const MCExpr *BranchTarget;
                                ^
                                 = nullptr
1 error generated.

Discussed here:
 http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190610/661417.html

llvm-svn: 363166
parent aa6bdf9d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1474,7 +1474,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
        BranchTarget = MCSymbolRefExpr::create(
            GetExternalSymbolSymbol(MI->getOperand(1).getSymbolName()),
            OutContext);
      }
      } else
        llvm_unreachable("Unhandled operand kind in Branch Future instruction");

      MCInst.addExpr(BranchTarget);
    }