diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-13 18:58:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-13 18:58:33 +0000 |
commit | f33fa6fb57b9c41e99739eff79b7f185e0df9500 (patch) | |
tree | fd969d67c1b2afebb127ed8a914c02a545b2be06 /lib/VMCore/Module.cpp | |
parent | 3e5fe173bb6bcaaacc54d9fd4f71767eb3e3298e (diff) | |
download | external_llvm-f33fa6fb57b9c41e99739eff79b7f185e0df9500.zip external_llvm-f33fa6fb57b9c41e99739eff79b7f185e0df9500.tar.gz external_llvm-f33fa6fb57b9c41e99739eff79b7f185e0df9500.tar.bz2 |
Add Module::getTypeName
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2237 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Module.cpp')
-rw-r--r-- | lib/VMCore/Module.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 74b5f4b..f3d7cd9 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -86,6 +86,26 @@ bool Module::addTypeName(const std::string &Name, const Type *Ty) { return false; } +// getTypeName - If there is at least one entry in the symbol table for the +// specified type, return it. +// +std::string Module::getTypeName(const Type *Ty) { + const SymbolTable *ST = getSymbolTable(); + if (ST == 0) return ""; // No symbol table, must not have an entry... + if (ST->find(Type::TypeTy) == ST->end()) + return ""; // No names for types... + + SymbolTable::type_const_iterator TI = ST->type_begin(Type::TypeTy); + SymbolTable::type_const_iterator TE = ST->type_end(Type::TypeTy); + + while (TI != TE && TI->second != (const Value*)Ty) + ++TI; + + if (TI != TE) // Must have found an entry! + return TI->first; + return ""; // Must not have found anything... +} + // dropAllReferences() - This function causes all the subinstructions to "let // go" of all references that they are maintaining. This allows one to |