From 92c8cf19e5f0969a2d1a2fa25990975f0e56abaa Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Tue, 14 Jul 2020 15:46:46 -0300 Subject: [PATCH] Disable loading scalars as addresses when materializing an entity variable (cherry picked from commit fea5ac27116bd7509a2c10de7d4921dbcfd84e41) --- lldb/source/Expression/Materializer.cpp | 5 +---- .../TestClassConstrainedProtocol.py | 1 - .../expression/self_from_register/Makefile | 3 +++ .../self_from_register/TestSelfFromRegister.py | 17 +++++++++++++++++ .../expression/self_from_register/main.swift | 13 +++++++++++++ 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 lldb/test/API/lang/swift/expression/self_from_register/Makefile create mode 100644 lldb/test/API/lang/swift/expression/self_from_register/TestSelfFromRegister.py create mode 100644 lldb/test/API/lang/swift/expression/self_from_register/main.swift diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index cee5dbf8785de..ce6c6a8f4417b 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -489,10 +489,7 @@ class EntityVariable : public Materializer::Entity { } } else { AddressType address_type = eAddressTypeInvalid; - const bool scalar_is_load_address = m_is_generic; // this is the only - // time we're dealing - // with dynamic values - + const bool scalar_is_load_address = false; lldb::addr_t addr_of_valobj = valobj_sp->GetAddressOf(scalar_is_load_address, &address_type); diff --git a/lldb/test/API/lang/swift/expression/class_constrained_protocol/TestClassConstrainedProtocol.py b/lldb/test/API/lang/swift/expression/class_constrained_protocol/TestClassConstrainedProtocol.py index a9185fe42b204..6d6eb5cbbec87 100644 --- a/lldb/test/API/lang/swift/expression/class_constrained_protocol/TestClassConstrainedProtocol.py +++ b/lldb/test/API/lang/swift/expression/class_constrained_protocol/TestClassConstrainedProtocol.py @@ -24,7 +24,6 @@ def test_extension_weak_self (self): self.do_self_test("Break here for weak self") @swiftTest - @expectedFailureAll(oslist=["linux"], bugnumber="rdar://31822722") def test_extension_self (self): """Test that we can reconstruct self in method of a class constrained protocol.""" self.build() diff --git a/lldb/test/API/lang/swift/expression/self_from_register/Makefile b/lldb/test/API/lang/swift/expression/self_from_register/Makefile new file mode 100644 index 0000000000000..2a69023633b34 --- /dev/null +++ b/lldb/test/API/lang/swift/expression/self_from_register/Makefile @@ -0,0 +1,3 @@ +SWIFT_SOURCES := main.swift + +include Makefile.rules diff --git a/lldb/test/API/lang/swift/expression/self_from_register/TestSelfFromRegister.py b/lldb/test/API/lang/swift/expression/self_from_register/TestSelfFromRegister.py new file mode 100644 index 0000000000000..938ed482fca30 --- /dev/null +++ b/lldb/test/API/lang/swift/expression/self_from_register/TestSelfFromRegister.py @@ -0,0 +1,17 @@ +# TestSelfFromRegister.py +# +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See https://swift.org/LICENSE.txt for license information +# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +# +# ------------------------------------------------------------------------------ + +import lldbsuite.test.lldbinline as lldbinline +from lldbsuite.test.decorators import * + +# Test that loading self from a register works as expected +lldbinline.MakeInlineTest(__file__, globals(), decorators=[swiftTest]) diff --git a/lldb/test/API/lang/swift/expression/self_from_register/main.swift b/lldb/test/API/lang/swift/expression/self_from_register/main.swift new file mode 100644 index 0000000000000..6c010610bf352 --- /dev/null +++ b/lldb/test/API/lang/swift/expression/self_from_register/main.swift @@ -0,0 +1,13 @@ +class C : CP { + let f: Int = 12345 +} + +protocol CP : class {} + +extension CP { + func foo() { + print(self) //% self.expect('e f', substrs=[' = 12345']) + } +} + +C().foo()