Skip to content

[lldb] Pass descriptor finder to computeUnalignedFieldStartOffset #8772

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

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class TargetReflectionContext : public ReflectionContextInterface {
return nullptr;

auto start =
m_reflection_ctx.computeUnalignedFieldStartOffset(type_ref);
m_reflection_ctx.computeUnalignedFieldStartOffset(type_ref, provider);
if (!start) {
if (auto *log = GetLog(LLDBLog::Types)) {
std::stringstream ss;
Expand Down
2 changes: 2 additions & 0 deletions lldb/test/API/lang/swift/c_type_ivar/Foo/Foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Simulates the CoreFoundation CF_BRIDGED_TYPE(id) macro.
typedef struct __attribute__((objc_bridge(id))) {} *BridgedPtr;
3 changes: 3 additions & 0 deletions lldb/test/API/lang/swift/c_type_ivar/Foo/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Foo {
header "Foo.h"
}
4 changes: 4 additions & 0 deletions lldb/test/API/lang/swift/c_type_ivar/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SWIFT_OBJC_INTEROP := 1
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR)/Foo
include Makefile.rules
36 changes: 36 additions & 0 deletions lldb/test/API/lang/swift/c_type_ivar/TestSwiftCTypeIvar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
import unittest2


class TestSwiftCTypeIvar(TestBase):
@swiftTest
@skipIf(setting=("symbols.use-swift-clangimporter", "false"))
def test(self):
"""Test that the extra inhabitants are correctly computed for various
kinds of Objective-C pointers, by using them in enums."""
self.build()
# Disable SwiftASTContext because we want to test we resolve the type
# by looking up the clang type in debug info.
self.runCmd("settings set symbols.swift-enable-ast-context false")
lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.swift")
)
# self.expect('v a', substrs=['asdf'])
a = self.frame().FindVariable("a")
lldbutil.check_variable(
self,
a.GetChildAtIndex(0),
typename="Swift.Optional<Foo.BridgedPtr>",
value="none",
)

b = self.frame().FindVariable("b")
lldbutil.check_variable(
self,
a.GetChildAtIndex(0),
typename="Swift.Optional<Foo.BridgedPtr>",
value="none",
)
18 changes: 18 additions & 0 deletions lldb/test/API/lang/swift/c_type_ivar/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foo

class A {
let bridged : BridgedPtr? = nil
}

class B : A {}

func use<T>(_ t: T) {}

func main() {
let a = A()
let b = B()
use(a)
use(b) // break here
}

main()