354 lines · plain
1; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump - | FileCheck %s --implicit-check-not "{{DW_TAG|NULL}}"2 3; CHECK: debug_info contents4; CHECK:DW_TAG_compile_unit5 6; CHECK: [[NS1:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace7; CHECK: DW_AT_name ("A")8; CHECK-NOT: DW_AT_decl_file9; CHECK-NOT: DW_AT_decl_line10 11; CHECK: [[NS2:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace12; CHECK: DW_AT_name ("B")13; CHECK-NOT: DW_AT_decl_file14; CHECK-NOT: DW_AT_decl_line15 16; CHECK: [[I:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable17; CHECK: DW_AT_name ("i")18; CHECK: [[VAR_FWD:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable19; CHECK: DW_AT_name ("var_fwd")20 21; CHECK: [[FOO:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type22; CHECK: DW_AT_name ("foo")23; CHECK: DW_AT_declaration24; CHECK: [[BAR:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type25; CHECK: DW_AT_name ("bar")26 27; CHECK: DW_TAG_subprogram28; CHECK: DW_AT_MIPS_linkage_name29; CHECK: DW_AT_name ("f1")30; CHECK: [[FUNC1:.*]]: DW_TAG_subprogram31; CHECK: DW_AT_MIPS_linkage_name32; CHECK: DW_AT_name ("f1")33; CHECK: DW_TAG_formal_parameter34; CHECK: NULL35 36; CHECK: [[FUNC_FWD:0x[0-9a-f]*]]:{{.*}}DW_TAG_subprogram37; CHECK: DW_AT_name ("func_fwd")38; CHECK-NOT: DW_AT_declaration39 40; CHECK: [[BAZ:0x[0-9a-f]*]]:{{.*}}DW_TAG_typedef41; CHECK: DW_AT_name ("baz")42 43; CHECK: [[VAR_DECL:0x[0-9a-f]*]]:{{.*}}DW_TAG_variable44; CHECK: DW_AT_name ("var_decl")45; CHECK: DW_AT_declaration46 47; CHECK: [[FUNC_DECL:0x[0-9a-f]*]]:{{.*}}DW_TAG_subprogram48; CHECK: DW_AT_name ("func_decl")49; CHECK: DW_AT_declaration50; CHECK: NULL51 52; CHECK: DW_TAG_imported_module53; CHECK: DW_AT_decl_file ([[F2:.*]])54; CHECK: DW_AT_decl_line (15)55; CHECK: DW_AT_import ([[NS2]])56; CHECK: DW_TAG_imported_declaration57; CHECK: NULL58 59; CHECK: DW_TAG_base_type60; CHECK: DW_TAG_subprogram61 62; CHECK: DW_TAG_subprogram63; CHECK: DW_AT_MIPS_linkage_name64; CHECK: DW_AT_name ("func")65; CHECK: DW_TAG_formal_parameter66; CHECK: DW_TAG_lexical_block67; CHECK: DW_TAG_imported_module68; CHECK: DW_AT_decl_file ([[F2]])69; CHECK: DW_AT_decl_line (23)70; CHECK: DW_AT_import {{.*}}71; CHECK: NULL72; CHECK: DW_TAG_imported_module73; CHECK: DW_AT_decl_file ([[F2:.*]])74; CHECK: DW_AT_decl_line (26)75; CHECK: DW_AT_import ([[NS1]])76; CHECK: DW_TAG_imported_declaration77; CHECK: DW_AT_decl_file ([[F2]])78; CHECK: DW_AT_decl_line (27)79; CHECK: DW_AT_import ([[FOO]])80; CHECK: DW_TAG_imported_declaration81; CHECK: DW_AT_decl_file ([[F2]])82; CHECK: DW_AT_decl_line (28)83; CHECK: DW_AT_import ([[BAR]])84; CHECK: DW_TAG_imported_declaration85; CHECK: DW_AT_decl_file ([[F2]])86; CHECK: DW_AT_decl_line (29)87; CHECK: DW_AT_import ([[FUNC1]])88; CHECK: DW_TAG_imported_declaration89; CHECK: DW_AT_decl_file ([[F2]])90; CHECK: DW_AT_decl_line (30)91; CHECK: DW_AT_import ([[I]])92; CHECK: DW_TAG_imported_declaration93; CHECK: DW_AT_decl_file ([[F2]])94; CHECK: DW_AT_decl_line (31)95; CHECK: DW_AT_import ([[BAZ]])96; CHECK: [[X:0x[0-9a-f]*]]:{{ *}}DW_TAG_imported_declaration97; CHECK: DW_AT_decl_file ([[F2]])98; CHECK: DW_AT_decl_line (32)99; CHECK: DW_AT_import ([[NS1]])100; CHECK: DW_AT_name ("X")101; CHECK: DW_TAG_imported_declaration102; CHECK: DW_AT_decl_file ([[F2]])103; CHECK: DW_AT_decl_line (33)104; CHECK: DW_AT_import ([[X]])105; CHECK: DW_AT_name ("Y")106; CHECK: DW_TAG_imported_declaration107; CHECK: DW_AT_decl_file ([[F2]])108; CHECK: DW_AT_decl_line (34)109; CHECK: DW_AT_import ([[VAR_DECL]])110; CHECK: DW_TAG_imported_declaration111; CHECK: DW_AT_decl_file ([[F2]])112; CHECK: DW_AT_decl_line (35)113; CHECK: DW_AT_import ([[FUNC_DECL]])114; CHECK: DW_TAG_imported_declaration115; CHECK: DW_AT_decl_file ([[F2]])116; CHECK: DW_AT_decl_line (36)117; CHECK: DW_AT_import ([[VAR_FWD]])118; CHECK: DW_TAG_imported_declaration119; CHECK: DW_AT_decl_file ([[F2]])120; CHECK: DW_AT_decl_line (37)121; CHECK: DW_AT_import ([[FUNC_FWD]])122; CHECK: NULL123 124; CHECK: DW_TAG_subprogram125; CHECK: DW_TAG_imported_module126; CHECK: DW_AT_decl_file ([[F2:.*]])127; CHECK: DW_AT_decl_line (18)128; CHECK: DW_AT_import ([[NS1]])129; CHECK: DW_TAG_imported_declaration130; CHECK: DW_TAG_base_type131; CHECK: NULL132 133; IR generated from clang/test/CodeGenCXX/debug-info-namespace.cpp, file paths134; changed to protect the guilty. The C++ source code is:135; // RUN...136; // RUN...137; // RUN...138;139; namespace A {140; #line 1 "foo.cpp"141; namespace B {142; extern int i;143; int f1() { return 0; }144; void f1(int) { }145; struct foo;146; struct bar { };147; typedef bar baz;148; extern int var_decl;149; void func_decl(void);150; extern int var_fwd;151; void func_fwd(void);152; }153; }154; namespace A {155; using namespace B;156; }157;158; using namespace A;159; namespace E = A;160; int B::i = f1();161; int func(bool b) {162; if (b) {163; using namespace A::B;164; return i;165; }166; using namespace A;167; using B::foo;168; using B::bar;169; using B::f1;170; using B::i;171; using B::baz;172; namespace X = A;173; namespace Y = X;174; using B::var_decl;175; using B::func_decl;176; using B::var_fwd;177; using B::func_fwd;178; return i + X::B::i + Y::B::i;179; }180;181; namespace A {182; using B::i;183; namespace B {184; int var_fwd = i;185; }186; }187; void B::func_fwd() {}188 189@_ZN1A1B1iE = global i32 0, align 4, !dbg !131190@_ZN1A1B7var_fwdE = global i32 0, align 4, !dbg !132191@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_debug_info_namespace.cpp, ptr null }]192 193; Function Attrs: nounwind ssp uwtable194define i32 @_ZN1A1B2f1Ev() #0 !dbg !10 {195entry:196 ret i32 0, !dbg !60197}198 199; Function Attrs: nounwind ssp uwtable200define void @_ZN1A1B2f1Ei(i32) #0 !dbg !14 {201entry:202 %.addr = alloca i32, align 4203 store i32 %0, ptr %.addr, align 4204 call void @llvm.dbg.declare(metadata ptr %.addr, metadata !61, metadata !62), !dbg !63205 ret void, !dbg !64206}207 208; Function Attrs: nounwind readnone209declare void @llvm.dbg.declare(metadata, metadata, metadata) #1210 211define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" !dbg !17 {212entry:213 %call = call i32 @_ZN1A1B2f1Ev(), !dbg !65214 store i32 %call, ptr @_ZN1A1B1iE, align 4, !dbg !65215 ret void, !dbg !65216}217 218; Function Attrs: nounwind ssp uwtable219define i32 @_Z4funcb(i1 zeroext %b) #0 !dbg !21 {220entry:221 %retval = alloca i32, align 4222 %b.addr = alloca i8, align 1223 %frombool = zext i1 %b to i8224 store i8 %frombool, ptr %b.addr, align 1225 call void @llvm.dbg.declare(metadata ptr %b.addr, metadata !66, metadata !62), !dbg !67226 %0 = load i8, ptr %b.addr, align 1, !dbg !68227 %tobool = trunc i8 %0 to i1, !dbg !68228 br i1 %tobool, label %if.then, label %if.end, !dbg !68229 230if.then: ; preds = %entry231 %1 = load i32, ptr @_ZN1A1B1iE, align 4, !dbg !69232 store i32 %1, ptr %retval, !dbg !69233 br label %return, !dbg !69234 235if.end: ; preds = %entry236 %2 = load i32, ptr @_ZN1A1B1iE, align 4, !dbg !70237 %3 = load i32, ptr @_ZN1A1B1iE, align 4, !dbg !70238 %add = add nsw i32 %2, %3, !dbg !70239 %4 = load i32, ptr @_ZN1A1B1iE, align 4, !dbg !70240 %add1 = add nsw i32 %add, %4, !dbg !70241 store i32 %add1, ptr %retval, !dbg !70242 br label %return, !dbg !70243 244return: ; preds = %if.end, %if.then245 %5 = load i32, ptr %retval, !dbg !71246 ret i32 %5, !dbg !71247}248 249define internal void @__cxx_global_var_init1() section "__TEXT,__StaticInit,regular,pure_instructions" !dbg !25 {250entry:251 %0 = load i32, ptr @_ZN1A1B1iE, align 4, !dbg !72252 store i32 %0, ptr @_ZN1A1B7var_fwdE, align 4, !dbg !72253 ret void, !dbg !72254}255 256; Function Attrs: nounwind ssp uwtable257define void @_ZN1A1B8func_fwdEv() #0 !dbg !26 {258entry:259 ret void, !dbg !73260}261 262define internal void @_GLOBAL__sub_I_debug_info_namespace.cpp() section "__TEXT,__StaticInit,regular,pure_instructions" {263entry:264 call void @__cxx_global_var_init(), !dbg !74265 call void @__cxx_global_var_init1(), !dbg !74266 ret void, !dbg !74267}268 269attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }270attributes #1 = { nounwind readnone }271 272!llvm.dbg.cu = !{!0}273!llvm.module.flags = !{!57, !58}274!llvm.ident = !{!59}275 276!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !30, imports: !33)277!1 = !DIFile(filename: "debug-info-namespace.cpp", directory: "/tmp")278!2 = !{}279!3 = !{!4, !8}280!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 5, flags: DIFlagFwdDecl, file: !5, scope: !6, identifier: "_ZTSN1A1B3fooE")281!5 = !DIFile(filename: "foo.cpp", directory: "/tmp")282!6 = !DINamespace(name: "B", scope: !7)283!7 = !DINamespace(name: "A", scope: null)284!8 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 6, size: 8, align: 8, file: !5, scope: !6, elements: !2, identifier: "_ZTSN1A1B3barE")285!10 = distinct !DISubprogram(name: "f1", linkageName: "_ZN1A1B2f1Ev", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !5, scope: !6, type: !11, retainedNodes: !2)286!11 = !DISubroutineType(types: !12)287!12 = !{!13}288!13 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)289!14 = distinct !DISubprogram(name: "f1", linkageName: "_ZN1A1B2f1Ei", line: 4, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !5, scope: !6, type: !15, retainedNodes: !2)290!15 = !DISubroutineType(types: !16)291!16 = !{null, !13}292!17 = distinct !DISubprogram(name: "__cxx_global_var_init", line: 20, isLocal: true, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 20, file: !5, scope: !18, type: !19, retainedNodes: !2)293!18 = !DIFile(filename: "foo.cpp", directory: "/tmp")294!19 = !DISubroutineType(types: !20)295!20 = !{null}296!21 = distinct !DISubprogram(name: "func", linkageName: "_Z4funcb", line: 21, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 21, file: !5, scope: !18, type: !22, retainedNodes: !77)297!22 = !DISubroutineType(types: !23)298!23 = !{!13, !24}299!24 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)300!25 = distinct !DISubprogram(name: "__cxx_global_var_init1", line: 44, isLocal: true, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 44, file: !5, scope: !18, type: !19, retainedNodes: !2)301!26 = distinct !DISubprogram(name: "func_fwd", linkageName: "_ZN1A1B8func_fwdEv", line: 47, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 47, file: !5, scope: !6, type: !19, retainedNodes: !2)302!27 = distinct !DISubprogram(name: "", linkageName: "_GLOBAL__sub_I_debug_info_namespace.cpp", isLocal: true, isDefinition: true, flags: DIFlagArtificial, isOptimized: false, unit: !0, file: !1, scope: !28, type: !29, retainedNodes: !2)303!28 = !DIFile(filename: "debug-info-namespace.cpp", directory: "/tmp")304!29 = !DISubroutineType(types: !2)305!30 = !{!131, !132}306!31 = !DIGlobalVariable(name: "i", linkageName: "_ZN1A1B1iE", line: 20, isLocal: false, isDefinition: true, scope: !6, file: !18, type: !13)307!32 = !DIGlobalVariable(name: "var_fwd", linkageName: "_ZN1A1B7var_fwdE", line: 44, isLocal: false, isDefinition: true, scope: !6, file: !18, type: !13)308!33 = !{!34, !35, !36, !56}309!34 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 15, scope: !7, entity: !6)310!35 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 18, scope: !0, entity: !7)311!36 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 19, name: "E", scope: !0, entity: !7)312!37 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 23, scope: !38, entity: !6)313!38 = distinct !DILexicalBlock(line: 22, column: 10, file: !5, scope: !39)314!39 = distinct !DILexicalBlock(line: 22, column: 7, file: !5, scope: !21)315!40 = !DIImportedEntity(tag: DW_TAG_imported_module, file: !5, line: 26, scope: !21, entity: !7)316!41 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 27, scope: !21, entity: !4)317!42 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 28, scope: !21, entity: !8)318!43 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 29, scope: !21, entity: !14)319!44 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 30, scope: !21, entity: !31)320!45 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 31, scope: !21, entity: !46)321!46 = !DIDerivedType(tag: DW_TAG_typedef, name: "baz", line: 7, file: !5, scope: !6, baseType: !8)322!47 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 32, name: "X", scope: !21, entity: !7)323!48 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 33, name: "Y", scope: !21, entity: !47)324!49 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 34, scope: !21, entity: !50)325!50 = !DIGlobalVariable(name: "var_decl", linkageName: "_ZN1A1B8var_declE", line: 8, isLocal: false, isDefinition: false, scope: !6, file: !18, type: !13)326!51 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 35, scope: !21, entity: !52)327!52 = !DISubprogram(name: "func_decl", linkageName: "_ZN1A1B9func_declEv", line: 9, isLocal: false, isDefinition: false, flags: DIFlagPrototyped, isOptimized: false, file: !5, scope: !6, type: !19, retainedNodes: !53)328!53 = !{} ; previously: invalid DW_TAG_base_type329!54 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 36, scope: !21, entity: !32)330!55 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 37, scope: !21, entity: !26)331!56 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !5, line: 42, scope: !7, entity: !31)332!57 = !{i32 2, !"Dwarf Version", i32 3}333!58 = !{i32 2, !"Debug Info Version", i32 3}334!59 = !{!"clang version 3.6.0 "}335!60 = !DILocation(line: 3, column: 12, scope: !10)336!61 = !DILocalVariable(name: "", line: 4, arg: 1, scope: !14, file: !18, type: !13)337!62 = !DIExpression()338!63 = !DILocation(line: 4, column: 12, scope: !14)339!64 = !DILocation(line: 4, column: 16, scope: !14)340!65 = !DILocation(line: 20, column: 12, scope: !17)341!66 = !DILocalVariable(name: "b", line: 21, arg: 1, scope: !21, file: !18, type: !24)342!67 = !DILocation(line: 21, column: 15, scope: !21)343!68 = !DILocation(line: 22, column: 7, scope: !21)344!69 = !DILocation(line: 24, column: 5, scope: !38)345!70 = !DILocation(line: 38, column: 3, scope: !21)346!71 = !DILocation(line: 39, column: 1, scope: !21)347!72 = !DILocation(line: 44, column: 15, scope: !25)348!73 = !DILocation(line: 47, column: 21, scope: !26)349!74 = !DILocation(line: 0, scope: !75)350!75 = !DILexicalBlockFile(discriminator: 0, file: !5, scope: !27)351!77 = !{!37, !40, !41, !42, !43, !44, !45, !47, !48, !49, !51, !54, !55}352!131 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression())353!132 = !DIGlobalVariableExpression(var: !32, expr: !DIExpression())354