forked from llvm/llvm-project
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the dynamic type of self in the expression evaluator.
This allows LLDB to resolve generic self types even if no type parameters are present (for example, because they were optimized out) because class objects and other entities carry all their dynamic type information in the *object*. rdar://problem/69020595
- Loading branch information
1 parent
e161d5c
commit eaceb46
Showing
9 changed files
with
167 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SWIFT_SOURCES := main.swift | ||
SWIFTFLAGS_EXTRAS := -O | ||
|
||
include Makefile.rules |
21 changes: 21 additions & 0 deletions
21
lldb/test/API/lang/swift/generic_class/TestSwiftGenericClass.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
import unittest2 | ||
|
||
|
||
class SwiftGenericClassTest(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
def test(self): | ||
"""Tests that a generic class type can be resolved from the instance metadata alone""" | ||
self.build() | ||
(target, process, thread, breakpoint) = lldbutil.run_to_source_breakpoint(self, | ||
"break here", lldb.SBFileSpec("main.swift")) | ||
|
||
self.expect("frame variable -d run self", | ||
substrs=["a.F<Int>", "23", "42", "128", "256"]) | ||
self.expect("expr -d run -- self", | ||
substrs=["a.F<Int>", "23", "42", "128", "256"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
public class F<A> { | ||
let a : A | ||
var b = 42 | ||
var c = 128 | ||
var d = 256 | ||
public init(_ val : A) { a = val } | ||
} | ||
|
||
protocol P { | ||
func method() | ||
} | ||
extension F : P { | ||
@inline(never) func method() { | ||
print("break here \(b)") | ||
} | ||
} | ||
|
||
// Defeat type specialization. | ||
@inline(never) func getF() -> P { | ||
return F<Int>(23) | ||
} | ||
|
||
let obj = getF() | ||
obj.method() | ||
|