AsmPrinter.cpp: Avoid crashes for targeting like "arm-mingw32". CurrentFnSym might...
[oota-llvm.git] / lib / CodeGen / AsmPrinter / AsmPrinter.cpp
index cb8aa72..85ee9b3 100644 (file)
@@ -902,7 +902,8 @@ void AsmPrinter::EmitFunctionBody() {
     const MCExpr *SizeExp = MCBinaryExpr::createSub(
         MCSymbolRefExpr::create(CurrentFnEnd, OutContext),
         MCSymbolRefExpr::create(CurrentFnSymForSize, OutContext), OutContext);
-    OutStreamer->emitELFSize(cast<MCSymbolELF>(CurrentFnSym), SizeExp);
+    if (auto Sym = dyn_cast<MCSymbolELF>(CurrentFnSym))
+      OutStreamer->emitELFSize(Sym, SizeExp);
   }
 
   for (const HandlerInfo &HI : Handlers) {