Index: lib/IR/DebugInfo.cpp =================================================================== --- lib/IR/DebugInfo.cpp +++ lib/IR/DebugInfo.cpp @@ -283,7 +283,9 @@ Tag != dwarf::DW_TAG_restrict_type && Tag != dwarf::DW_TAG_array_type && Tag != dwarf::DW_TAG_enumeration_type && Tag != dwarf::DW_TAG_subroutine_type && - Tag != dwarf::DW_TAG_inheritance && Tag != dwarf::DW_TAG_friend) + Tag != dwarf::DW_TAG_inheritance && Tag != dwarf::DW_TAG_friend && + Tag != dwarf::DW_TAG_structure_type && Tag != dwarf::DW_TAG_member && + Tag != dwarf::DW_TAG_typedef) return false; } Index: test/DebugInfo/verifier.ll =================================================================== --- /dev/null +++ test/DebugInfo/verifier.ll @@ -0,0 +1,24 @@ +; RUN: opt -verify -S -o /dev/null %s + +; Test that we accept DW_TAG_structure_type, DW_TAG_member and DW_TAG_typedef +; with no source location. These can come up in some languages with predefined +; types. + +!0 = !MDCompositeType(tag: DW_TAG_structure_type, name: "foo", elements: !3) +!1 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "x", type: !5) +!2 = !MDExpression() +!3 = !{!4} +!4 = !MDDerivedType(tag: DW_TAG_member, name: "m", baseType: !0) +!5 = !MDDerivedType(tag: DW_TAG_typedef, name: "td", baseType: !0) + +define void @foo() { + %x = alloca i32 + call void @llvm.dbg.declare(metadata i32* %x, metadata !1, metadata !2) + ret void +} + +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +!llvm.module.flags = !{!100, !101} +!100 = !{i32 2, !"Dwarf Version", i32 2} +!101 = !{i32 2, !"Debug Info Version", i32 3}