mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-25 21:11:25 +00:00
CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
We don't want a skeleton CU when generating debug info for the module itself. NFC. llvm-svn: 248062
This commit is contained in:
parent
49e72e69e5
commit
666892051c
@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
|
||||
}
|
||||
|
||||
llvm::DIModule *
|
||||
CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
|
||||
CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
|
||||
bool CreateSkeletonCU) {
|
||||
auto &ModRef = ModuleRefCache[Mod.ModuleName];
|
||||
if (ModRef)
|
||||
return cast<llvm::DIModule>(ModRef);
|
||||
@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
|
||||
OS << '\"';
|
||||
}
|
||||
}
|
||||
llvm::DIBuilder DIB(CGM.getModule());
|
||||
auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.ModuleName,
|
||||
Mod.Path, TheCU->getProducer(), true,
|
||||
StringRef(), 0, Mod.ASTFile,
|
||||
llvm::DIBuilder::FullDebug, Mod.Signature);
|
||||
llvm::DIModule *M =
|
||||
DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
|
||||
CGM.getHeaderSearchOpts().Sysroot);
|
||||
DIB.finalize();
|
||||
|
||||
llvm::DIModule *M = nullptr;
|
||||
if (CreateSkeletonCU) {
|
||||
llvm::DIBuilder DIB(CGM.getModule());
|
||||
auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.ModuleName,
|
||||
Mod.Path, TheCU->getProducer(), true,
|
||||
StringRef(), 0, Mod.ASTFile,
|
||||
llvm::DIBuilder::FullDebug, Mod.Signature);
|
||||
M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
|
||||
CGM.getHeaderSearchOpts().Sysroot);
|
||||
DIB.finalize();
|
||||
} else
|
||||
M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros, Mod.Path,
|
||||
CGM.getHeaderSearchOpts().Sysroot);
|
||||
ModRef.reset(M);
|
||||
return M;
|
||||
}
|
||||
@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
|
||||
if (!DebugTypeExtRefs || !D->isFromASTFile())
|
||||
return nullptr;
|
||||
|
||||
// Record a reference to an imported clang module or precompiled header.
|
||||
llvm::DIModule *ModuleRef = nullptr;
|
||||
auto *Reader = CGM.getContext().getExternalSource();
|
||||
auto Idx = D->getOwningModuleID();
|
||||
auto Info = Reader->getSourceDescriptor(Idx);
|
||||
if (Info)
|
||||
ModuleRef = getOrCreateModuleRef(*Info);
|
||||
ModuleRef = getOrCreateModuleRef(*Info, true);
|
||||
return ModuleRef;
|
||||
}
|
||||
|
||||
@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) {
|
||||
auto *Reader = CGM.getContext().getExternalSource();
|
||||
auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
|
||||
DBuilder.createImportedDeclaration(
|
||||
getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),
|
||||
getOrCreateModuleRef(Info),
|
||||
getLineNumber(ID.getLocation()));
|
||||
getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),
|
||||
getOrCreateModuleRef(Info, DebugTypeExtRefs),
|
||||
getLineNumber(ID.getLocation()));
|
||||
}
|
||||
|
||||
llvm::DIImportedEntity *
|
||||
|
@ -403,9 +403,11 @@ private:
|
||||
/// Get the type from the cache or create a new type if necessary.
|
||||
llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg);
|
||||
|
||||
/// Get a reference to a clang module.
|
||||
/// Get a reference to a clang module. If \p CreateSkeletonCU is true,
|
||||
/// this also creates a split dwarf skeleton compile unit.
|
||||
llvm::DIModule *
|
||||
getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod);
|
||||
getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
|
||||
bool CreateSkeletonCU);
|
||||
|
||||
/// DebugTypeExtRefs: If \p D originated in a clang module, return it.
|
||||
llvm::DIModule *getParentModuleOrNull(const Decl *D);
|
||||
|
Loading…
x
Reference in New Issue
Block a user