diff options
-rw-r--r-- | include/llvm/Module.h | 6 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/llvm/Module.h b/include/llvm/Module.h index a2a8e50728..bc7f564a8f 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -63,6 +63,12 @@ public: // Function *getFunction(const std::string &Name, const FunctionType *Ty); + // 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 addTypeName(const std::string &Name, const Type *Ty); + // Get the underlying elements of the Module... inline const GlobalListType &getGlobalList() const { return GlobalList; } inline GlobalListType &getGlobalList() { return GlobalList; } 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 |