Skip to content

Commit a58f88f

Browse files
committed
Hoist SwiftASTContext::IsScalarType into TypeSystemSwift (NFC)
and add a unit test for it.
1 parent 215c9c1 commit a58f88f

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,13 +5195,6 @@ bool SwiftASTContext::IsPossibleDynamicType(opaque_compiler_type_t type,
51955195
return false;
51965196
}
51975197

5198-
bool SwiftASTContext::IsScalarType(opaque_compiler_type_t type) {
5199-
if (!type)
5200-
return false;
5201-
5202-
return (GetTypeInfo(type, nullptr) & eTypeIsScalar) != 0;
5203-
}
5204-
52055198
bool SwiftASTContext::IsTypedefType(opaque_compiler_type_t type) {
52065199
if (!type)
52075200
return false;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,6 @@ class SwiftASTContext : public TypeSystemSwift {
473473
bool IsPointerType(lldb::opaque_compiler_type_t type,
474474
CompilerType *pointee_type) override;
475475

476-
bool IsScalarType(lldb::opaque_compiler_type_t type) override;
477-
478476
bool IsVoidType(lldb::opaque_compiler_type_t type) override;
479477

480478
static bool IsGenericType(const CompilerType &compiler_type);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ bool TypeSystemSwift::IsIntegerType(opaque_compiler_type_t type,
3131
bool &is_signed) {
3232
return (GetTypeInfo(type, nullptr) & eTypeIsInteger);
3333
}
34+
35+
bool TypeSystemSwift::IsScalarType(opaque_compiler_type_t type) {
36+
if (!type)
37+
return false;
38+
39+
return (GetTypeInfo(type, nullptr) & eTypeIsScalar) != 0;
40+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class TypeSystemSwift : public TypeSystem {
136136
bool &is_complex) override;
137137
bool IsIntegerType(lldb::opaque_compiler_type_t type,
138138
bool &is_signed) override;
139+
bool IsScalarType(lldb::opaque_compiler_type_t type) override;
139140
bool IsCStringType(lldb::opaque_compiler_type_t type,
140141
uint32_t &length) override {
141142
return false;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,6 @@ bool TypeSystemSwiftTypeRef::IsPointerType(opaque_compiler_type_t type,
13671367
VALIDATE_AND_RETURN(impl, IsPointerType, type,
13681368
(ReconstructType(type), pointee_type));
13691369
}
1370-
bool TypeSystemSwiftTypeRef::IsScalarType(opaque_compiler_type_t type) {
1371-
return m_swift_ast_context->IsScalarType(ReconstructType(type));
1372-
}
13731370
bool TypeSystemSwiftTypeRef::IsVoidType(opaque_compiler_type_t type) {
13741371
auto impl = [&]() {
13751372
using namespace swift::Demangle;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
100100
bool check_cplusplus, bool check_objc) override;
101101
bool IsPointerType(lldb::opaque_compiler_type_t type,
102102
CompilerType *pointee_type) override;
103-
bool IsScalarType(lldb::opaque_compiler_type_t type) override;
104103
bool IsVoidType(lldb::opaque_compiler_type_t type) override;
105104
// Type Completion
106105
bool GetCompleteType(lldb::opaque_compiler_type_t type) override;

lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Aggregate) {
264264
NodePointer n = b.GlobalType(b.Node(Node::Kind::Tuple));
265265
CompilerType tuple = GetCompilerType(b.Mangle(n));
266266
ASSERT_TRUE(tuple.IsAggregateType());
267+
ASSERT_FALSE(tuple.IsScalarType());
267268
// Yes, Int is a struct.
268269
NodePointer int_node = b.GlobalTypeMangling(b.IntType());
269270
CompilerType int_type = GetCompilerType(b.Mangle(int_node));
@@ -289,7 +290,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Defined) {
289290
}
290291
}
291292

292-
TEST_F(TestTypeSystemSwiftTypeRef, IntFloat) {
293+
TEST_F(TestTypeSystemSwiftTypeRef, Scalar) {
293294
using namespace swift::Demangle;
294295
Demangler dem;
295296
NodeBuilder b(dem);
@@ -303,6 +304,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, IntFloat) {
303304
ASSERT_EQ(is_complex, false);
304305
bool is_signed = true;
305306
ASSERT_TRUE(int_type.IsIntegerType(is_signed));
307+
ASSERT_TRUE(int_type.IsScalarType());
306308
}
307309
{
308310
NodePointer float_node = b.GlobalTypeMangling(b.FloatType());
@@ -314,5 +316,6 @@ TEST_F(TestTypeSystemSwiftTypeRef, IntFloat) {
314316
ASSERT_EQ(is_complex, false);
315317
bool is_signed = true;
316318
ASSERT_FALSE(float_type.IsIntegerType(is_signed));
319+
ASSERT_TRUE(float_type.IsScalarType());
317320
}
318321
}

0 commit comments

Comments
 (0)