diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-28 13:45:00 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-28 13:45:00 +0000 |
commit | a80e1181b78183dc36ec6568559d38faa86981f0 (patch) | |
tree | 88ca9bd2f28f363e50add28297f6220ac8e09fc1 /lib/VMCore/Globals.cpp | |
parent | 44b2c5098f5cf766b4eff43d9eb0d8a9a143e7d8 (diff) |
Implement review feedback. Aliasees can be either GlobalValue's or
bitcasts of them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Globals.cpp')
-rw-r--r-- | lib/VMCore/Globals.cpp | 21 |
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); + } } |