r177329 - This code works around what appears to be a bug in another part of clang.
Reed Kotler
rkotler at mips.com
Mon Mar 18 15:18:00 PDT 2013
Author: rkotler
Date: Mon Mar 18 17:18:00 2013
New Revision: 177329
URL: http://llvm.org/viewvc/llvm-project?rev=177329&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=177329&r1=177328&r2=177329&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Mar 18 17:18:00 2013
@@ -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");
}
More information about the cfe-commits
mailing list