diff options
author | Chris Lattner <sabre@nondot.org> | 2002-03-29 04:48:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-03-29 04:48:40 +0000 |
commit | 68e5ed8dbe724bd3380a044a522d4fd3effe2dd0 (patch) | |
tree | 26210e94466538b3b91140e5ae2c1d51e0475855 /lib/VMCore/Module.cpp | |
parent | b408b1255646f31895dcbf099184e087bfa1ca39 (diff) |
Add new addTypeName method to Module class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2037 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Module.cpp')
-rw-r--r-- | lib/VMCore/Module.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index c0767cd7d1..9d13169970 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -70,6 +70,21 @@ Function *Module::getFunction(const std::string &Name, const FunctionType *Ty) { return cast_or_null<Function>(SymTab->lookup(PointerType::get(Ty), Name)); } +// addTypeName - Insert an entry in the symbol table mapping Str to Type. If +// there is already an entry for this name, true is returned and the symbol +// table is not modified. +// +bool Module::addTypeName(const std::string &Name, const Type *Ty) { + SymbolTable *ST = getSymbolTableSure(); + + if (ST->lookup(Type::TypeTy, Name)) return true; // Already in symtab... + + // Not in symbol table? Set the name with the Symtab as an argument so the + // type knows what to update... + ((Value*)Ty)->setName(Name, ST); + + return false; +} // dropAllReferences() - This function causes all the subinstructions to "let |