StringRef getPath() const { return Path; }
StringRef getASTFile() const { return ASTFile; }
uint64_t getSignature() const { return Signature; }
+ const Module *getModuleOrNull() const { return ClangModule; }
};
/// Return a descriptor for the corresponding module, if one exists.
llvm::DIModule *
CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
bool CreateSkeletonCU) {
- std::string FullModuleName = Mod.getFullModuleName();
- auto &ModRef = ModuleRefCache[FullModuleName];
+ // Use the Module pointer as the key into the cache. This is a
+ // nullptr if the "Module" is a PCH, which is safe because we don't
+ // support chained PCH debug info, so there can only be a single PCH.
+ const Module *M = Mod.getModuleOrNull();
+ auto &ModRef = ModuleCache[M];
if (ModRef)
return cast<llvm::DIModule>(ModRef);
}
}
+ std::string FullModuleName = Mod.getFullModuleName();
if (CreateSkeletonCU) {
llvm::DIBuilder DIB(CGM.getModule());
DIB.createCompileUnit(TheCU->getSourceLanguage(), FullModuleName,
llvm::DIBuilder::FullDebug, Mod.getSignature());
DIB.finalize();
}
- llvm::DIModule *M =
+ llvm::DIModule *DIMod =
DBuilder.createModule(TheCU, FullModuleName, ConfigMacros, Mod.getPath(),
CGM.getHeaderSearchOpts().Sysroot);
- ModRef.reset(M);
- return M;
+ ModRef.reset(DIMod);
+ return DIMod;
}
llvm::DIType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
/// Cache of references to clang modules and precompiled headers.
- llvm::StringMap<llvm::TrackingMDRef> ModuleRefCache;
+ llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
/// List of interfaces we want to keep even if orphaned.
std::vector<void *> RetainedTypes;