}
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);
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;
}
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;
}
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 *
/// 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);