aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorReed Kotler <rkotler@mips.com>2013-03-18 22:18:00 +0000
committerReed Kotler <rkotler@mips.com>2013-03-18 22:18:00 +0000
commit4882fe02d8d453084da563b9c18eb5545f0783d4 (patch)
tree993909a261aadfeaa906265431938d79aed5afc3 /lib/CodeGen/TargetInfo.cpp
parentf72663fc962c1c27a4793ebd3d2e3d81a4f4e984 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r--lib/CodeGen/TargetInfo.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index 556999f61b..193121b2de 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -4323,7 +4323,8 @@ public:
CodeGen::CodeGenModule &CGM) const {
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
if (!FD) return;
- llvm::Function *Fn = cast<llvm::Function>(GV);
+ llvm::Function *Fn = dyn_cast<llvm::Function>(GV);
+ if (!Fn) return; // should not happen
if (FD->hasAttr<Mips16Attr>()) {
Fn->addFnAttr("mips16");
}