r208331 - Simplify a few cast<>s.
Rafael Espindola
rafael.espindola at gmail.com
Thu May 8 08:44:46 PDT 2014
Author: rafael
Date: Thu May 8 10:44:45 2014
New Revision: 208331
URL: http://llvm.org/viewvc/llvm-project?rev=208331&view=rev
Log:
Simplify a few cast<>s.
Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=208331&r1=208330&r2=208331&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu May 8 10:44:45 2014
@@ -321,27 +321,30 @@ void CodeGenVTables::emitThunk(GlobalDec
const CGFunctionInfo &FnInfo = CGM.getTypes().arrangeGlobalDeclaration(GD);
// FIXME: re-use FnInfo in this computation.
- llvm::Constant *Entry = CGM.GetAddrOfThunk(GD, Thunk);
-
+ llvm::Constant *C = CGM.GetAddrOfThunk(GD, Thunk);
+ llvm::GlobalValue *Entry;
+
// Strip off a bitcast if we got one back.
- if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {
+ if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(C)) {
assert(CE->getOpcode() == llvm::Instruction::BitCast);
- Entry = CE->getOperand(0);
+ Entry = cast<llvm::GlobalValue>(CE->getOperand(0));
+ } else {
+ Entry = cast<llvm::GlobalValue>(C);
}
-
+
// There's already a declaration with the same name, check if it has the same
// type or if we need to replace it.
- if (cast<llvm::GlobalValue>(Entry)->getType()->getElementType() !=
+ if (Entry->getType()->getElementType() !=
CGM.getTypes().GetFunctionTypeForVTable(GD)) {
- llvm::GlobalValue *OldThunkFn = cast<llvm::GlobalValue>(Entry);
-
+ llvm::GlobalValue *OldThunkFn = Entry;
+
// If the types mismatch then we have to rewrite the definition.
assert(OldThunkFn->isDeclaration() &&
"Shouldn't replace non-declaration");
// Remove the name from the old thunk function and get a new thunk.
OldThunkFn->setName(StringRef());
- Entry = CGM.GetAddrOfThunk(GD, Thunk);
+ Entry = cast<llvm::GlobalValue>(CGM.GetAddrOfThunk(GD, Thunk));
// If needed, replace the old thunk with a bitcast.
if (!OldThunkFn->use_empty()) {
More information about the cfe-commits
mailing list