1 //===-- XcodeSDKModuleTests.cpp -------------------------------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
10 #include "Plugins/SymbolFile/DWARF/DWARFCompileUnit.h"
11 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
12 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
13 #include "TestingSupport/Symbol/YAMLModuleTester.h"
14 #include "lldb/Core/PluginManager.h"
15 #include "gmock/gmock.h"
16 #include "gtest/gtest.h"
19 using namespace lldb_private
;
23 class XcodeSDKModuleTests
: public testing::Test
{
24 SubsystemRAII
<HostInfoBase
, PlatformMacOSX
> subsystems
;
29 TEST_F(XcodeSDKModuleTests
, TestModuleGetXcodeSDK
) {
30 const char *yamldata
= R
"(
43 Tag: DW_TAG_compile_unit
44 Children: DW_CHILDREN_no
46 - Attribute: DW_AT_language
48 - Attribute: DW_AT_APPLE_sdk
54 - AbbrCode: 0x00000001
56 - Value: 0x000000000000000C
57 - Value: 0x0000000000000000
58 - AbbrCode: 0x00000000
62 YAMLModuleTester
t(yamldata
);
63 DWARFUnit
*dwarf_unit
= t
.GetDwarfUnit();
64 auto *dwarf_cu
= llvm::cast
<DWARFCompileUnit
>(dwarf_unit
);
65 ASSERT_TRUE(static_cast<bool>(dwarf_cu
));
66 SymbolFileDWARF
&sym_file
= dwarf_cu
->GetSymbolFileDWARF();
67 CompUnitSP comp_unit
= sym_file
.GetCompileUnitAtIndex(0);
68 ASSERT_TRUE(static_cast<bool>(comp_unit
.get()));
69 ModuleSP module
= t
.GetModule();
70 ASSERT_EQ(module
->GetSourceMappingList().GetSize(), 0u);
71 XcodeSDK sdk
= sym_file
.ParseXcodeSDK(*comp_unit
);
72 ASSERT_EQ(sdk
.GetType(), XcodeSDK::Type::MacOSX
);
73 ASSERT_EQ(module
->GetSourceMappingList().GetSize(), 1u);