brintos

brintos / llvm-project-archived public Read only

0
0
Text · 62.5 KiB · cef3a25 Raw
1956 lines · cpp
1//===-- DWARFASTParserClangTests.cpp --------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"10#include "Plugins/SymbolFile/DWARF/DWARFCompileUnit.h"11#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"12#include "TestingSupport/Symbol/ClangTestUtils.h"13#include "TestingSupport/Symbol/YAMLModuleTester.h"14#include "lldb/Core/Debugger.h"15#include "gmock/gmock.h"16#include "gtest/gtest.h"17 18using namespace lldb;19using namespace lldb_private;20using namespace lldb_private::plugin::dwarf;21using namespace llvm::dwarf;22 23namespace {24static std::once_flag debugger_initialize_flag;25 26class DWARFASTParserClangTests : public testing::Test {27  void SetUp() override {28    std::call_once(debugger_initialize_flag,29                   []() { Debugger::Initialize(nullptr); });30  }31};32 33class DWARFASTParserClangStub : public DWARFASTParserClang {34public:35  using DWARFASTParserClang::DWARFASTParserClang;36  using DWARFASTParserClang::LinkDeclContextToDIE;37 38  std::vector<const clang::DeclContext *> GetDeclContextToDIEMapKeys() {39    std::vector<const clang::DeclContext *> keys;40    for (const auto &it : m_decl_ctx_to_die)41      keys.push_back(it.first);42    return keys;43  }44};45} // namespace46 47// If your implementation needs to dereference the dummy pointers we are48// defining here, causing this test to fail, feel free to delete it.49TEST_F(DWARFASTParserClangTests,50       EnsureAllDIEsInDeclContextHaveBeenParsedParsesOnlyMatchingEntries) {51 52  /// Auxiliary debug info.53  const char *yamldata = R"(54--- !ELF55FileHeader:56  Class:   ELFCLASS6457  Data:    ELFDATA2LSB58  Type:    ET_EXEC59  Machine: EM_38660DWARF:61  debug_abbrev:62    - Table:63        - Code:            0x0000000164          Tag:             DW_TAG_compile_unit65          Children:        DW_CHILDREN_yes66          Attributes:67            - Attribute:       DW_AT_language68              Form:            DW_FORM_data269        - Code:            0x0000000270          Tag:             DW_TAG_base_type71          Children:        DW_CHILDREN_no72          Attributes:73            - Attribute:       DW_AT_encoding74              Form:            DW_FORM_data175            - Attribute:       DW_AT_byte_size76              Form:            DW_FORM_data177  debug_info:78    - Version:         479      AddrSize:        880      Entries:81        - AbbrCode:        0x0000000182          Values:83            - Value:           0x000000000000000C84        - AbbrCode:        0x0000000285          Values:86            - Value:           0x0000000000000007 # DW_ATE_unsigned87            - Value:           0x000000000000000488        - AbbrCode:        0x0000000289          Values:90            - Value:           0x0000000000000007 # DW_ATE_unsigned91            - Value:           0x000000000000000892        - AbbrCode:        0x0000000293          Values:94            - Value:           0x0000000000000005 # DW_ATE_signed95            - Value:           0x000000000000000896        - AbbrCode:        0x0000000297          Values:98            - Value:           0x0000000000000008 # DW_ATE_unsigned_char99            - Value:           0x0000000000000001100        - AbbrCode:        0x00000000101)";102 103  YAMLModuleTester t(yamldata);104  ASSERT_TRUE((bool)t.GetDwarfUnit());105 106  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");107  auto &ast_ctx = *holder->GetAST();108 109  DWARFASTParserClangStub ast_parser(ast_ctx);110 111  DWARFUnit *unit = t.GetDwarfUnit();112  const DWARFDebugInfoEntry *die_first = unit->DIE().GetDIE();113  const DWARFDebugInfoEntry *die_child0 = die_first->GetFirstChild();114  const DWARFDebugInfoEntry *die_child1 = die_child0->GetSibling();115  const DWARFDebugInfoEntry *die_child2 = die_child1->GetSibling();116  const DWARFDebugInfoEntry *die_child3 = die_child2->GetSibling();117  std::vector<DWARFDIE> dies = {118      DWARFDIE(unit, die_child0), DWARFDIE(unit, die_child1),119      DWARFDIE(unit, die_child2), DWARFDIE(unit, die_child3)};120  std::vector<clang::DeclContext *> decl_ctxs = {121      (clang::DeclContext *)1LL, (clang::DeclContext *)2LL,122      (clang::DeclContext *)2LL, (clang::DeclContext *)3LL};123  for (int i = 0; i < 4; ++i)124    ast_parser.LinkDeclContextToDIE(decl_ctxs[i], dies[i]);125  ast_parser.EnsureAllDIEsInDeclContextHaveBeenParsed(126      CompilerDeclContext(nullptr, decl_ctxs[1]));127 128  EXPECT_THAT(ast_parser.GetDeclContextToDIEMapKeys(),129              testing::UnorderedElementsAre(decl_ctxs[0], decl_ctxs[3]));130}131 132TEST_F(DWARFASTParserClangTests, TestCallingConventionParsing) {133  // Tests parsing DW_AT_calling_convention values.134 135  // The DWARF below just declares a list of function types with136  // DW_AT_calling_convention on them.137  const char *yamldata = R"(138--- !ELF139FileHeader:140  Class:   ELFCLASS32141  Data:    ELFDATA2LSB142  Type:    ET_EXEC143  Machine: EM_386144DWARF:145  debug_str:146    - func1147    - func2148    - func3149    - func4150    - func5151    - func6152    - func7153    - func8154    - func9155  debug_abbrev:156    - ID:              0157      Table:158        - Code:            0x1159          Tag:             DW_TAG_compile_unit160          Children:        DW_CHILDREN_yes161          Attributes:162            - Attribute:       DW_AT_language163              Form:            DW_FORM_data2164        - Code:            0x2165          Tag:             DW_TAG_subprogram166          Children:        DW_CHILDREN_no167          Attributes:168            - Attribute:       DW_AT_low_pc169              Form:            DW_FORM_addr170            - Attribute:       DW_AT_high_pc171              Form:            DW_FORM_data4172            - Attribute:       DW_AT_name173              Form:            DW_FORM_strp174            - Attribute:       DW_AT_calling_convention175              Form:            DW_FORM_data1176            - Attribute:       DW_AT_external177              Form:            DW_FORM_flag_present178  debug_info:179    - Version:         4180      AddrSize:        4181      Entries:182        - AbbrCode:        0x1183          Values:184            - Value:           0xC185        - AbbrCode:        0x2186          Values:187            - Value:           0x0188            - Value:           0x5189            - Value:           0x00190            - Value:           0xCB191            - Value:           0x1192        - AbbrCode:        0x2193          Values:194            - Value:           0x10195            - Value:           0x5196            - Value:           0x06197            - Value:           0xB3198            - Value:           0x1199        - AbbrCode:        0x2200          Values:201            - Value:           0x20202            - Value:           0x5203            - Value:           0x0C204            - Value:           0xB1205            - Value:           0x1206        - AbbrCode:        0x2207          Values:208            - Value:           0x30209            - Value:           0x5210            - Value:           0x12211            - Value:           0xC0212            - Value:           0x1213        - AbbrCode:        0x2214          Values:215            - Value:           0x40216            - Value:           0x5217            - Value:           0x18218            - Value:           0xB2219            - Value:           0x1220        - AbbrCode:        0x2221          Values:222            - Value:           0x50223            - Value:           0x5224            - Value:           0x1E225            - Value:           0xC1226            - Value:           0x1227        - AbbrCode:        0x2228          Values:229            - Value:           0x60230            - Value:           0x5231            - Value:           0x24232            - Value:           0xC2233            - Value:           0x1234        - AbbrCode:        0x2235          Values:236            - Value:           0x70237            - Value:           0x5238            - Value:           0x2a239            - Value:           0xEE240            - Value:           0x1241        - AbbrCode:        0x2242          Values:243            - Value:           0x80244            - Value:           0x5245            - Value:           0x30246            - Value:           0x01247            - Value:           0x1248        - AbbrCode:        0x0249...250)";251  YAMLModuleTester t(yamldata);252 253  DWARFUnit *unit = t.GetDwarfUnit();254  ASSERT_NE(unit, nullptr);255  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();256  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);257  DWARFDIE cu_die(unit, cu_entry);258 259  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");260  auto &ast_ctx = *holder->GetAST();261  DWARFASTParserClangStub ast_parser(ast_ctx);262 263  std::vector<std::string> found_function_types;264  // The DWARF above is just a list of functions. Parse all of them to265  // extract the function types and their calling convention values.266  for (DWARFDIE func : cu_die.children()) {267    ASSERT_EQ(func.Tag(), DW_TAG_subprogram);268    SymbolContext sc;269    bool new_type = false;270    lldb::TypeSP type = ast_parser.ParseTypeFromDWARF(sc, func, &new_type);271    found_function_types.push_back(272        type->GetForwardCompilerType().GetTypeName().AsCString());273  }274 275  // Compare the parsed function types against the expected list of types.276  const std::vector<std::string> expected_function_types = {277      "void () __attribute__((regcall))",278      "void () __attribute__((fastcall))",279      "void () __attribute__((stdcall))",280      "void () __attribute__((vectorcall))",281      "void () __attribute__((pascal))",282      "void () __attribute__((ms_abi))",283      "void () __attribute__((sysv_abi))",284      "void ()", // invalid calling convention.285      "void ()", // DW_CC_normal -> no attribute286  };287  ASSERT_EQ(found_function_types, expected_function_types);288}289 290TEST_F(DWARFASTParserClangTests, TestPtrAuthParsing) {291  // Tests parsing values with type DW_TAG_LLVM_ptrauth_type corresponding to292  // explicitly signed raw function pointers293 294  // This is Dwarf for the following C code:295  // ```296  // void (*__ptrauth(0, 0, 42) a)();297  // ```298 299  const char *yamldata = R"(300--- !ELF301FileHeader:302  Class:   ELFCLASS64303  Data:    ELFDATA2LSB304  Type:    ET_EXEC305  Machine: EM_AARCH64306DWARF:307  debug_str:308    - a309  debug_abbrev:310    - ID:              0311      Table:312        - Code:            0x01313          Tag:             DW_TAG_compile_unit314          Children:        DW_CHILDREN_yes315          Attributes:316            - Attribute:       DW_AT_language317              Form:            DW_FORM_data2318        - Code:            0x02319          Tag:             DW_TAG_variable320          Children:        DW_CHILDREN_no321          Attributes:322            - Attribute:       DW_AT_name323              Form:            DW_FORM_strp324            - Attribute:       DW_AT_type325              Form:            DW_FORM_ref4326            - Attribute:       DW_AT_external327              Form:            DW_FORM_flag_present328        - Code:            0x03329          Tag:             DW_TAG_LLVM_ptrauth_type330          Children:        DW_CHILDREN_no331          Attributes:332            - Attribute:       DW_AT_type333              Form:            DW_FORM_ref4334            - Attribute:       DW_AT_LLVM_ptrauth_key335              Form:            DW_FORM_data1336            - Attribute:       DW_AT_LLVM_ptrauth_extra_discriminator337              Form:            DW_FORM_data2338        - Code:            0x04339          Tag:             DW_TAG_pointer_type340          Children:        DW_CHILDREN_no341          Attributes:342            - Attribute:       DW_AT_type343              Form:            DW_FORM_ref4344        - Code:            0x05345          Tag:             DW_TAG_subroutine_type346          Children:        DW_CHILDREN_yes347        - Code:            0x06348          Tag:             DW_TAG_unspecified_parameters349          Children:        DW_CHILDREN_no350 351  debug_info:352    - Version:         5353      UnitType:        DW_UT_compile354      AddrSize:        8355      Entries:356# 0x0c: DW_TAG_compile_unit357#         DW_AT_language [DW_FORM_data2]    (DW_LANG_C99)358        - AbbrCode:        0x01359          Values:360            - Value:           0x0c361 362# 0x0f:   DW_TAG_variable363#           DW_AT_name [DW_FORM_strp]       (\"a\")364#           DW_AT_type [DW_FORM_ref4]       (0x00000018 \"void (*__ptrauth(0, 0, 0x02a)\")365#           DW_AT_external [DW_FORM_flag_present]   (true)366        - AbbrCode:        0x02367          Values:368            - Value:           0x00369            - Value:           0x18370 371# 0x18:   DW_TAG_LLVM_ptrauth_type372#           DW_AT_type [DW_FORM_ref4]       (0x00000020 \"void (*)(...)\")373#           DW_AT_LLVM_ptrauth_key [DW_FORM_data1]  (0x00)374#           DW_AT_LLVM_ptrauth_extra_discriminator [DW_FORM_data2]  (0x002a)375        - AbbrCode:        0x03376          Values:377            - Value:           0x20378            - Value:           0x00379            - Value:           0x2a380 381# 0x20:   DW_TAG_pointer_type382#           DW_AT_type [DW_AT_type [DW_FORM_ref4]       (0x00000025 \"void (...)\")383        - AbbrCode:        0x04384          Values:385            - Value:           0x25386 387# 0x25:   DW_TAG_subroutine_type388        - AbbrCode:        0x05389 390# 0x26:     DW_TAG_unspecified_parameters391        - AbbrCode:        0x06392 393        - AbbrCode:        0x00 # end of child tags of 0x25394        - AbbrCode:        0x00 # end of child tags of 0x0c395...396)";397  YAMLModuleTester t(yamldata);398 399  DWARFUnit *unit = t.GetDwarfUnit();400  ASSERT_NE(unit, nullptr);401  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();402  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);403  DWARFDIE cu_die(unit, cu_entry);404 405  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");406  auto &ast_ctx = *holder->GetAST();407  DWARFASTParserClangStub ast_parser(ast_ctx);408 409  DWARFDIE ptrauth_variable = cu_die.GetFirstChild();410  ASSERT_EQ(ptrauth_variable.Tag(), DW_TAG_variable);411  DWARFDIE ptrauth_type =412      ptrauth_variable.GetAttributeValueAsReferenceDIE(DW_AT_type);413  ASSERT_EQ(ptrauth_type.Tag(), DW_TAG_LLVM_ptrauth_type);414 415  SymbolContext sc;416  bool new_type = false;417  lldb::TypeSP type_sp =418      ast_parser.ParseTypeFromDWARF(sc, ptrauth_type, &new_type);419  CompilerType compiler_type = type_sp->GetForwardCompilerType();420  ASSERT_EQ(compiler_type.GetPtrAuthKey(), 0U);421  ASSERT_EQ(compiler_type.GetPtrAuthAddressDiversity(), false);422  ASSERT_EQ(compiler_type.GetPtrAuthDiscriminator(), 42U);423}424 425struct ExtractIntFromFormValueTest : public testing::Test {426  SubsystemRAII<FileSystem, HostInfo> subsystems;427  clang_utils::TypeSystemClangHolder holder;428  TypeSystemClang &ts;429 430  DWARFASTParserClang parser;431  ExtractIntFromFormValueTest()432      : holder("dummy ASTContext"), ts(*holder.GetAST()), parser(ts) {}433 434  /// Takes the given integer value, stores it in a DWARFFormValue and then435  /// tries to extract the value back via436  /// DWARFASTParserClang::ExtractIntFromFormValue.437  /// Returns the string representation of the extracted value or the error438  /// that was returned from ExtractIntFromFormValue.439  llvm::Expected<std::string> Extract(clang::QualType qt, uint64_t value) {440    DWARFFormValue form_value;441    form_value.SetUnsigned(value);442    llvm::Expected<llvm::APInt> result =443        parser.ExtractIntFromFormValue(ts.GetType(qt), form_value);444    if (!result)445      return result.takeError();446    llvm::SmallString<16> result_str;447    result->toStringUnsigned(result_str);448    return std::string(result_str.str());449  }450 451  /// Same as ExtractIntFromFormValueTest::Extract but takes a signed integer452  /// and treats the result as a signed integer.453  llvm::Expected<std::string> ExtractS(clang::QualType qt, int64_t value) {454    DWARFFormValue form_value;455    form_value.SetSigned(value);456    llvm::Expected<llvm::APInt> result =457        parser.ExtractIntFromFormValue(ts.GetType(qt), form_value);458    if (!result)459      return result.takeError();460    llvm::SmallString<16> result_str;461    result->toStringSigned(result_str);462    return std::string(result_str.str());463  }464};465 466TEST_F(ExtractIntFromFormValueTest, TestBool) {467  using namespace llvm;468  clang::ASTContext &ast = ts.getASTContext();469 470  EXPECT_THAT_EXPECTED(Extract(ast.BoolTy, 0), HasValue("0"));471  EXPECT_THAT_EXPECTED(Extract(ast.BoolTy, 1), HasValue("1"));472  EXPECT_THAT_EXPECTED(Extract(ast.BoolTy, 2), Failed());473  EXPECT_THAT_EXPECTED(Extract(ast.BoolTy, 3), Failed());474}475 476TEST_F(ExtractIntFromFormValueTest, TestInt) {477  using namespace llvm;478 479  clang::ASTContext &ast = ts.getASTContext();480 481  // Find the min/max values for 'int' on the current host target.482  constexpr int64_t int_max = std::numeric_limits<int>::max();483  constexpr int64_t int_min = std::numeric_limits<int>::min();484 485  // Check that the bit width of int matches the int width in our type system.486  ASSERT_EQ(sizeof(int) * 8, ast.getIntWidth(ast.IntTy));487 488  // Check values around int_min.489  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_min - 2), llvm::Failed());490  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_min - 1), llvm::Failed());491  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_min),492                       HasValue(std::to_string(int_min)));493  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_min + 1),494                       HasValue(std::to_string(int_min + 1)));495  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_min + 2),496                       HasValue(std::to_string(int_min + 2)));497 498  // Check values around 0.499  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, -128), HasValue("-128"));500  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, -10), HasValue("-10"));501  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, -1), HasValue("-1"));502  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, 0), HasValue("0"));503  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, 1), HasValue("1"));504  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, 10), HasValue("10"));505  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, 128), HasValue("128"));506 507  // Check values around int_max.508  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_max - 2),509                       HasValue(std::to_string(int_max - 2)));510  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_max - 1),511                       HasValue(std::to_string(int_max - 1)));512  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_max),513                       HasValue(std::to_string(int_max)));514  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_max + 1), llvm::Failed());515  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_max + 5), llvm::Failed());516 517  // Check some values not near an edge case.518  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_max / 2),519                       HasValue(std::to_string(int_max / 2)));520  EXPECT_THAT_EXPECTED(ExtractS(ast.IntTy, int_min / 2),521                       HasValue(std::to_string(int_min / 2)));522}523 524TEST_F(ExtractIntFromFormValueTest, TestUnsignedInt) {525  using namespace llvm;526 527  clang::ASTContext &ast = ts.getASTContext();528  constexpr uint64_t uint_max = std::numeric_limits<uint32_t>::max();529 530  // Check values around 0.531  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, 0), HasValue("0"));532  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, 1), HasValue("1"));533  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, 1234), HasValue("1234"));534 535  // Check some values not near an edge case.536  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, uint_max / 2),537                       HasValue(std::to_string(uint_max / 2)));538 539  // Check values around uint_max.540  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, uint_max - 2),541                       HasValue(std::to_string(uint_max - 2)));542  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, uint_max - 1),543                       HasValue(std::to_string(uint_max - 1)));544  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, uint_max),545                       HasValue(std::to_string(uint_max)));546  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, uint_max + 1),547                       llvm::Failed());548  EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, uint_max + 2),549                       llvm::Failed());550}551 552TEST_F(DWARFASTParserClangTests, TestDefaultTemplateParamParsing) {553  // Tests parsing DW_AT_default_value for template parameters.554  auto BufferOrError = llvm::MemoryBuffer::getFile(555      GetInputFilePath("DW_AT_default_value-test.yaml"), /*IsText=*/true);556  ASSERT_TRUE(BufferOrError);557  YAMLModuleTester t(BufferOrError.get()->getBuffer());558 559  DWARFUnit *unit = t.GetDwarfUnit();560  ASSERT_NE(unit, nullptr);561  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();562  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);563  DWARFDIE cu_die(unit, cu_entry);564 565  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");566  auto &ast_ctx = *holder->GetAST();567  DWARFASTParserClangStub ast_parser(ast_ctx);568 569  llvm::SmallVector<lldb::TypeSP, 2> types;570  for (DWARFDIE die : cu_die.children()) {571    if (die.Tag() == DW_TAG_class_type) {572      SymbolContext sc;573      bool new_type = false;574      types.push_back(ast_parser.ParseTypeFromDWARF(sc, die, &new_type));575    }576  }577 578  ASSERT_EQ(types.size(), 3U);579 580  auto check_decl = [](auto const *decl) {581    clang::ClassTemplateSpecializationDecl const *ctsd =582        llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>(decl);583    ASSERT_NE(ctsd, nullptr);584 585    auto const &args = ctsd->getTemplateArgs();586    ASSERT_GT(args.size(), 0U);587 588    for (auto const &arg : args.asArray()) {589      EXPECT_TRUE(arg.getIsDefaulted());590    }591  };592 593  for (auto const &type_sp : types) {594    ASSERT_NE(type_sp, nullptr);595    auto const *decl = ClangUtil::GetAsTagDecl(type_sp->GetFullCompilerType());596    if (decl->getName() == "bar" || decl->getName() == "baz") {597      check_decl(decl);598    }599  }600}601 602TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {603  // Tests that parsing a ClassTemplateSpecializationDecl that already exists604  // is handled gracefully.605  auto BufferOrError = llvm::MemoryBuffer::getFile(606      GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);607  ASSERT_TRUE(BufferOrError);608  YAMLModuleTester t(BufferOrError.get()->getBuffer());609 610  DWARFUnit *unit = t.GetDwarfUnit();611  ASSERT_NE(unit, nullptr);612  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();613  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);614  DWARFDIE cu_die(unit, cu_entry);615 616  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");617  auto &ast_ctx = *holder->GetAST();618  DWARFASTParserClangStub ast_parser(ast_ctx);619 620  llvm::SmallVector<lldb::TypeSP, 2> specializations;621  for (DWARFDIE die : cu_die.children()) {622    SymbolContext sc;623    bool new_type = false;624    auto type = ast_parser.ParseTypeFromDWARF(sc, die, &new_type);625    llvm::StringRef die_name = llvm::StringRef(die.GetName());626    if (die_name.starts_with("_Optional_payload")) {627      specializations.push_back(std::move(type));628    }629  }630 631  ASSERT_EQ(specializations.size(), 2U);632  ASSERT_NE(specializations[0], nullptr);633  ASSERT_EQ(specializations[1], nullptr);634}635 636TEST_F(DWARFASTParserClangTests, TestUniqueDWARFASTTypeMap_CppInsertMapFind) {637  // This tests the behaviour of UniqueDWARFASTTypeMap under638  // following scenario:639  // 1. DWARFASTParserClang parses a forward declaration and640  // inserts it into the UniqueDWARFASTTypeMap.641  // 2. We then MapDeclDIEToDefDIE which updates the map642  // entry with the line number/file information of the definition.643  // 3. Parse the definition DIE, which should return the previously644  // parsed type from the UniqueDWARFASTTypeMap.645 646  const char *yamldata = R"(647--- !ELF648FileHeader:649  Class:   ELFCLASS64650  Data:    ELFDATA2LSB651  Type:    ET_EXEC652  Machine: EM_AARCH64653DWARF:654  debug_str:655    - Foo656 657  debug_line:      658    - Version:         4659      MinInstLength:   1660      MaxOpsPerInst:   1661      DefaultIsStmt:   1662      LineBase:        0663      LineRange:       0664      Files:           665        - Name:            main.cpp666          DirIdx:          0667          ModTime:         0668          Length:          0669 670  debug_abbrev:671    - ID:              0672      Table:673        - Code:            0x01674          Tag:             DW_TAG_compile_unit675          Children:        DW_CHILDREN_yes676          Attributes:677            - Attribute:       DW_AT_language678              Form:            DW_FORM_data2679            - Attribute:       DW_AT_stmt_list680              Form:            DW_FORM_sec_offset681        - Code:            0x02682          Tag:             DW_TAG_structure_type683          Children:        DW_CHILDREN_no684          Attributes:685            - Attribute:       DW_AT_name686              Form:            DW_FORM_strp687            - Attribute:       DW_AT_declaration688              Form:            DW_FORM_flag_present689        - Code:            0x03690          Tag:             DW_TAG_structure_type691          Children:        DW_CHILDREN_no692          Attributes:693            - Attribute:       DW_AT_name694              Form:            DW_FORM_strp695            - Attribute:       DW_AT_decl_file696              Form:            DW_FORM_data1697            - Attribute:       DW_AT_decl_line698              Form:            DW_FORM_data1699 700  debug_info:701    - Version:         5702      UnitType:        DW_UT_compile703      AddrSize:        8704      Entries:705# 0x0c: DW_TAG_compile_unit706#         DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)707#         DW_AT_stmt_list [DW_FORM_sec_offset]708        - AbbrCode:        0x01709          Values:710            - Value:           0x04711            - Value:           0x0000000000000000712 713# 0x0d:   DW_TAG_structure_type714#           DW_AT_name [DW_FORM_strp]       (\"Foo\")715#           DW_AT_declaration [DW_FORM_flag_present] (true)716        - AbbrCode:        0x02717          Values:718            - Value:           0x00719 720# 0x0f:   DW_TAG_structure_type721#           DW_AT_name [DW_FORM_strp]       (\"Foo\")722#           DW_AT_decl_file [DW_FORM_data1] (main.cpp)723#           DW_AT_decl_line [DW_FORM_data1] (3)724        - AbbrCode:        0x03725          Values:726            - Value:           0x00727            - Value:           0x01728            - Value:           0x03729 730        - AbbrCode:        0x00 # end of child tags of 0x0c731...732)";733  YAMLModuleTester t(yamldata);734 735  DWARFUnit *unit = t.GetDwarfUnit();736  ASSERT_NE(unit, nullptr);737  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();738  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);739  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);740  DWARFDIE cu_die(unit, cu_entry);741 742  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");743  auto &ast_ctx = *holder->GetAST();744  DWARFASTParserClangStub ast_parser(ast_ctx);745 746  DWARFDIE decl_die;747  DWARFDIE def_die;748  for (auto const &die : cu_die.children()) {749    if (die.Tag() != DW_TAG_structure_type)750      continue;751 752    if (die.GetAttributeValueAsOptionalUnsigned(llvm::dwarf::DW_AT_declaration))753      decl_die = die;754    else755      def_die = die;756  }757 758  ASSERT_TRUE(decl_die.IsValid());759  ASSERT_TRUE(def_die.IsValid());760  ASSERT_NE(decl_die, def_die);761 762  ParsedDWARFTypeAttributes attrs(def_die);763  ASSERT_TRUE(attrs.decl.IsValid());764 765  SymbolContext sc;766  bool new_type = false;767  lldb::TypeSP type_sp = ast_parser.ParseTypeFromDWARF(sc, decl_die, &new_type);768  ASSERT_NE(type_sp, nullptr);769 770  ast_parser.MapDeclDIEToDefDIE(decl_die, def_die);771 772  lldb::TypeSP reparsed_type_sp =773      ast_parser.ParseTypeFromDWARF(sc, def_die, &new_type);774  ASSERT_NE(reparsed_type_sp, nullptr);775 776  ASSERT_EQ(type_sp, reparsed_type_sp);777}778 779TEST_F(DWARFASTParserClangTests, TestObjectPointer) {780  // This tests the behaviour of DWARFASTParserClang781  // for DW_TAG_subprogram definitions which have a DW_AT_object_pointer782  // *and* a DW_AT_specification that also has a DW_AT_object_pointer.783  // We don't want the declaration DW_AT_object_pointer to overwrite the784  // one from the more specific definition's.785 786  const char *yamldata = R"(787--- !ELF788FileHeader:789  Class:   ELFCLASS64790  Data:    ELFDATA2LSB791  Type:    ET_EXEC792  Machine: EM_AARCH64793DWARF:794  debug_str:795    - Context796    - func797    - this798  debug_abbrev:799    - ID:              0800      Table:801        - Code:            0x1802          Tag:             DW_TAG_compile_unit803          Children:        DW_CHILDREN_yes804          Attributes:805            - Attribute:       DW_AT_language806              Form:            DW_FORM_data2807        - Code:            0x2808          Tag:             DW_TAG_structure_type809          Children:        DW_CHILDREN_yes810          Attributes:811            - Attribute:       DW_AT_name812              Form:            DW_FORM_strp813        - Code:            0x3814          Tag:             DW_TAG_subprogram815          Children:        DW_CHILDREN_yes816          Attributes:817            - Attribute:       DW_AT_name818              Form:            DW_FORM_strp819            - Attribute:       DW_AT_declaration820              Form:            DW_FORM_flag_present821            - Attribute:       DW_AT_object_pointer822              Form:            DW_FORM_ref4823            - Attribute:       DW_AT_artificial824              Form:            DW_FORM_flag_present825            - Attribute:       DW_AT_external826              Form:            DW_FORM_flag_present827        - Code:            0x4828          Tag:             DW_TAG_formal_parameter829          Children:        DW_CHILDREN_no830          Attributes:831            - Attribute:       DW_AT_artificial832              Form:            DW_FORM_flag_present833        - Code:            0x5834          Tag:             DW_TAG_subprogram835          Children:        DW_CHILDREN_yes836          Attributes:837            - Attribute:       DW_AT_object_pointer838              Form:            DW_FORM_ref4839            - Attribute:       DW_AT_specification840              Form:            DW_FORM_ref4841        - Code:            0x6842          Tag:             DW_TAG_formal_parameter843          Children:        DW_CHILDREN_no844          Attributes:845            - Attribute:       DW_AT_name846              Form:            DW_FORM_strp847            - Attribute:       DW_AT_artificial848              Form:            DW_FORM_flag_present849  debug_info:850     - Version:         5851       UnitType:        DW_UT_compile852       AddrSize:        8853       Entries:854 855# DW_TAG_compile_unit856#   DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)857 858        - AbbrCode:        0x1859          Values:860            - Value:           0x04861 862#   DW_TAG_structure_type863#     DW_AT_name [DW_FORM_strp] ("Context")864 865        - AbbrCode:        0x2866          Values:867            - Value:           0x0868 869#     DW_TAG_subprogram870#       DW_AT_name [DW_FORM_strp] ("func")871#       DW_AT_object_pointer [DW_FORM_ref4]872        - AbbrCode:        0x3873          Values:874            - Value:           0x8875            - Value:           0x1876            - Value:           0x1d877            - Value:           0x1878            - Value:           0x1879 880#       DW_TAG_formal_parameter881#         DW_AT_artificial882        - AbbrCode:        0x4883          Values:884          - Value: 0x1885 886        - AbbrCode: 0x0887        - AbbrCode: 0x0888 889#     DW_TAG_subprogram890#       DW_AT_object_pointer [DW_FORM_ref4] ("this")891#       DW_AT_specification [DW_FORM_ref4] ("func")892        - AbbrCode:        0x5893          Values:894            - Value:           0x29895            - Value:           0x14896 897#       DW_TAG_formal_parameter898#         DW_AT_name [DW_FORM_strp] ("this")899#         DW_AT_artificial900        - AbbrCode:        0x6901          Values:902            - Value:           0xd903            - Value:           0x1904 905        - AbbrCode: 0x0906        - AbbrCode: 0x0907...908)";909  YAMLModuleTester t(yamldata);910 911  DWARFUnit *unit = t.GetDwarfUnit();912  ASSERT_NE(unit, nullptr);913  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();914  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);915  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);916  DWARFDIE cu_die(unit, cu_entry);917 918  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");919  auto &ast_ctx = *holder->GetAST();920  DWARFASTParserClangStub ast_parser(ast_ctx);921 922  auto context_die = cu_die.GetFirstChild();923  ASSERT_TRUE(context_die.IsValid());924  ASSERT_EQ(context_die.Tag(), DW_TAG_structure_type);925 926  {927    auto decl_die = context_die.GetFirstChild();928    ASSERT_TRUE(decl_die.IsValid());929    ASSERT_EQ(decl_die.Tag(), DW_TAG_subprogram);930    ASSERT_TRUE(decl_die.GetAttributeValueAsOptionalUnsigned(DW_AT_external));931 932    auto param_die = decl_die.GetFirstChild();933    ASSERT_TRUE(param_die.IsValid());934 935    EXPECT_EQ(param_die, ast_parser.GetObjectParameter(decl_die, context_die));936  }937 938  {939    auto subprogram_definition = context_die.GetSibling();940    ASSERT_TRUE(subprogram_definition.IsValid());941    ASSERT_EQ(subprogram_definition.Tag(), DW_TAG_subprogram);942    ASSERT_FALSE(subprogram_definition.GetAttributeValueAsOptionalUnsigned(943        DW_AT_external));944 945    auto param_die = subprogram_definition.GetFirstChild();946    ASSERT_TRUE(param_die.IsValid());947 948    EXPECT_EQ(param_die, ast_parser.GetObjectParameter(subprogram_definition,949                                                       context_die));950  }951}952 953TEST_F(DWARFASTParserClangTests,954       TestObjectPointer_NoSpecificationOnDefinition) {955  // This tests the behaviour of DWARFASTParserClang956  // for DW_TAG_subprogram definitions which have a DW_AT_object_pointer957  // but no DW_AT_specification that would link back to its declaration.958  // This is how Objective-C class method definitions are emitted.959 960  const char *yamldata = R"(961--- !ELF962FileHeader:963  Class:   ELFCLASS64964  Data:    ELFDATA2LSB965  Type:    ET_EXEC966  Machine: EM_AARCH64967DWARF:968  debug_str:969    - Context970    - func971    - this972  debug_abbrev:973    - ID:              0974      Table:975        - Code:            0x1976          Tag:             DW_TAG_compile_unit977          Children:        DW_CHILDREN_yes978          Attributes:979            - Attribute:       DW_AT_language980              Form:            DW_FORM_data2981        - Code:            0x2982          Tag:             DW_TAG_structure_type983          Children:        DW_CHILDREN_yes984          Attributes:985            - Attribute:       DW_AT_name986              Form:            DW_FORM_strp987        - Code:            0x3988          Tag:             DW_TAG_subprogram989          Children:        DW_CHILDREN_yes990          Attributes:991            - Attribute:       DW_AT_name992              Form:            DW_FORM_strp993            - Attribute:       DW_AT_declaration994              Form:            DW_FORM_flag_present995            - Attribute:       DW_AT_object_pointer996              Form:            DW_FORM_ref4997            - Attribute:       DW_AT_artificial998              Form:            DW_FORM_flag_present999            - Attribute:       DW_AT_external1000              Form:            DW_FORM_flag_present1001        - Code:            0x41002          Tag:             DW_TAG_formal_parameter1003          Children:        DW_CHILDREN_no1004          Attributes:1005            - Attribute:       DW_AT_artificial1006              Form:            DW_FORM_flag_present1007        - Code:            0x51008          Tag:             DW_TAG_subprogram1009          Children:        DW_CHILDREN_yes1010          Attributes:1011            - Attribute:       DW_AT_object_pointer1012              Form:            DW_FORM_ref41013        - Code:            0x61014          Tag:             DW_TAG_formal_parameter1015          Children:        DW_CHILDREN_no1016          Attributes:1017            - Attribute:       DW_AT_name1018              Form:            DW_FORM_strp1019            - Attribute:       DW_AT_artificial1020              Form:            DW_FORM_flag_present1021  debug_info:1022     - Version:         51023       UnitType:        DW_UT_compile1024       AddrSize:        81025       Entries:1026 1027# DW_TAG_compile_unit1028#   DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)1029 1030        - AbbrCode:        0x11031          Values:1032            - Value:           0x041033 1034#   DW_TAG_structure_type1035#     DW_AT_name [DW_FORM_strp] ("Context")1036 1037        - AbbrCode:        0x21038          Values:1039            - Value:           0x01040 1041#     DW_TAG_subprogram1042#       DW_AT_name [DW_FORM_strp] ("func")1043#       DW_AT_object_pointer [DW_FORM_ref4]1044        - AbbrCode:        0x31045          Values:1046            - Value:           0x81047            - Value:           0x11048            - Value:           0x1d1049            - Value:           0x11050            - Value:           0x11051 1052#       DW_TAG_formal_parameter1053#         DW_AT_artificial1054        - AbbrCode:        0x41055          Values:1056          - Value: 0x11057 1058        - AbbrCode: 0x01059        - AbbrCode: 0x01060 1061#     DW_TAG_subprogram1062#       DW_AT_object_pointer [DW_FORM_ref4] ("this")1063        - AbbrCode:        0x51064          Values:1065            - Value:           0x251066 1067#       DW_TAG_formal_parameter1068#         DW_AT_name [DW_FORM_strp] ("this")1069#         DW_AT_artificial1070        - AbbrCode:        0x61071          Values:1072            - Value:           0xd1073            - Value:           0x11074 1075        - AbbrCode: 0x01076        - AbbrCode: 0x01077...1078)";1079  YAMLModuleTester t(yamldata);1080 1081  DWARFUnit *unit = t.GetDwarfUnit();1082  ASSERT_NE(unit, nullptr);1083  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();1084  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);1085  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);1086  DWARFDIE cu_die(unit, cu_entry);1087 1088  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");1089  auto &ast_ctx = *holder->GetAST();1090  DWARFASTParserClangStub ast_parser(ast_ctx);1091 1092  auto context_die = cu_die.GetFirstChild();1093  ASSERT_TRUE(context_die.IsValid());1094  ASSERT_EQ(context_die.Tag(), DW_TAG_structure_type);1095 1096  auto subprogram_definition = context_die.GetSibling();1097  ASSERT_TRUE(subprogram_definition.IsValid());1098  ASSERT_EQ(subprogram_definition.Tag(), DW_TAG_subprogram);1099  ASSERT_FALSE(subprogram_definition.GetAttributeValueAsOptionalUnsigned(1100      DW_AT_external));1101  ASSERT_FALSE(1102      subprogram_definition.GetAttributeValueAsReferenceDIE(DW_AT_specification)1103          .IsValid());1104 1105  auto param_die = subprogram_definition.GetFirstChild();1106  ASSERT_TRUE(param_die.IsValid());1107  EXPECT_EQ(param_die,1108            ast_parser.GetObjectParameter(subprogram_definition, {}));1109}1110 1111TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) {1112  // Tests parsing of a C++ non-static member function with an explicit object1113  // parameter that isn't called "this" and is not a pointer (but a CV-qualified1114  // rvalue reference instead).1115 1116  const char *yamldata = R"(1117--- !ELF1118FileHeader:1119  Class:   ELFCLASS641120  Data:    ELFDATA2LSB1121  Type:    ET_EXEC1122  Machine: EM_AARCH641123DWARF:1124  debug_str:1125    - Context1126    - func1127    - mySelf1128  debug_abbrev:1129    - ID:              01130      Table:1131        - Code:            0x11132          Tag:             DW_TAG_compile_unit1133          Children:        DW_CHILDREN_yes1134          Attributes:1135            - Attribute:       DW_AT_language1136              Form:            DW_FORM_data21137        - Code:            0x21138          Tag:             DW_TAG_structure_type1139          Children:        DW_CHILDREN_yes1140          Attributes:1141            - Attribute:       DW_AT_name1142              Form:            DW_FORM_strp1143        - Code:            0x31144          Tag:             DW_TAG_subprogram1145          Children:        DW_CHILDREN_yes1146          Attributes:1147            - Attribute:       DW_AT_name1148              Form:            DW_FORM_strp1149            - Attribute:       DW_AT_declaration1150              Form:            DW_FORM_flag_present1151            - Attribute:       DW_AT_object_pointer1152              Form:            DW_FORM_ref41153            - Attribute:       DW_AT_external1154              Form:            DW_FORM_flag_present1155        - Code:            0x41156          Tag:             DW_TAG_formal_parameter1157          Children:        DW_CHILDREN_no1158          Attributes:1159            - Attribute:       DW_AT_name1160              Form:            DW_FORM_strp1161            - Attribute:       DW_AT_type1162              Form:            DW_FORM_ref41163        - Code:            0x51164          Tag:             DW_TAG_rvalue_reference_type1165          Children:        DW_CHILDREN_no1166          Attributes:1167            - Attribute:       DW_AT_type1168              Form:            DW_FORM_ref41169        - Code:            0x61170          Tag:             DW_TAG_const_type1171          Children:        DW_CHILDREN_no1172          Attributes:1173            - Attribute:       DW_AT_type1174              Form:            DW_FORM_ref41175        - Code:            0x71176          Tag:             DW_TAG_volatile_type1177          Children:        DW_CHILDREN_no1178          Attributes:1179            - Attribute:       DW_AT_type1180              Form:            DW_FORM_ref41181  debug_info:1182     - Version:         51183       UnitType:        DW_UT_compile1184       AddrSize:        81185       Entries:1186 1187# DW_TAG_compile_unit1188#   DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)1189 1190        - AbbrCode:        0x11191          Values:1192            - Value:           0x041193 1194#   DW_TAG_structure_type1195#     DW_AT_name [DW_FORM_strp] ("Context")1196 1197        - AbbrCode:        0x21198          Values:1199            - Value:           0x01200 1201#     DW_TAG_subprogram1202#       DW_AT_name [DW_FORM_strp] ("func")1203#       DW_AT_object_pointer [DW_FORM_ref4]1204        - AbbrCode:        0x31205          Values:1206            - Value:           0x81207            - Value:           0x11208            - Value:           0x1d1209            - Value:           0x11210 1211#       DW_TAG_formal_parameter1212#         DW_AT_name [DW_FORM_strp] ("mySelf")1213#         DW_AT_type [DW_FORM_ref4] (const volatile Context &&)1214        - AbbrCode:        0x41215          Values:1216            - Value: 0xd1217            - Value: 0x281218 1219        - AbbrCode: 0x01220        - AbbrCode: 0x01221 1222#   DW_TAG_rvalue_reference_type1223#     DW_AT_type [DW_FORM_ref4] ("const volatile Context")1224 1225        - AbbrCode:        0x51226          Values:1227            - Value:           0x2d1228 1229#   DW_TAG_const_type1230#     DW_AT_type [DW_FORM_ref4] ("volatile Context")1231 1232        - AbbrCode:        0x61233          Values:1234            - Value:           0x321235 1236#   DW_TAG_volatile_type1237#     DW_AT_type [DW_FORM_ref4] ("Context")1238 1239        - AbbrCode:        0x71240          Values:1241            - Value:           0xf1242 1243        - AbbrCode: 0x01244...1245)";1246  YAMLModuleTester t(yamldata);1247 1248  DWARFUnit *unit = t.GetDwarfUnit();1249  ASSERT_NE(unit, nullptr);1250  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();1251  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);1252  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);1253  DWARFDIE cu_die(unit, cu_entry);1254 1255  auto ts_or_err =1256      cu_die.GetDWARF()->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);1257  ASSERT_TRUE(static_cast<bool>(ts_or_err));1258  llvm::consumeError(ts_or_err.takeError());1259  auto *parser =1260      static_cast<DWARFASTParserClang *>((*ts_or_err)->GetDWARFParser());1261 1262  auto context_die = cu_die.GetFirstChild();1263  ASSERT_TRUE(context_die.IsValid());1264  ASSERT_EQ(context_die.Tag(), DW_TAG_structure_type);1265 1266  SymbolContext sc;1267  bool new_type;1268  auto context_type_sp = parser->ParseTypeFromDWARF(sc, context_die, &new_type);1269  ASSERT_NE(context_type_sp, nullptr);1270 1271  ASSERT_TRUE(1272      parser->CompleteTypeFromDWARF(context_die, context_type_sp.get(),1273                                    context_type_sp->GetForwardCompilerType()));1274 1275  auto *record_decl = llvm::dyn_cast_or_null<clang::CXXRecordDecl>(1276      ClangUtil::GetAsTagDecl(context_type_sp->GetForwardCompilerType()));1277  ASSERT_NE(record_decl, nullptr);1278 1279  auto method_it = record_decl->method_begin();1280  ASSERT_NE(method_it, record_decl->method_end());1281 1282  // Check that we didn't parse the function as static.1283  EXPECT_FALSE(method_it->isStatic());1284 1285  // Check that method qualifiers were correctly set.1286  EXPECT_EQ(method_it->getMethodQualifiers(),1287            clang::Qualifiers::fromCVRMask(clang::Qualifiers::Const |1288                                           clang::Qualifiers::Volatile));1289}1290 1291TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ParameterCreation) {1292  // Tests parsing of a C++ free function will create clang::ParmVarDecls with1293  // the correct clang::DeclContext.1294  //1295  // Also ensures we attach names to the ParmVarDecls (even when DWARF contains1296  // a mix of named/unnamed parameters).1297 1298  const char *yamldata = R"(1299--- !ELF1300FileHeader:1301  Class:   ELFCLASS641302  Data:    ELFDATA2LSB1303  Type:    ET_EXEC1304  Machine: EM_AARCH641305DWARF:1306  debug_str:1307    - func1308    - int1309    - short1310    - namedParam1311  debug_abbrev:1312    - ID:              01313      Table:1314        - Code:            0x11315          Tag:             DW_TAG_compile_unit1316          Children:        DW_CHILDREN_yes1317          Attributes:1318            - Attribute:       DW_AT_language1319              Form:            DW_FORM_data21320        - Code:            0x21321          Tag:             DW_TAG_structure_type1322          Children:        DW_CHILDREN_yes1323          Attributes:1324            - Attribute:       DW_AT_name1325              Form:            DW_FORM_strp1326        - Code:            0x31327          Tag:             DW_TAG_subprogram1328          Children:        DW_CHILDREN_yes1329          Attributes:1330            - Attribute:       DW_AT_name1331              Form:            DW_FORM_strp1332            - Attribute:       DW_AT_declaration1333              Form:            DW_FORM_flag_present1334            - Attribute:       DW_AT_external1335              Form:            DW_FORM_flag_present1336        - Code:            0x41337          Tag:             DW_TAG_formal_parameter1338          Children:        DW_CHILDREN_no1339          Attributes:1340            - Attribute:       DW_AT_type1341              Form:            DW_FORM_ref41342        - Code:            0x51343          Tag:             DW_TAG_formal_parameter1344          Children:        DW_CHILDREN_no1345          Attributes:1346            - Attribute:       DW_AT_type1347              Form:            DW_FORM_ref41348            - Attribute:       DW_AT_name1349              Form:            DW_FORM_strp1350        - Code:            0x61351          Tag:             DW_TAG_base_type1352          Children:        DW_CHILDREN_no1353          Attributes:1354            - Attribute:       DW_AT_name1355              Form:            DW_FORM_strp1356            - Attribute:       DW_AT_encoding1357              Form:            DW_FORM_data11358            - Attribute:       DW_AT_byte_size1359              Form:            DW_FORM_data11360  debug_info:1361     - Version:         51362       UnitType:        DW_UT_compile1363       AddrSize:        81364       Entries:1365 1366# DW_TAG_compile_unit1367#   DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)1368 1369        - AbbrCode:        0x11370          Values:1371            - Value:           0x041372 1373#     DW_TAG_subprogram1374#       DW_AT_name [DW_FORM_strp] ("func")1375        - AbbrCode:        0x31376          Values:1377            - Value:           0x01378            - Value:           0x11379            - Value:           0x11380 1381#       DW_TAG_formal_parameter1382#         DW_AT_type [DW_FORM_ref4] (int)1383        - AbbrCode:        0x41384          Values:1385            - Value: 0x231386 1387#       DW_TAG_formal_parameter1388#         DW_AT_type [DW_FORM_ref4] (short)1389#         DW_AT_name [DW_FORM_strp] ("namedParam")1390        - AbbrCode:        0x51391          Values:1392            - Value: 0x2a1393            - Value: 0xf1394 1395        - AbbrCode: 0x01396 1397#   DW_TAG_base_type1398#     DW_AT_name      [DW_FORM_strp] ("int")1399#     DW_AT_encoding  [DW_FORM_data1]1400#     DW_AT_byte_size [DW_FORM_data1]1401 1402        - AbbrCode:        0x61403          Values:1404            - Value:           0x00000000000000051405            - Value:           0x0000000000000005 # DW_ATE_signed1406            - Value:           0x00000000000000041407 1408#   DW_TAG_base_type1409#     DW_AT_name      [DW_FORM_strp] ("short")1410#     DW_AT_encoding  [DW_FORM_data1]1411#     DW_AT_byte_size [DW_FORM_data1]1412 1413        - AbbrCode:        0x61414          Values:1415            - Value:           0x00000000000000091416            - Value:           0x0000000000000005 # DW_ATE_signed1417            - Value:           0x00000000000000041418 1419        - AbbrCode: 0x01420...1421)";1422  YAMLModuleTester t(yamldata);1423 1424  DWARFUnit *unit = t.GetDwarfUnit();1425  ASSERT_NE(unit, nullptr);1426  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();1427  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);1428  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);1429  DWARFDIE cu_die(unit, cu_entry);1430 1431  auto ts_or_err =1432      cu_die.GetDWARF()->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);1433  ASSERT_TRUE(static_cast<bool>(ts_or_err));1434  llvm::consumeError(ts_or_err.takeError());1435 1436  auto *ts = static_cast<TypeSystemClang *>(ts_or_err->get());1437  auto *parser = static_cast<DWARFASTParserClang *>(ts->GetDWARFParser());1438 1439  auto subprogram = cu_die.GetFirstChild();1440  ASSERT_TRUE(subprogram.IsValid());1441  ASSERT_EQ(subprogram.Tag(), DW_TAG_subprogram);1442 1443  SymbolContext sc;1444  bool new_type;1445  auto type_sp = parser->ParseTypeFromDWARF(sc, subprogram, &new_type);1446  ASSERT_NE(type_sp, nullptr);1447 1448  auto result = ts->GetTranslationUnitDecl()->lookup(1449      clang_utils::getDeclarationName(*ts, "func"));1450  ASSERT_TRUE(result.isSingleResult());1451 1452  auto const *func = llvm::cast<clang::FunctionDecl>(result.front());1453 1454  EXPECT_EQ(func->getNumParams(), 2U);1455  EXPECT_EQ(func->getParamDecl(0)->getDeclContext(), func);1456  EXPECT_TRUE(func->getParamDecl(0)->getName().empty());1457  EXPECT_EQ(func->getParamDecl(1)->getDeclContext(), func);1458  EXPECT_EQ(func->getParamDecl(1)->getName(), "namedParam");1459}1460 1461TEST_F(DWARFASTParserClangTests, TestObjectPointer_IndexEncoding) {1462  // This tests the behaviour of DWARFASTParserClang1463  // for DW_TAG_subprogram definitions which have a DW_AT_object_pointer1464  // that encodes a constant index (instead of a DIE reference).1465 1466  const char *yamldata = R"(1467--- !ELF1468FileHeader:1469  Class:   ELFCLASS641470  Data:    ELFDATA2LSB1471  Type:    ET_EXEC1472  Machine: EM_AARCH641473DWARF:1474  debug_str:1475    - Context1476    - func1477    - this1478    - self1479    - arg1480  debug_abbrev:1481    - ID:              01482      Table:1483        - Code:            0x11484          Tag:             DW_TAG_compile_unit1485          Children:        DW_CHILDREN_yes1486          Attributes:1487            - Attribute:       DW_AT_language1488              Form:            DW_FORM_data21489        - Code:            0x21490          Tag:             DW_TAG_structure_type1491          Children:        DW_CHILDREN_yes1492          Attributes:1493            - Attribute:       DW_AT_name1494              Form:            DW_FORM_strp1495        - Code:            0x31496          Tag:             DW_TAG_subprogram1497          Children:        DW_CHILDREN_yes1498          Attributes:1499            - Attribute:       DW_AT_name1500              Form:            DW_FORM_strp1501            - Attribute:       DW_AT_declaration1502              Form:            DW_FORM_flag_present1503            - Attribute:       DW_AT_object_pointer1504              Form:            DW_FORM_implicit_const1505              Value:           11506            - Attribute:       DW_AT_external1507              Form:            DW_FORM_flag_present1508        - Code:            0x41509          Tag:             DW_TAG_subprogram1510          Children:        DW_CHILDREN_yes1511          Attributes:1512            - Attribute:       DW_AT_name1513              Form:            DW_FORM_strp1514            - Attribute:       DW_AT_declaration1515              Form:            DW_FORM_flag_present1516            - Attribute:       DW_AT_object_pointer1517              Form:            DW_FORM_implicit_const1518              Value:           01519            - Attribute:       DW_AT_external1520              Form:            DW_FORM_flag_present1521 1522        - Code:            0x51523          Tag:             DW_TAG_formal_parameter1524          Children:        DW_CHILDREN_no1525          Attributes:1526            - Attribute:       DW_AT_name1527              Form:            DW_FORM_strp1528 1529        - Code:            0x61530          Tag:             DW_TAG_formal_parameter1531          Children:        DW_CHILDREN_no1532          Attributes:1533            - Attribute:       DW_AT_name1534              Form:            DW_FORM_strp1535            - Attribute:       DW_AT_artificial1536              Form:            DW_FORM_flag_present1537 1538  debug_info:1539     - Version:  51540       UnitType: DW_UT_compile1541       AddrSize: 81542       Entries:1543 1544# DW_TAG_compile_unit1545#   DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)1546 1547        - AbbrCode: 0x11548          Values:1549            - Value: 0x041550 1551#   DW_TAG_structure_type1552#     DW_AT_name [DW_FORM_strp] ("Context")1553 1554        - AbbrCode: 0x21555          Values:1556            - Value: 0x01557 1558#     DW_TAG_subprogram1559#       DW_AT_name [DW_FORM_strp] ("func")1560#       DW_AT_object_pointer [DW_FORM_implicit_const] (1)1561        - AbbrCode: 0x31562          Values:1563            - Value: 0x81564            - Value: 0x11565            - Value: 0x11566            - Value: 0x11567 1568#       DW_TAG_formal_parameter1569#         DW_AT_name [DW_FORM_strp] ("arg")1570        - AbbrCode: 0x51571          Values:1572          - Value: 0x171573 1574#       DW_TAG_formal_parameter1575#         DW_AT_name [DW_FORM_strp] ("self")1576#         DW_AT_artificial1577        - AbbrCode: 0x61578          Values:1579          - Value: 0x121580          - Value: 0x11581 1582        - AbbrCode: 0x01583 1584#     DW_TAG_subprogram1585#       DW_AT_object_pointer [DW_FORM_implicit_const] (0)1586#       DW_AT_name [DW_FORM_strp] ("func")1587        - AbbrCode:        0x41588          Values:1589            - Value: 0x81590            - Value: 0x11591            - Value: 0x11592            - Value: 0x11593 1594#       DW_TAG_formal_parameter1595#         DW_AT_name [DW_FORM_strp] ("this")1596#         DW_AT_artificial1597        - AbbrCode:        0x61598          Values:1599            - Value:           0xd1600            - Value:           0x11601 1602#       DW_TAG_formal_parameter1603#         DW_AT_name [DW_FORM_strp] ("arg")1604        - AbbrCode: 0x51605          Values:1606          - Value: 0x171607 1608        - AbbrCode: 0x01609        - AbbrCode: 0x01610...1611)";1612 1613  YAMLModuleTester t(yamldata);1614 1615  DWARFUnit *unit = t.GetDwarfUnit();1616  ASSERT_NE(unit, nullptr);1617  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();1618  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);1619  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);1620  DWARFDIE cu_die(unit, cu_entry);1621 1622  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");1623  auto &ast_ctx = *holder->GetAST();1624  DWARFASTParserClangStub ast_parser(ast_ctx);1625 1626  auto context_die = cu_die.GetFirstChild();1627  ASSERT_TRUE(context_die.IsValid());1628  ASSERT_EQ(context_die.Tag(), DW_TAG_structure_type);1629 1630  auto sub1 = context_die.GetFirstChild();1631  ASSERT_TRUE(sub1.IsValid());1632  ASSERT_EQ(sub1.Tag(), DW_TAG_subprogram);1633 1634  auto sub2 = sub1.GetSibling();1635  ASSERT_TRUE(sub2.IsValid());1636  ASSERT_EQ(sub2.Tag(), DW_TAG_subprogram);1637 1638  // Object parameter is at constant index 11639  {1640    auto param_die = sub1.GetFirstChild().GetSibling();1641    ASSERT_TRUE(param_die.IsValid());1642 1643    EXPECT_EQ(param_die, ast_parser.GetObjectParameter(sub1, context_die));1644  }1645 1646  // Object parameter is at constant index 01647  {1648    auto param_die = sub2.GetFirstChild();1649    ASSERT_TRUE(param_die.IsValid());1650 1651    EXPECT_EQ(param_die, ast_parser.GetObjectParameter(sub2, context_die));1652  }1653}1654 1655TEST_F(DWARFASTParserClangTests, TestTypeBitSize) {1656  // Tests that we correctly parse DW_AT_bit_size of a DW_AT_base_type.1657 1658  const char *yamldata = R"(1659--- !ELF1660FileHeader:1661  Class:   ELFCLASS641662  Data:    ELFDATA2LSB1663  Type:    ET_EXEC1664  Machine: EM_AARCH641665DWARF:1666  debug_str:1667    - _BitInt(2)1668  debug_abbrev:1669    - ID:              01670      Table:1671        - Code:            0x11672          Tag:             DW_TAG_compile_unit1673          Children:        DW_CHILDREN_yes1674          Attributes:1675            - Attribute:       DW_AT_language1676              Form:            DW_FORM_data21677        - Code:            0x21678          Tag:             DW_TAG_base_type1679          Children:        DW_CHILDREN_no1680          Attributes:1681            - Attribute: DW_AT_name1682              Form:      DW_FORM_strp1683            - Attribute: DW_AT_encoding1684              Form:      DW_FORM_data11685            - Attribute: DW_AT_byte_size1686              Form:      DW_FORM_data11687            - Attribute: DW_AT_bit_size1688              Form:      DW_FORM_data11689 1690  debug_info:1691     - Version:  51692       UnitType: DW_UT_compile1693       AddrSize: 81694       Entries:1695 1696# DW_TAG_compile_unit1697#   DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)1698 1699        - AbbrCode: 0x11700          Values:1701            - Value: 0x041702 1703#   DW_TAG_base_type1704#     DW_AT_name [DW_FORM_strp] ('_BitInt(2)')1705 1706        - AbbrCode: 0x21707          Values:1708            - Value: 0x01709            - Value: 0x051710            - Value: 0x011711            - Value: 0x021712...1713)";1714 1715  YAMLModuleTester t(yamldata);1716 1717  DWARFUnit *unit = t.GetDwarfUnit();1718  ASSERT_NE(unit, nullptr);1719  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();1720  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);1721  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);1722  DWARFDIE cu_die(unit, cu_entry);1723 1724  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");1725  auto &ast_ctx = *holder->GetAST();1726  DWARFASTParserClangStub ast_parser(ast_ctx);1727 1728  auto type_die = cu_die.GetFirstChild();1729  ASSERT_TRUE(type_die.IsValid());1730  ASSERT_EQ(type_die.Tag(), DW_TAG_base_type);1731 1732  ParsedDWARFTypeAttributes attrs(type_die);1733  EXPECT_EQ(attrs.byte_size.value_or(0), 1U);1734  EXPECT_EQ(attrs.data_bit_size.value_or(0), 2U);1735 1736  SymbolContext sc;1737  auto type_sp =1738      ast_parser.ParseTypeFromDWARF(sc, type_die, /*type_is_new_ptr=*/nullptr);1739  ASSERT_NE(type_sp, nullptr);1740 1741  EXPECT_EQ(llvm::expectedToOptional(type_sp->GetByteSize(nullptr)).value_or(0),1742            1U);1743}1744 1745TEST_F(DWARFASTParserClangTests, TestBitIntParsing) {1746  // Tests that we correctly parse the DW_AT_base_type for a _BitInt.1747  // Older versions of Clang only emit the `_BitInt` string into the1748  // DW_AT_name (not including the bitsize). Make sure we understand1749  // those too.1750 1751  const char *yamldata = R"(1752--- !ELF1753FileHeader:1754  Class:   ELFCLASS641755  Data:    ELFDATA2LSB1756  Type:    ET_EXEC1757  Machine: EM_AARCH641758DWARF:1759  debug_str:1760    - _BitInt(2)1761    - _BitInt1762    - unsigned _BitInt(2)1763    - unsigned _BitInt1764  debug_abbrev:1765    - ID:              01766      Table:1767        - Code:            0x11768          Tag:             DW_TAG_compile_unit1769          Children:        DW_CHILDREN_yes1770          Attributes:1771            - Attribute:       DW_AT_language1772              Form:            DW_FORM_data21773        - Code:            0x21774          Tag:             DW_TAG_base_type1775          Children:        DW_CHILDREN_no1776          Attributes:1777            - Attribute: DW_AT_name1778              Form:      DW_FORM_strp1779            - Attribute: DW_AT_encoding1780              Form:      DW_FORM_data11781            - Attribute: DW_AT_byte_size1782              Form:      DW_FORM_data11783            - Attribute: DW_AT_bit_size1784              Form:      DW_FORM_data11785        - Code:            0x31786          Tag:             DW_TAG_base_type1787          Children:        DW_CHILDREN_no1788          Attributes:1789            - Attribute: DW_AT_name1790              Form:      DW_FORM_strp1791            - Attribute: DW_AT_encoding1792              Form:      DW_FORM_data11793            - Attribute: DW_AT_byte_size1794              Form:      DW_FORM_data11795 1796  debug_info:1797     - Version:  51798       UnitType: DW_UT_compile1799       AddrSize: 81800       Entries:1801 1802# DW_TAG_compile_unit1803#   DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)1804 1805        - AbbrCode: 0x11806          Values:1807            - Value: 0x041808 1809#   DW_TAG_base_type1810#     DW_AT_name [DW_FORM_strp] ('_BitInt(2)')1811 1812        - AbbrCode: 0x21813          Values:1814            - Value: 0x01815            - Value: 0x051816            - Value: 0x011817            - Value: 0x021818 1819#   DW_TAG_base_type1820#     DW_AT_name [DW_FORM_strp] ('_BitInt')1821 1822        - AbbrCode: 0x21823          Values:1824            - Value: 0x0b1825            - Value: 0x051826            - Value: 0x081827            - Value: 0x341828 1829#   DW_TAG_base_type1830#     DW_AT_name [DW_FORM_strp] ('unsigned _BitInt(2)')1831 1832        - AbbrCode: 0x21833          Values:1834            - Value: 0x131835            - Value: 0x071836            - Value: 0x011837            - Value: 0x021838 1839#   DW_TAG_base_type1840#     DW_AT_name [DW_FORM_strp] ('unsigned _BitInt')1841 1842        - AbbrCode: 0x21843          Values:1844            - Value: 0x271845            - Value: 0x071846            - Value: 0x081847            - Value: 0x341848 1849#   DW_TAG_base_type1850#     DW_AT_name [DW_FORM_strp] ('_BitInt')1851 1852        - AbbrCode: 0x31853          Values:1854            - Value: 0x0b1855            - Value: 0x051856            - Value: 0x081857...1858 1859)";1860 1861  YAMLModuleTester t(yamldata);1862 1863  DWARFUnit *unit = t.GetDwarfUnit();1864  ASSERT_NE(unit, nullptr);1865  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();1866  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);1867  ASSERT_EQ(unit->GetDWARFLanguageType(), DW_LANG_C_plus_plus);1868  DWARFDIE cu_die(unit, cu_entry);1869 1870  auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast");1871  auto &ast_ctx = *holder->GetAST();1872  DWARFASTParserClangStub ast_parser(ast_ctx);1873 1874  auto type_die = cu_die.GetFirstChild();1875  ASSERT_TRUE(type_die.IsValid());1876 1877  {1878    SymbolContext sc;1879    auto type_sp = ast_parser.ParseTypeFromDWARF(sc, type_die,1880                                                 /*type_is_new_ptr=*/nullptr);1881    ASSERT_NE(type_sp, nullptr);1882 1883    EXPECT_EQ(1884        llvm::expectedToOptional(type_sp->GetByteSize(nullptr)).value_or(0),1885        1U);1886    EXPECT_EQ(type_sp->GetEncoding(), lldb::eEncodingSint);1887    EXPECT_EQ(type_sp->GetName(), "_BitInt(2)");1888    EXPECT_EQ(type_sp->GetForwardCompilerType().GetTypeName(), "_BitInt(2)");1889  }1890 1891  {1892    type_die = type_die.GetSibling();1893    SymbolContext sc;1894    auto type_sp = ast_parser.ParseTypeFromDWARF(sc, type_die,1895                                                 /*type_is_new_ptr=*/nullptr);1896    ASSERT_NE(type_sp, nullptr);1897 1898    EXPECT_EQ(1899        llvm::expectedToOptional(type_sp->GetByteSize(nullptr)).value_or(0),1900        8U);1901    EXPECT_EQ(type_sp->GetEncoding(), lldb::eEncodingSint);1902    EXPECT_EQ(type_sp->GetName(), "_BitInt");1903    EXPECT_EQ(type_sp->GetForwardCompilerType().GetTypeName(), "_BitInt(52)");1904  }1905 1906  {1907    type_die = type_die.GetSibling();1908    SymbolContext sc;1909    auto type_sp = ast_parser.ParseTypeFromDWARF(sc, type_die,1910                                                 /*type_is_new_ptr=*/nullptr);1911    ASSERT_NE(type_sp, nullptr);1912 1913    EXPECT_EQ(1914        llvm::expectedToOptional(type_sp->GetByteSize(nullptr)).value_or(0),1915        1U);1916    EXPECT_EQ(type_sp->GetEncoding(), lldb::eEncodingUint);1917    EXPECT_EQ(type_sp->GetName(), "unsigned _BitInt(2)");1918    EXPECT_EQ(type_sp->GetForwardCompilerType().GetTypeName(),1919              "unsigned _BitInt(2)");1920  }1921 1922  {1923    type_die = type_die.GetSibling();1924    SymbolContext sc;1925    auto type_sp = ast_parser.ParseTypeFromDWARF(sc, type_die,1926                                                 /*type_is_new_ptr=*/nullptr);1927    ASSERT_NE(type_sp, nullptr);1928 1929    EXPECT_EQ(1930        llvm::expectedToOptional(type_sp->GetByteSize(nullptr)).value_or(0),1931        8U);1932    EXPECT_EQ(type_sp->GetEncoding(), lldb::eEncodingUint);1933    EXPECT_EQ(type_sp->GetName(), "unsigned _BitInt");1934    EXPECT_EQ(type_sp->GetForwardCompilerType().GetTypeName(),1935              "unsigned _BitInt(52)");1936  }1937 1938  {1939    type_die = type_die.GetSibling();1940    SymbolContext sc;1941    auto type_sp = ast_parser.ParseTypeFromDWARF(sc, type_die,1942                                                 /*type_is_new_ptr=*/nullptr);1943    ASSERT_NE(type_sp, nullptr);1944 1945    EXPECT_EQ(1946        llvm::expectedToOptional(type_sp->GetByteSize(nullptr)).value_or(0),1947        8U);1948    EXPECT_EQ(type_sp->GetEncoding(), lldb::eEncodingSint);1949    EXPECT_EQ(type_sp->GetName(), "_BitInt");1950 1951    // Older versions of Clang didn't emit a DW_AT_bit_size for _BitInt. In1952    // those cases we would format the CompilerType name using the byte-size.1953    EXPECT_EQ(type_sp->GetForwardCompilerType().GetTypeName(), "_BitInt(64)");1954  }1955}1956