diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1729,6 +1729,8 @@ Flags |= llvm::DINode::FlagLValueReference; if (Method->getRefQualifier() == RQ_RValue) Flags |= llvm::DINode::FlagRValueReference; + if (!Method->isExternallyVisible()) + SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit; if (CGM.getLangOpts().Optimize) SPFlags |= llvm::DISubprogram::SPFlagOptimized; diff --git a/clang/test/CodeGenCXX/debug-info-class.cpp b/clang/test/CodeGenCXX/debug-info-class.cpp --- a/clang/test/CodeGenCXX/debug-info-class.cpp +++ b/clang/test/CodeGenCXX/debug-info-class.cpp @@ -24,12 +24,14 @@ C::~C() { } +namespace { struct D { - D(); - virtual ~D(); + D() {} + virtual ~D() {} void func() { } }; +} // namespace struct E { E(); @@ -135,11 +137,13 @@ // CHECK-SAME: DIFlagStaticMember // CHECK: [[C_DTOR]] = !DISubprogram(name: "~C" -// CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "D" +// CHECK: [[D:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D" // CHECK-SAME: size: -// CHECK-SAME: DIFlagFwdDecl // CHECK-NOT: identifier: // CHECK-SAME: ){{$}} +// CHECK: [[D_FUNC_DECL:![0-9]*]] = !DISubprogram(name: "func",{{.*}} scope: [[D]] +// CHECK-SAME: DISPFlagLocalToUnit + // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "E" // CHECK-SAME: DIFlagFwdDecl // CHECK-NOT: identifier: @@ -150,11 +154,10 @@ // CHECK-SAME: ){{$}} // CHECK: !DISubprogram(name: "func",{{.*}} scope: [[D]] -// CHECK-SAME: DISPFlagDefinition -// CHECK-SAME: declaration: [[D_FUNC_DECL:![0-9]*]] -// CHECK: [[D_FUNC_DECL]] = !DISubprogram(name: "func",{{.*}} scope: [[D]] +// CHECK-SAME: DISPFlagLocalToUnit | DISPFlagDefinition +// CHECK-SAME: declaration: [[D_FUNC_DECL]] -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} line: 50 +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} line: 52 // CHECK-NOT: DIFlagFwdDecl // CHECK-SAME: elements: [[G_INNER_MEM:![0-9]*]] // CHECK-SAME: identifier: "_ZTSN1G5innerE" @@ -170,5 +173,5 @@ // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "A" // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "HdrSize" // -// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 91, -// CHECK: ![[RETLOC]] = !DILocation(line: 90, +// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 93, +// CHECK: ![[RETLOC]] = !DILocation(line: 92,