[llvm-commits] [llvm] r135157 - /llvm/trunk/lib/VMCore/Globals.cpp
Chris Lattner
sabre at nondot.org
Thu Jul 14 11:01:49 PDT 2011
Author: lattner
Date: Thu Jul 14 13:01:49 2011
New Revision: 135157
URL: http://llvm.org/viewvc/llvm-project?rev=135157&view=rev
Log:
code cleanup
Modified:
llvm/trunk/lib/VMCore/Globals.cpp
Modified: llvm/trunk/lib/VMCore/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=135157&r1=135156&r2=135157&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Globals.cpp (original)
+++ llvm/trunk/lib/VMCore/Globals.cpp Thu Jul 14 13:01:49 2011
@@ -210,31 +210,26 @@
return false;
}
-void GlobalAlias::setAliasee(Constant *Aliasee)
-{
- if (Aliasee)
- assert(Aliasee->getType() == getType() &&
- "Alias and aliasee types should match!");
+void GlobalAlias::setAliasee(Constant *Aliasee) {
+ assert((!Aliasee || Aliasee->getType() == getType()) &&
+ "Alias and aliasee types should match!");
setOperand(0, Aliasee);
}
const GlobalValue *GlobalAlias::getAliasedGlobal() const {
const Constant *C = getAliasee();
- if (C) {
- if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
- return GV;
- else {
- const ConstantExpr *CE = 0;
- if ((CE = dyn_cast<ConstantExpr>(C)) &&
- (CE->getOpcode() == Instruction::BitCast ||
- CE->getOpcode() == Instruction::GetElementPtr))
- return dyn_cast<GlobalValue>(CE->getOperand(0));
- else
- llvm_unreachable("Unsupported aliasee");
- }
- }
- return 0;
+ if (C == 0) return 0;
+
+ if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
+ return GV;
+
+ const ConstantExpr *CE = cast<ConstantExpr>(C);
+ assert((CE->getOpcode() == Instruction::BitCast ||
+ CE->getOpcode() == Instruction::GetElementPtr) &&
+ "Unsupported aliasee");
+
+ return dyn_cast<GlobalValue>(CE->getOperand(0));
}
const GlobalValue *GlobalAlias::resolveAliasedGlobal(bool stopOnWeak) const {
@@ -255,7 +250,7 @@
GV = GA->getAliasedGlobal();
if (!Visited.insert(GV))
- return NULL;
+ return 0;
}
return GV;
More information about the llvm-commits
mailing list