aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Globals.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/Globals.cpp')
-rw-r--r--lib/VMCore/Globals.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index c64b719095..88a8c0b2a7 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -163,12 +163,15 @@ void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To,
//===----------------------------------------------------------------------===//
GlobalAlias::GlobalAlias(const Type *Ty, LinkageTypes Link,
- const std::string &Name, const GlobalValue* aliasee,
+ const std::string &Name, Constant* aliasee,
Module *ParentModule)
- : GlobalValue(Ty, Value::GlobalAliasVal, 0, 0,
- Link, Name), Aliasee(aliasee) {
+ : GlobalValue(Ty, Value::GlobalAliasVal, &Aliasee, 1, Link, Name) {
LeakDetector::addGarbageObject(this);
+ if (aliasee)
+ assert(aliasee->getType() == Ty && "Alias and aliasee types should match!");
+ Aliasee.init(aliasee, this);
+
if (ParentModule)
ParentModule->getAliasList().push_back(this);
}
@@ -190,12 +193,16 @@ void GlobalAlias::eraseFromParent() {
}
bool GlobalAlias::isDeclaration() const {
- return (Aliasee && Aliasee->isDeclaration());
+ const GlobalValue* AV = dyn_cast_or_null<const GlobalValue>(getAliasee());
+ return (AV && AV->isDeclaration());
}
-void GlobalAlias::setAliasee(const GlobalValue *GV)
+void GlobalAlias::setAliasee(Constant *Aliasee)
{
- // FIXME: Some checks?
- Aliasee = GV;
+ if (Aliasee) {
+ assert(Aliasee->getType() == getType() &&
+ "Alias and aliasee types should match!");
+ setOperand(0, Aliasee);
+ }
}