From 8b0a8c84da2030ee8f4440d5b60a8033de691222 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Wed, 25 Apr 2007 14:27:10 +0000 Subject: 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 --- lib/VMCore/Module.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/VMCore/Module.cpp') 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::createSentinel() { LeakDetector::removeGarbageObject(Ret); return Ret; } +GlobalAlias *ilist_traits::createSentinel() { + GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty, GlobalValue::ExternalLinkage); + // This should not be garbage monitored. + LeakDetector::removeGarbageObject(Ret); + return Ret; +} iplist &ilist_traits::getList(Module *M) { return M->getFunctionList(); @@ -52,11 +58,15 @@ iplist &ilist_traits::getList(Module *M) { iplist &ilist_traits::getList(Module *M) { return M->getGlobalList(); } +iplist &ilist_traits::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; template class SymbolTableListTraits; +template class SymbolTableListTraits; //===----------------------------------------------------------------------===// // Primitive Module methods. @@ -72,6 +82,7 @@ Module::~Module() { dropAllReferences(); GlobalList.clear(); FunctionList.clear(); + AliasList.clear(); LibraryList.clear(); delete ValSymTab; delete TypeSymTab; @@ -211,6 +222,18 @@ GlobalVariable *Module::getGlobalVariable(const std::string &Name, return 0; } +//===----------------------------------------------------------------------===// +// 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(SymTab.lookup(Name)); +} + //===----------------------------------------------------------------------===// // Methods for easy access to the types in the module. // -- cgit v1.2.3-18-g5258