Skip to content

Commit c32e305

Browse files
Merge pull request #1449 from adrian-prantl/isdefined
Implement TypeSystemSwiftTypeRef::IsDefined (NFC)
2 parents 5a5b279 + d772905 commit c32e305

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lldb/source/Symbol/TypeSystemSwiftTypeRef.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,10 @@ bool TypeSystemSwiftTypeRef::IsAggregateType(opaque_compiler_type_t type) {
931931
}
932932

933933
bool TypeSystemSwiftTypeRef::IsDefined(opaque_compiler_type_t type) {
934-
return m_swift_ast_context->IsDefined(ReconstructType(type));
934+
auto impl = [&]() -> bool {
935+
return type;
936+
};
937+
VALIDATE_AND_RETURN(impl, IsDefined, type, (ReconstructType(type)));
935938
}
936939
bool TypeSystemSwiftTypeRef::IsFloatingPointType(opaque_compiler_type_t type,
937940
uint32_t &count,

lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,16 @@ TEST_F(TestTypeSystemSwiftTypeRef, Aggregate) {
267267
ASSERT_FALSE(tau.IsAggregateType());
268268
}
269269
}
270+
271+
TEST_F(TestTypeSystemSwiftTypeRef, Defined) {
272+
using namespace swift::Demangle;
273+
Demangler dem;
274+
NodeBuilder b(dem);
275+
{
276+
NodePointer int_node = b.GlobalTypeMangling(b.IntType());
277+
CompilerType int_type = GetCompilerType(b.Mangle(int_node));
278+
ASSERT_TRUE(int_type.IsDefined());
279+
// It's technically not possible to construct such a CompilerType.
280+
ASSERT_FALSE(m_swift_ts.IsDefined(nullptr));
281+
}
282+
}

0 commit comments

Comments
 (0)