Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Warnings #2052

Merged
merged 2 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,30 @@ ResolveTypeAlias(SwiftASTContext *module_holder,
return {n, {}};
}

std::string
TypeSystemSwiftTypeRef::GetTupleElementName(lldb::opaque_compiler_type_t type,
size_t idx) {
using namespace swift::Demangle;
Demangler dem;
NodePointer node = TypeSystemSwiftTypeRef::DemangleCanonicalType(dem, type);
if (!node || node->getKind() != Node::Kind::Tuple)
return "";
if (node->getNumChildren() < idx)
return "";
NodePointer child = node->getChild(idx);
if (child->getNumChildren() != 1 &&
child->getKind() != Node::Kind::TupleElement)
return "";
for (NodePointer name : *child) {
if (name->getKind() != Node::Kind::TupleElementName)
continue;
return name->getText().str();
}
std::string name;
llvm::raw_string_ostream(name) << idx;
return name;
}

swift::Demangle::NodePointer TypeSystemSwiftTypeRef::Transform(
swift::Demangle::Demangler &dem, swift::Demangle::NodePointer node,
std::function<swift::Demangle::NodePointer(swift::Demangle::NodePointer)>
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
bool print_help_if_available, bool print_extensions_if_available,
lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) override;

/// Return the nth tuple element's name, if it has one.
std::string GetTupleElementName(lldb::opaque_compiler_type_t type,
size_t idx);

/// Recursively transform the demangle tree starting a \p node by
/// doing a post-order traversal and replacing each node with
/// fn(node).
Expand Down
14 changes: 14 additions & 0 deletions lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,20 @@ class LLDBMemoryReader : public swift::remote::MemoryReader {
bool queryDataLayout(DataLayoutQueryType type, void *inBuffer,
void *outBuffer) override {
switch (type) {
// FIXME: add support for case DLQ_GetPtrAuthMask:
case DLQ_GetObjCReservedLowBits: {
Comment on lines +283 to +284

Choose a reason for hiding this comment

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

Nice I was wondering what to do about this, but I figured it's good that the warning is there to tell us that it's a todo.

auto *result = static_cast<uint8_t *>(outBuffer);
auto &triple = m_process.GetTarget().GetArchitecture().GetTriple();
if (triple.isMacOSX() && triple.getArch() == llvm::Triple::x86_64) {
// Obj-C reserves low bit on 64-bit Intel macOS only.
// Other Apple platforms don't reserve this bit (even when
// running on x86_64-based simulators).
*result = 1;
} else {
*result = 0;
}
break;
}
case DLQ_GetPointerSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = m_process.GetAddressByteSize();
Expand Down
26 changes: 20 additions & 6 deletions lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ TEST_F(TestTypeSystemSwiftTypeRef, Function) {
CompilerType void_void = GetCompilerType(b.Mangle(n));
ASSERT_TRUE(void_void.IsFunctionType(nullptr));
ASSERT_TRUE(void_void.IsFunctionPointerType());
ASSERT_EQ(void_void.GetNumberOfFunctionArguments(), 0);
ASSERT_EQ(void_void.GetNumberOfFunctionArguments(), 0UL);
}
{
NodePointer n = b.GlobalType(
b.Node(Node::Kind::ImplFunctionType, b.Node(Node::Kind::ImplEscaping),
b.Node(Node::Kind::ImplConvention, "@callee_guaranteed")));
CompilerType impl_void_void = GetCompilerType(b.Mangle(n));
ASSERT_TRUE(impl_void_void.IsFunctionType(nullptr));
ASSERT_EQ(impl_void_void.GetNumberOfFunctionArguments(), 0);
ASSERT_EQ(impl_void_void.GetNumberOfFunctionArguments(), 0UL);
}
{
NodePointer n = b.GlobalType(b.Node(
Expand All @@ -147,7 +147,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Function) {
b.Node(Node::Kind::Tuple))));
CompilerType impl_two_args = GetCompilerType(b.Mangle(n));
ASSERT_TRUE(impl_two_args.IsFunctionType(nullptr));
ASSERT_EQ(impl_two_args.GetNumberOfFunctionArguments(), 2);
ASSERT_EQ(impl_two_args.GetNumberOfFunctionArguments(), 2UL);
ASSERT_EQ(impl_two_args.GetFunctionArgumentAtIndex(0), int_type);
ASSERT_EQ(impl_two_args.GetFunctionArgumentAtIndex(1), void_type);
ASSERT_EQ(impl_two_args.GetFunctionArgumentTypeAtIndex(0), int_type);
Expand All @@ -167,7 +167,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Function) {
b.Node(Node::Kind::Type, b.Node(Node::Kind::Tuple)))));
CompilerType two_args = GetCompilerType(b.Mangle(n));
ASSERT_TRUE(two_args.IsFunctionType(nullptr));
ASSERT_EQ(two_args.GetNumberOfFunctionArguments(), 2);
ASSERT_EQ(two_args.GetNumberOfFunctionArguments(), 2UL);
ASSERT_EQ(two_args.GetFunctionArgumentAtIndex(0), int_type);
ASSERT_EQ(two_args.GetFunctionArgumentAtIndex(1), void_type);
ASSERT_EQ(two_args.GetFunctionArgumentTypeAtIndex(0), int_type);
Expand Down Expand Up @@ -306,7 +306,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Scalar) {
uint32_t count = 99;
bool is_complex = true;
ASSERT_FALSE(int_type.IsFloatingPointType(count, is_complex));
ASSERT_EQ(count, 0);
ASSERT_EQ(count, 0UL);
ASSERT_EQ(is_complex, false);
bool is_signed = true;
ASSERT_TRUE(int_type.IsIntegerType(is_signed));
Expand All @@ -318,7 +318,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, Scalar) {
uint32_t count = 99;
bool is_complex = true;
ASSERT_TRUE(float_type.IsFloatingPointType(count, is_complex));
ASSERT_EQ(count, 1);
ASSERT_EQ(count, 1UL);
ASSERT_EQ(is_complex, false);
bool is_signed = true;
ASSERT_FALSE(float_type.IsIntegerType(is_signed));
Expand Down Expand Up @@ -402,6 +402,20 @@ TEST_F(TestTypeSystemSwiftTypeRef, Tuple) {
ASSERT_EQ(float_int_tuple.GetMangledTypeName(),
"$ss0019BuiltinFPIEEE_CJEEdV1f_s0016BuiltinInt_gCJAcV1itD");
}
{
NodePointer n = b.GlobalType(
b.Node(Node::Kind::Tuple,
b.Node(Node::Kind::TupleElement,
b.Node(Node::Kind::TupleElementName, "x"), b.IntType()),
b.Node(Node::Kind::TupleElement, b.IntType()),
b.Node(Node::Kind::TupleElement,
b.Node(Node::Kind::TupleElementName, "z"), b.IntType())));
CompilerType t = GetCompilerType(b.Mangle(n));
lldb::opaque_compiler_type_t o = t.GetOpaqueQualType();
ASSERT_EQ(m_swift_ts.GetTupleElementName(o, 0), "x");
ASSERT_EQ(m_swift_ts.GetTupleElementName(o, 1), "1");
ASSERT_EQ(m_swift_ts.GetTupleElementName(o, 2), "z");
}
}

TEST_F(TestTypeSystemSwiftTypeRef, TypeClass) {
Expand Down