llvm::DIModule *
CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
- auto it = ModuleRefCache.find(Mod.Signature);
- if (it != ModuleRefCache.end())
- return it->second;
+ auto &ModRef = ModuleRefCache[Mod.Signature];
+ if (ModRef)
+ return cast<llvm::DIModule>(ModRef);
// Macro definitions that were defined with "-D" on the command line.
SmallString<128> ConfigMacros;
TheCU->getSourceLanguage(), internString(Mod.ModuleName),
internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
- llvm::DIModule *ModuleRef =
+ llvm::DIModule *M =
DIB.createModule(CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
internString(CGM.getHeaderSearchOpts().Sysroot));
DIB.finalize();
- ModuleRefCache.insert(std::make_pair(Mod.Signature, ModuleRef));
- return ModuleRef;
+ ModRef.reset(M);
+ return M;
}
llvm::DIType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
/// Cache of references to AST files such as PCHs or modules.
- llvm::DenseMap<uint64_t, llvm::DIModule *> ModuleRefCache;
+ llvm::DenseMap<uint64_t, llvm::TrackingMDRef> ModuleRefCache;
/// List of interfaces we want to keep even if orphaned.
std::vector<void *> RetainedTypes;