ModuleDebugInfo.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // Test that (the same) debug info is emitted for an Objective-C++
  2. // module and a C++ precompiled header.
  3. // REQUIRES: asserts
  4. // Modules:
  5. // RUN: rm -rf %t
  6. // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
  7. // RUN: cat %t-mod.ll | FileCheck %s
  8. // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
  9. // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
  10. // PCH:
  11. // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
  12. // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-CXX %s
  13. // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
  14. #ifdef MODULES
  15. @import DebugCXX;
  16. #endif
  17. // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
  18. // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
  19. // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
  20. // CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
  21. // CHECK-SAME: isOptimized: false,
  22. // CHECK-NOT: splitDebugFilename:
  23. // CHECK-SAME: dwoId:
  24. // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum"
  25. // CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
  26. // CHECK: !DINamespace(name: "DebugCXX"
  27. // CHECK-MOD: ![[DEBUGCXX:.*]] = !DIModule(scope: null, name: "DebugCXX
  28. // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
  29. // CHECK-NOT: name:
  30. // CHECK-SAME: )
  31. // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
  32. // CHECK-NOT: name:
  33. // CHECK-SAME: )
  34. // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
  35. // CHECK-NOT: name:
  36. // CHECK-SAME: identifier: "_ZTS11TypedefEnum")
  37. // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
  38. // CHECK-NOT: name:
  39. // CHECK-SAME: )
  40. // CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
  41. // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
  42. // no mangled name here yet.
  43. // This type is anchored by a function parameter.
  44. // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>"
  45. // CHECK-SAME: elements:
  46. // CHECK-SAME: templateParams:
  47. // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
  48. // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
  49. // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
  50. // This type is anchored by an explicit template instantiation.
  51. // CHECK: !DICompositeType(tag: DW_TAG_class_type,
  52. // CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >"
  53. // CHECK-SAME: elements:
  54. // CHECK-SAME: templateParams:
  55. // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
  56. // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<int>"
  57. // CHECK-SAME: flags: DIFlagFwdDecl
  58. // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIiEE")
  59. // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<float>"
  60. // CHECK-SAME: elements:
  61. // CHECK-SAME: templateParams:
  62. // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIfEE")
  63. // CHECK: !DICompositeType(tag: DW_TAG_class_type,
  64. // CHECK-SAME: name: "Template<long, DebugCXX::traits<long> >"
  65. // CHECK-SAME: elements:
  66. // CHECK-SAME: templateParams:
  67. // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE")
  68. // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
  69. // no mangled name here yet.
  70. // CHECK: !DICompositeType(tag: DW_TAG_class_type,
  71. // CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >"
  72. // CHECK-SAME: flags: DIFlagFwdDecl
  73. // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
  74. // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual"
  75. // CHECK-SAME: elements:
  76. // CHECK-SAME: identifier: "_ZTS7Virtual")
  77. // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "_vptr$Virtual"
  78. // CHECK: !DICompositeType(tag: DW_TAG_union_type,
  79. // CHECK-NOT: name:
  80. // CHECK-SAME: identifier: "_ZTS12TypedefUnion")
  81. // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
  82. // CHECK-NOT: name:
  83. // CHECK-SAME: identifier: "_ZTS13TypedefStruct")
  84. // CHECK: !DICompositeType(tag: DW_TAG_union_type,
  85. // CHECK-NOT: name:
  86. // CHECK-SAME: )
  87. // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
  88. // CHECK-NOT: name:
  89. // CHECK-SAME: )
  90. // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
  91. // CHECK-SAME: name: "InAnonymousNamespace",
  92. // CHECK-SAME: elements: !{{[0-9]+}})
  93. // CHECK: ![[A:.*]] = {{.*}}!DICompositeType(tag: DW_TAG_class_type, name: "A",
  94. // CHECK-SAME: elements:
  95. // CHECK-SAME: vtableHolder: ![[A]])
  96. // CHECK: ![[DERIVED:.*]] = {{.*}}!DICompositeType(tag: DW_TAG_class_type, name: "Derived",
  97. // CHECK-SAME: identifier: "_ZTS7Derived")
  98. // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: ![[DERIVED]],
  99. // CHECK-SAME: elements: ![[B_MBRS:.*]], vtableHolder:
  100. // CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}
  101. // CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"
  102. // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefTemplate",
  103. // CHECK-SAME: baseType: ![[BASE:.*]])
  104. // CHECK: ![[BASE]] = !DICompositeType(tag: DW_TAG_class_type,
  105. // CHECK-SAME: name: "Template1<void *>",
  106. // CHECK-SAME: flags: DIFlagFwdDecl,
  107. // CHECK-SAME: identifier: "_ZTS9Template1IPvE")
  108. // Explicit instantiation.
  109. // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<int>",
  110. // CHECK-SAME: templateParams:
  111. // CHECK-SAME: identifier: "_ZTS9Template1IiE")
  112. // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate<int>",
  113. // CHECK-SAME: flags: DIFlagFwdDecl
  114. // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
  115. // Forward-declared member of a template.
  116. // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
  117. // CHECK-SAME: flags: DIFlagFwdDecl
  118. // CHECK-SAME: identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
  119. // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "SpecializedBase",
  120. // CHECK-SAME: baseType: ![[SPECIALIZEDBASE:.*]])
  121. // CHECK: ![[SPECIALIZEDBASE]] = !DICompositeType(tag: DW_TAG_class_type,
  122. // CHECK-SAME: name: "WithSpecializedBase<float>",
  123. // CHECK-SAME: flags: DIFlagFwdDecl,
  124. // CHECK-MOD: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: ![[DEBUGCXX]],
  125. // CHECK-MOD-SAME: entity: ![[DUMMY:[0-9]+]],
  126. // CHECK-MOD-SAME: line: 3)
  127. // CHECK-MOD: ![[DUMMY]] = !DIModule(scope: null, name: "dummy",
  128. // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_ObjC_plus_plus,
  129. // CHECK-MOD-SAME: splitDebugFilename: "{{.*}}dummy{{.*}}.pcm",
  130. // CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"