/// Does a type definition exist in an imported clang module?
static bool isDefinedInClangModule(const RecordDecl *RD) {
- if (!RD->isFromASTFile())
- return false;
- if (!RD->getDefinition())
+ if (!RD || !RD->isFromASTFile())
return false;
if (!RD->isExternallyVisible() && RD->getName().empty())
return false;
static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
bool DebugTypeExtRefs, const RecordDecl *RD,
const LangOptions &LangOpts) {
- if (DebugTypeExtRefs && isDefinedInClangModule(RD))
+ if (DebugTypeExtRefs && isDefinedInClangModule(RD->getDefinition()))
return true;
if (DebugKind > codegenoptions::LimitedDebugInfo)
InAnonymousNamespace anon;
+// Forward-declared in the module.
+struct PureFwdDecl { int i; };
+PureFwdDecl definedLocally;
+
void foo() {
anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
}
// CHECK-SAME: templateParams:
// CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
+// This type is defined locally and forward-declare in the module.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "PureFwdDecl",
+// CHECK-SAME: elements:
+// CHECK-SAME: identifier: "_ZTS11PureFwdDecl")
+
// CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]]
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
// CHECK-SAME: line: 16