diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -79,6 +79,8 @@ using NamedMDListType = ilist; /// The type of the comdat "symbol" table. using ComdatSymTabType = StringMap; + /// The type for mapping names to named metadata. + using NamedMDSymTabType = StringMap; /// The Global Variable iterator. using global_iterator = GlobalListType::iterator; @@ -187,7 +189,7 @@ ///< recorded in bitcode. std::string TargetTriple; ///< Platform target triple Module compiled on ///< Format: (arch)(sub)-(vendor)-(sys0-(abi) - void *NamedMDSymTab; ///< NamedMDNode names. + NamedMDSymTabType NamedMDSymTab; ///< NamedMDNode names. DataLayout DL; ///< DataLayout associated with the module friend class Constant; diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -73,7 +73,6 @@ Module::Module(StringRef MID, LLVMContext &C) : Context(C), Materializer(), ModuleID(MID), SourceFileName(MID), DL("") { ValSymTab = new ValueSymbolTable(); - NamedMDSymTab = new StringMap(); Context.addModule(this); } @@ -85,8 +84,8 @@ AliasList.clear(); IFuncList.clear(); NamedMDList.clear(); + NamedMDSymTab.clear(); delete ValSymTab; - delete static_cast *>(NamedMDSymTab); } std::unique_ptr Module::createRNG(const Pass* P) const { @@ -250,15 +249,14 @@ NamedMDNode *Module::getNamedMetadata(const Twine &Name) const { SmallString<256> NameData; StringRef NameRef = Name.toStringRef(NameData); - return static_cast *>(NamedMDSymTab)->lookup(NameRef); + return NamedMDSymTab.lookup(NameRef); } /// getOrInsertNamedMetadata - Return the first named MDNode in the module /// with the specified name. This method returns a new NamedMDNode if a /// NamedMDNode with the specified name is not found. NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) { - NamedMDNode *&NMD = - (*static_cast *>(NamedMDSymTab))[Name]; + NamedMDNode *&NMD = NamedMDSymTab[Name]; if (!NMD) { NMD = new NamedMDNode(Name); NMD->setParent(this); @@ -270,7 +268,7 @@ /// eraseNamedMetadata - Remove the given NamedMDNode from this module and /// delete it. void Module::eraseNamedMetadata(NamedMDNode *NMD) { - static_cast *>(NamedMDSymTab)->erase(NMD->getName()); + NamedMDSymTab.erase(NMD->getName()); NamedMDList.erase(NMD->getIterator()); }