Skip to content

Commit 24c8c66

Browse files
committed
Hoist SwiftASTContext::IsIntegerType into TypeSystemSwift (NFC)
and add a unit test for it. (cherry picked from commit 215c9c1)
1 parent 149dcc7 commit 24c8c66

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5061,11 +5061,6 @@ bool SwiftASTContext::IsFunctionPointerType(opaque_compiler_type_t type) {
50615061
return IsFunctionType(type, nullptr); // FIXME: think about this
50625062
}
50635063

5064-
bool SwiftASTContext::IsIntegerType(opaque_compiler_type_t type,
5065-
bool &is_signed) {
5066-
return (GetTypeInfo(type, nullptr) & eTypeIsInteger);
5067-
}
5068-
50695064
bool SwiftASTContext::IsPointerType(opaque_compiler_type_t type,
50705065
CompilerType *pointee_type) {
50715066
VALID_OR_RETURN(false);

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,6 @@ class SwiftASTContext : public TypeSystemSwift {
460460

461461
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
462462

463-
bool IsIntegerType(lldb::opaque_compiler_type_t type,
464-
bool &is_signed) override;
465-
466463
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
467464
CompilerType *target_type, // Can pass NULL
468465
bool check_cplusplus, bool check_objc) override;

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,8 @@ bool TypeSystemSwift::IsFloatingPointType(opaque_compiler_type_t type,
7676
}
7777
return false;
7878
}
79+
80+
bool TypeSystemSwift::IsIntegerType(opaque_compiler_type_t type,
81+
bool &is_signed) {
82+
return (GetTypeInfo(type, nullptr) & eTypeIsInteger);
83+
}

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class TypeSystemSwift : public TypeSystem {
143143
bool IsConst(lldb::opaque_compiler_type_t type) override { return false; }
144144
bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
145145
bool &is_complex) override;
146+
bool IsIntegerType(lldb::opaque_compiler_type_t type,
147+
bool &is_signed) override;
146148
bool IsCStringType(lldb::opaque_compiler_type_t type,
147149
uint32_t &length) override {
148150
return false;

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,10 +1341,6 @@ bool TypeSystemSwiftTypeRef::IsFunctionPointerType(
13411341
VALIDATE_AND_RETURN(impl, IsFunctionPointerType, type,
13421342
(ReconstructType(type)));
13431343
}
1344-
bool TypeSystemSwiftTypeRef::IsIntegerType(opaque_compiler_type_t type,
1345-
bool &is_signed) {
1346-
return m_swift_ast_context->IsIntegerType(ReconstructType(type), is_signed);
1347-
}
13481344
bool TypeSystemSwiftTypeRef::IsPossibleDynamicType(opaque_compiler_type_t type,
13491345
CompilerType *target_type,
13501346
bool check_cplusplus,

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
9595
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
9696
const size_t index) override;
9797
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
98-
bool IsIntegerType(lldb::opaque_compiler_type_t type,
99-
bool &is_signed) override;
10098
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
10199
CompilerType *target_type, // Can pass NULL
102100
bool check_cplusplus, bool check_objc) override;

lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Defined) {
289289
}
290290
}
291291

292-
TEST_F(TestTypeSystemSwiftTypeRef, Float) {
292+
TEST_F(TestTypeSystemSwiftTypeRef, IntFloat) {
293293
using namespace swift::Demangle;
294294
Demangler dem;
295295
NodeBuilder b(dem);
@@ -301,6 +301,8 @@ TEST_F(TestTypeSystemSwiftTypeRef, Float) {
301301
ASSERT_FALSE(int_type.IsFloatingPointType(count, is_complex));
302302
ASSERT_EQ(count, 0);
303303
ASSERT_EQ(is_complex, false);
304+
bool is_signed = true;
305+
ASSERT_TRUE(int_type.IsIntegerType(is_signed));
304306
}
305307
{
306308
NodePointer float_node = b.GlobalTypeMangling(b.FloatType());
@@ -310,5 +312,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Float) {
310312
ASSERT_TRUE(float_type.IsFloatingPointType(count, is_complex));
311313
ASSERT_EQ(count, 1);
312314
ASSERT_EQ(is_complex, false);
315+
bool is_signed = true;
316+
ASSERT_FALSE(float_type.IsIntegerType(is_signed));
313317
}
314318
}

0 commit comments

Comments
 (0)