Skip to content
Merged
12 changes: 12 additions & 0 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,20 @@ lldb::BasicType TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
{"unsigned long long int", eBasicTypeUnsignedLongLong},

// "int128"
//
// The following two lines are here only
// for the sake of backward-compatibility.
// Neither "__int128_t", nor "__uint128_t" are basic-types.
// They are typedefs.
{"__int128_t", eBasicTypeInt128},
{"__uint128_t", eBasicTypeUnsignedInt128},
// In order to be consistent with:
// - gcc's C programming language extension related to 128-bit integers
// https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html
// - the "BuiltinType::getName" method in LLVM
// the following two lines must be present:
{"__int128", eBasicTypeInt128},
{"unsigned __int128", eBasicTypeUnsignedInt128},

// "bool"
{"bool", eBasicTypeBool},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ def test(self):
self.assertEqual(b.GetType().GetBasicType(), int_basic_type)
self.assertEqual(c.GetType().GetBasicType(), int_basic_type)
self.assertEqual(d.GetType().GetBasicType(), int_basic_type)

# Check the size of the chosen basic types.
self.assertEqual(self.target().FindFirstType("__int128").size, 16)
self.assertEqual(self.target().FindFirstType("unsigned __int128").size, 16)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add the same assertions for __uint128_t and __int128_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a commit that adds this kind of changes as well.


# Check the size of the chosen aliases of basic types.
self.assertEqual(self.target().FindFirstType("__int128_t").size, 16)
self.assertEqual(self.target().FindFirstType("__uint128_t").size, 16)
3 changes: 3 additions & 0 deletions lldb/unittests/Symbol/TestTypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ TEST_F(TestTypeSystemClang, TestGetBasicTypeFromName) {
EXPECT_EQ(GetBasicQualType(eBasicTypeInt128), GetBasicQualType("__int128_t"));
EXPECT_EQ(GetBasicQualType(eBasicTypeUnsignedInt128),
GetBasicQualType("__uint128_t"));
EXPECT_EQ(GetBasicQualType(eBasicTypeInt128), GetBasicQualType("__int128"));
EXPECT_EQ(GetBasicQualType(eBasicTypeUnsignedInt128),
GetBasicQualType("unsigned __int128"));
EXPECT_EQ(GetBasicQualType(eBasicTypeVoid), GetBasicQualType("void"));
EXPECT_EQ(GetBasicQualType(eBasicTypeBool), GetBasicQualType("bool"));
EXPECT_EQ(GetBasicQualType(eBasicTypeFloat), GetBasicQualType("float"));
Expand Down
Loading