aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Module.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-04-25 14:27:10 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-04-25 14:27:10 +0000
commit8b0a8c84da2030ee8f4440d5b60a8033de691222 (patch)
tree7b780ed0cf12403faeac0e65fb16bca29fda5dbf /lib/VMCore/Module.cpp
parent24a3cc4c83e5edb25fadf7b8979a26b4451795c6 (diff)
Implement aliases. This fixes PR1017 and it's dependent bugs. CFE part
will follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36435 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Module.cpp')
-rw-r--r--lib/VMCore/Module.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index ddd503dea1..c66032388b 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -45,6 +45,12 @@ GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() {
LeakDetector::removeGarbageObject(Ret);
return Ret;
}
+GlobalAlias *ilist_traits<GlobalAlias>::createSentinel() {
+ GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty, GlobalValue::ExternalLinkage);
+ // This should not be garbage monitored.
+ LeakDetector::removeGarbageObject(Ret);
+ return Ret;
+}
iplist<Function> &ilist_traits<Function>::getList(Module *M) {
return M->getFunctionList();
@@ -52,11 +58,15 @@ iplist<Function> &ilist_traits<Function>::getList(Module *M) {
iplist<GlobalVariable> &ilist_traits<GlobalVariable>::getList(Module *M) {
return M->getGlobalList();
}
+iplist<GlobalAlias> &ilist_traits<GlobalAlias>::getList(Module *M) {
+ return M->getAliasList();
+}
// Explicit instantiations of SymbolTableListTraits since some of the methods
// are not in the public header file.
template class SymbolTableListTraits<GlobalVariable, Module>;
template class SymbolTableListTraits<Function, Module>;
+template class SymbolTableListTraits<GlobalAlias, Module>;
//===----------------------------------------------------------------------===//
// Primitive Module methods.
@@ -72,6 +82,7 @@ Module::~Module() {
dropAllReferences();
GlobalList.clear();
FunctionList.clear();
+ AliasList.clear();
LibraryList.clear();
delete ValSymTab;
delete TypeSymTab;
@@ -212,6 +223,18 @@ GlobalVariable *Module::getGlobalVariable(const std::string &Name,
}
//===----------------------------------------------------------------------===//
+// Methods for easy access to the global variables in the module.
+//
+
+// getNamedAlias - Look up the specified global in the module symbol table.
+// If it does not exist, return null.
+//
+GlobalAlias *Module::getNamedAlias(const std::string &Name) const {
+ const ValueSymbolTable &SymTab = getValueSymbolTable();
+ return dyn_cast_or_null<GlobalAlias>(SymTab.lookup(Name));
+}
+
+//===----------------------------------------------------------------------===//
// Methods for easy access to the types in the module.
//