From 145cdc632a29600c2d8ea1707917e227f9a2c8b1 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sun, 14 Jun 2015 00:23:40 +0000 Subject: [PATCH] AsmPrinter.cpp: Avoid crashes for targeting like "arm-mingw32". CurrentFnSym might not be here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239692 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index cb8aa72e246..85ee9b3b853 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -902,7 +902,8 @@ void AsmPrinter::EmitFunctionBody() { const MCExpr *SizeExp = MCBinaryExpr::createSub( MCSymbolRefExpr::create(CurrentFnEnd, OutContext), MCSymbolRefExpr::create(CurrentFnSymForSize, OutContext), OutContext); - OutStreamer->emitELFSize(cast(CurrentFnSym), SizeExp); + if (auto Sym = dyn_cast(CurrentFnSym)) + OutStreamer->emitELFSize(Sym, SizeExp); } for (const HandlerInfo &HI : Handlers) { -- 2.34.1