From 7ee730414dc1f449e3de059f70a3d8a7fd1ea5fb Mon Sep 17 00:00:00 2001 From: Reed Kotler Date: Mon, 18 Mar 2013 22:18:00 +0000 Subject: This code works around what appears to be a bug in another part of clang. I have filed http://llvm.org/bugs/show_bug.cgi?id=15538 against clang. This code is safer anyway because "cast" assumes you really know that it's okay to make the cast. In this case isa should not be false and dyn_cast should not return null as far as I understand. But everything else is valid so I did not want to revert my previous patch for attributes mips16/nomips16 or use an llvm_unreachable here which would make a number of our tests fail for mips. llvm-svn: 177329 --- clang/lib/CodeGen/TargetInfo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/TargetInfo.cpp') diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 556999f61b3..193121b2deb 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -4323,7 +4323,8 @@ public: CodeGen::CodeGenModule &CGM) const { const FunctionDecl *FD = dyn_cast(D); if (!FD) return; - llvm::Function *Fn = cast(GV); + llvm::Function *Fn = dyn_cast(GV); + if (!Fn) return; // should not happen if (FD->hasAttr()) { Fn->addFnAttr("mips16"); } -- cgit v1.2.3