llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
ExternalASTSource::ASTSourceDescriptor Info;
- if (ClangModuleMap) {
+ if (DebugTypeExtRefs && D->isFromASTFile()) {
+ // Record a reference to an imported clang module or precompiled header.
+ auto *Reader = CGM.getContext().getExternalSource();
+ auto Idx = D->getOwningModuleID();
+ auto Info = Reader->getSourceDescriptor(Idx);
+ if (Info)
+ return getOrCreateModuleRef(*Info, /*SkeletonCU=*/true);
+ } else if (ClangModuleMap) {
// We are building a clang module or a precompiled header.
//
// TODO: When D is a CXXRecordDecl or a C++ Enum, the ODR applies
}
}
- if (DebugTypeExtRefs && D->isFromASTFile()) {
- // Record a reference to an imported clang module or precompiled header.
- auto *Reader = CGM.getContext().getExternalSource();
- auto Idx = D->getOwningModuleID();
- auto Info = Reader->getSourceDescriptor(Idx);
- if (Info)
- return getOrCreateModuleRef(*Info, /*SkeletonCU=*/true);
- }
return nullptr;
}
return !Ty->isDependentType() && !Ty->isUndeducedType();
}
+ bool VisitImportDecl(ImportDecl *D) {
+ auto *Import = cast<ImportDecl>(D);
+ if (!Import->getImportedOwningModule())
+ DI.EmitImportDecl(*Import);
+ return true;
+ }
+
bool VisitTypeDecl(TypeDecl *D) {
QualType QualTy = Ctx.getTypeDeclType(D);
if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-format=obj -g -dwarf-ext-refs \
+// RUN: -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs \
+// RUN: %s -mllvm -debug-only=pchcontainer 2>&1 | FileCheck %s
+// REQUIRES: asserts
+
+@import diamond_left;
+
+// CHECK: ![[TOP_DEF:.*]] = distinct !DICompileUnit({{.*}}diamond_top
+// CHECK: ![[LEFT_DEF:.*]] = distinct !DICompileUnit({{.*}}diamond_left
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration,
+// CHECK-SAME: entity: ![[MODULE:.*]], line: 3)
+// CHECK: ![[MODULE]] = !DIModule(scope: null, name: "diamond_top"
+// CHECK: ![[TOP_SKEL_CU:.*]] = distinct !DICompileUnit({{.*}}diamond_top{{.*}}dwoId:
+