1; RUN: %llc_dwarf -debugger-tune=gdb -filetype=obj -o %t.o < %s 2; RUN: llvm-dwarfdump -debug-pubnames %t.o | FileCheck %s 3; ModuleID = 'dwarf-public-names.cpp' 4; 5; Generated from: 6; 7; struct C { 8; void member_function(); 9; static int static_member_function(); 10; static int static_member_variable; 11; }; 12; 13; int C::static_member_variable = 0; 14; 15; void C::member_function() { 16; static_member_variable = 0; 17; } 18; 19; int C::static_member_function() { 20; return static_member_variable; 21; } 22; 23; C global_variable; 24; 25; int global_function() { 26; return -1; 27; } 28; 29; namespace ns { 30; void global_namespace_function() { 31; global_variable.member_function(); 32; } 33; int global_namespace_variable = 1; 34; } 35 36; Skip the output to the header of the pubnames section. 37; CHECK: debug_pubnames 38; CHECK: version = 0x0002 39 40; Check for each name in the output. 41; CHECK-DAG: "ns" 42; CHECK-DAG: "C::static_member_function" 43; CHECK-DAG: "global_variable" 44; CHECK-DAG: "ns::global_namespace_variable" 45; CHECK-DAG: "ns::global_namespace_function" 46; CHECK-DAG: "global_function" 47; CHECK-DAG: "C::static_member_variable" 48; CHECK-DAG: "C::member_function" 49 50source_filename = "test/DebugInfo/Generic/dwarf-public-names.ll" 51 52%struct.C = type { i8 } 53 54@_ZN1C22static_member_variableE = global i32 0, align 4, !dbg !0 55@global_variable = global %struct.C zeroinitializer, align 1, !dbg !15 56@_ZN2ns25global_namespace_variableE = global i32 1, align 4, !dbg !17 57 58; Function Attrs: nounwind uwtable 59define void @_ZN1C15member_functionEv(ptr %this) #0 align 2 !dbg !23 { 60entry: 61 %this.addr = alloca ptr, align 8 62 store ptr %this, ptr %this.addr, align 8 63 call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !24, metadata !26), !dbg !27 64 %this1 = load ptr, ptr %this.addr 65 store i32 0, ptr @_ZN1C22static_member_variableE, align 4, !dbg !28 66 ret void, !dbg !29 67} 68 69; Function Attrs: nounwind readnone 70declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 71 72; Function Attrs: nounwind uwtable 73define i32 @_ZN1C22static_member_functionEv() #0 align 2 !dbg !30 { 74entry: 75 %0 = load i32, ptr @_ZN1C22static_member_variableE, align 4, !dbg !31 76 ret i32 %0, !dbg !31 77} 78 79; Function Attrs: nounwind uwtable 80define i32 @_Z15global_functionv() #0 !dbg !32 { 81entry: 82 ret i32 -1, !dbg !33 83} 84 85; Function Attrs: nounwind uwtable 86define void @_ZN2ns25global_namespace_functionEv() #0 !dbg !34 { 87entry: 88 call void @_ZN1C15member_functionEv(ptr @global_variable), !dbg !37 89 ret void, !dbg !38 90} 91 92attributes #0 = { nounwind uwtable } 93attributes #1 = { nounwind readnone } 94 95!llvm.dbg.cu = !{!20} 96!llvm.module.flags = !{!22} 97 98!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 99!1 = !DIGlobalVariable(name: "static_member_variable", linkageName: "_ZN1C22static_member_variableE", scope: !2, file: !3, line: 7, type: !6, isLocal: false, isDefinition: true, declaration: !5) 100!2 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !3, line: 1, size: 8, align: 8, elements: !4) 101!3 = !DIFile(filename: "dwarf-public-names.cpp", directory: "/usr2/kparzysz/s.hex/t") 102!4 = !{!5, !7, !12} 103!5 = !DIDerivedType(tag: DW_TAG_member, name: "static_member_variable", scope: !2, file: !3, line: 4, baseType: !6, flags: DIFlagStaticMember) 104!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 105!7 = !DISubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: false, scopeLine: 2, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, retainedNodes: !11) 106!8 = !DISubroutineType(types: !9) 107!9 = !{null, !10} 108!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !2, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 109!11 = !{} 110!12 = !DISubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", scope: !2, file: !3, line: 3, type: !13, isLocal: false, isDefinition: false, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, retainedNodes: !11) 111!13 = !DISubroutineType(types: !14) 112!14 = !{!6} 113!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression()) 114!16 = !DIGlobalVariable(name: "global_variable", scope: null, file: !3, line: 17, type: !2, isLocal: false, isDefinition: true) ; previously: invalid DW_TAG_base_type 115!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression()) 116!18 = !DIGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", scope: !19, file: !3, line: 27, type: !6, isLocal: false, isDefinition: true) 117!19 = !DINamespace(name: "ns", scope: null) 118!20 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !21, imports: !11) ; previously: invalid DW_TAG_base_type 119!21 = !{!0, !15, !17} 120!22 = !{i32 1, !"Debug Info Version", i32 3} 121!23 = distinct !DISubprogram(name: "member_function", linkageName: "_ZN1C15member_functionEv", scope: null, file: !3, line: 9, type: !8, isLocal: false, isDefinition: true, scopeLine: 9, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, declaration: !7, retainedNodes: !11) 122!24 = !DILocalVariable(name: "this", arg: 1, scope: !23, file: !3, line: 9, type: !25, flags: DIFlagArtificial | DIFlagObjectPointer) 123!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !2, size: 64, align: 64) 124!26 = !DIExpression() 125!27 = !DILocation(line: 9, scope: !23) 126!28 = !DILocation(line: 10, scope: !23) 127!29 = !DILocation(line: 11, scope: !23) 128!30 = distinct !DISubprogram(name: "static_member_function", linkageName: "_ZN1C22static_member_functionEv", scope: null, file: !3, line: 13, type: !13, isLocal: false, isDefinition: true, scopeLine: 13, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, declaration: !12, retainedNodes: !11) 129!31 = !DILocation(line: 14, scope: !30) 130!32 = distinct !DISubprogram(name: "global_function", linkageName: "_Z15global_functionv", scope: !3, file: !3, line: 19, type: !13, isLocal: false, isDefinition: true, scopeLine: 19, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, retainedNodes: !11) 131!33 = !DILocation(line: 20, scope: !32) 132!34 = distinct !DISubprogram(name: "global_namespace_function", linkageName: "_ZN2ns25global_namespace_functionEv", scope: !19, file: !3, line: 24, type: !35, isLocal: false, isDefinition: true, scopeLine: 24, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !20, retainedNodes: !11) 133!35 = !DISubroutineType(types: !36) 134!36 = !{null} 135!37 = !DILocation(line: 25, scope: !34) 136!38 = !DILocation(line: 26, scope: !34) 137 138