Skip to content

Commit cd41445

Browse files
Merge pull request #1488 from adrian-prantl/should-treat-scalar-next
Hoist SwiftASTContext::IsScalarType into TypeSystemSwift (NFC)
2 parents 134081e + 5464c0b commit cd41445

File tree

7 files changed

+35
-16
lines changed

7 files changed

+35
-16
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5077,12 +5077,6 @@ bool SwiftASTContext::IsPointerOrReferenceType(opaque_compiler_type_t type,
50775077
IsReferenceType(type, pointee_type, nullptr);
50785078
}
50795079

5080-
bool SwiftASTContext::ShouldTreatScalarValueAsAddress(
5081-
opaque_compiler_type_t type) {
5082-
return Flags(GetTypeInfo(type, nullptr))
5083-
.AnySet(eTypeInstanceIsPointer | eTypeIsReference);
5084-
}
5085-
50865080
bool SwiftASTContext::IsReferenceType(opaque_compiler_type_t type,
50875081
CompilerType *pointee_type,
50885082
bool *is_rvalue) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,6 @@ class SwiftASTContext : public TypeSystemSwift {
720720
bool IsReferenceType(lldb::opaque_compiler_type_t type,
721721
CompilerType *pointee_type, bool *is_rvalue) override;
722722

723-
bool
724-
ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) override;
725-
726723
uint32_t GetNumPointeeChildren(lldb::opaque_compiler_type_t type);
727724

728725
bool IsImportedType(lldb::opaque_compiler_type_t type,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,9 @@ bool TypeSystemSwift::IsScalarType(opaque_compiler_type_t type) {
8888

8989
return (GetTypeInfo(type, nullptr) & eTypeIsScalar) != 0;
9090
}
91+
92+
bool TypeSystemSwift::ShouldTreatScalarValueAsAddress(
93+
opaque_compiler_type_t type) {
94+
return Flags(GetTypeInfo(type, nullptr))
95+
.AnySet(eTypeInstanceIsPointer | eTypeIsReference);
96+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ class TypeSystemSwift : public TypeSystem {
202202
size_t idx, uint32_t *bit_offset_ptr) override {
203203
return {};
204204
}
205+
bool
206+
ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) override;
205207
/// \}
206208
protected:
207209
/// Used in the logs.

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,8 +1770,3 @@ bool TypeSystemSwiftTypeRef::IsReferenceType(opaque_compiler_type_t type,
17701770
VALIDATE_AND_RETURN(impl, IsReferenceType, type,
17711771
(ReconstructType(type), pointee_type, is_rvalue));
17721772
}
1773-
bool TypeSystemSwiftTypeRef::ShouldTreatScalarValueAsAddress(
1774-
opaque_compiler_type_t type) {
1775-
return m_swift_ast_context->ShouldTreatScalarValueAsAddress(
1776-
ReconstructType(type));
1777-
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
226226
uint32_t *bit_offset_ptr) override;
227227
bool IsReferenceType(lldb::opaque_compiler_type_t type,
228228
CompilerType *pointee_type, bool *is_rvalue) override;
229-
bool
230-
ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) override;
231229

232230
// Swift-specific methods.
233231
lldb::TypeSP GetCachedType(ConstString mangled) override;

lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,30 @@ TEST_F(TestTypeSystemSwiftTypeRef, Scalar) {
319319
ASSERT_TRUE(float_type.IsScalarType());
320320
}
321321
}
322+
323+
TEST_F(TestTypeSystemSwiftTypeRef, ScalarAddress) {
324+
using namespace swift::Demangle;
325+
Demangler dem;
326+
NodeBuilder b(dem);
327+
{
328+
NodePointer int_node = b.GlobalTypeMangling(b.IntType());
329+
CompilerType int_type = GetCompilerType(b.Mangle(int_node));
330+
ASSERT_FALSE(int_type.ShouldTreatScalarValueAsAddress());
331+
}
332+
{
333+
NodePointer n = b.GlobalType(b.Node(
334+
Node::Kind::InOut,
335+
b.Node(Node::Kind::Structure,
336+
b.Node(Node::Kind::Module, swift::STDLIB_NAME),
337+
b.Node(Node::Kind::Identifier, swift::BUILTIN_TYPE_NAME_INT))));
338+
CompilerType r = GetCompilerType(b.Mangle(n));
339+
ASSERT_TRUE(r.ShouldTreatScalarValueAsAddress());
340+
}
341+
{
342+
NodePointer n =
343+
b.GlobalType(b.Node(Node::Kind::Class, b.Node(Node::Kind::Module, "M"),
344+
b.Node(Node::Kind::Identifier, "C")));
345+
CompilerType c = GetCompilerType(b.Mangle(n));
346+
ASSERT_TRUE(c.ShouldTreatScalarValueAsAddress());
347+
}
348+
}

0 commit comments

Comments
 (0)