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 @@ -5,11 +5,14 @@


class TestCase(TestBase):
def test(self):
"""Test that SBType.GetBasicType unwraps typedefs."""
def setUp(self):
Copy link
Member

Choose a reason for hiding this comment

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

Final nit: can we revert the changes of adding a setUp method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing this out. I've missed that. I've pushed a commit that inlines setUp (back) to the test method.

TestBase.setUp(self)
self.build()
lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))

def testTypedefUnwrapping(self):
"""Test that SBType.GetBasicType unwraps typedefs."""

a = self.frame().FindVariable("a")
self.assertTrue(a)

Expand All @@ -28,3 +31,8 @@ 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)

def testBasicTypeSize(self):
Copy link
Member

Choose a reason for hiding this comment

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

No need to make this a separate test case. Just fold it into the existing case.

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 joins those two tests back into a single test.

"""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.

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