forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
Fix extra inhabitants count for Clang-imported pointers. #8072
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
adrian-prantl
merged 1 commit into
swiftlang:stable/20230725
from
adrian-prantl:121225616
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
5 changes: 5 additions & 0 deletions
5
lldb/test/API/lang/swift/clangimporter/extra_inhabitants/Foo/Foo.h
This file contains hidden or 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,5 @@ | ||
typedef struct {} *StructPtr; | ||
// Simulates the CoreFoundation CF_BRIDGED_TYPE(id) macro. | ||
typedef struct __attribute__((objc_bridge(id))) {} *BridgedPtr; | ||
typedef id OpaqueObj; | ||
typedef void *VoidPtr; |
3 changes: 3 additions & 0 deletions
3
lldb/test/API/lang/swift/clangimporter/extra_inhabitants/Foo/module.modulemap
This file contains hidden or 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,3 @@ | ||
module Foo { | ||
header "Foo.h" | ||
} |
4 changes: 4 additions & 0 deletions
4
lldb/test/API/lang/swift/clangimporter/extra_inhabitants/Makefile
This file contains hidden or 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_OBJC_INTEROP := 1 | ||
SWIFT_SOURCES := main.swift | ||
SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR)/Foo | ||
include Makefile.rules |
41 changes: 41 additions & 0 deletions
41
.../API/lang/swift/clangimporter/extra_inhabitants/TestSwiftClangImporterExtraInhabitants.py
This file contains hidden or 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,41 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
import unittest2 | ||
|
||
class TestSwiftClangImporterExtraInhabitants(TestBase): | ||
@swiftTest | ||
@skipUnlessDarwin | ||
# Don't run ClangImporter tests if Clangimporter is disabled. | ||
@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() | ||
lldbutil.run_to_source_breakpoint(self, 'break here', | ||
lldb.SBFileSpec('main.swift')) | ||
var = self.frame().FindVariable("mystruct") | ||
check = lldbutil.check_variable | ||
|
||
check(self, var.GetChildAtIndex(0), value="0") | ||
check(self, var.GetChildAtIndex(1), | ||
typename="Swift.Optional<Swift.OpaquePointer>", | ||
summary="nil") | ||
|
||
check(self, var.GetChildAtIndex(2), value="2") | ||
check(self, var.GetChildAtIndex(3), | ||
typename="Swift.Optional<Foo.BridgedPtr>", | ||
summary="nil") | ||
|
||
check(self, var.GetChildAtIndex(4), value="4") | ||
check(self, var.GetChildAtIndex(5), | ||
typename="Swift.Optional<Swift.AnyObject>", | ||
summary="nil") | ||
|
||
check(self, var.GetChildAtIndex(6), value="6") | ||
check(self, var.GetChildAtIndex(7), | ||
typename="Swift.Optional<Swift.UnsafeMutableRawPointer>", | ||
summary="nil") | ||
|
||
check(self, var.GetChildAtIndex(8), value="8") |
23 changes: 23 additions & 0 deletions
23
lldb/test/API/lang/swift/clangimporter/extra_inhabitants/main.swift
This file contains hidden or 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,23 @@ | ||
import Foo | ||
|
||
class MyStruct { | ||
let m0 : Int = 0 | ||
let pointer : StructPtr? = nil | ||
let m2 : Int = 2 | ||
let bridged : BridgedPtr? = nil | ||
let m4 : Int = 4 | ||
let opaque : OpaqueObj? = nil | ||
let m6 : Int = 6 | ||
let void : VoidPtr? = nil | ||
let m8 : Int = 8 | ||
init() {} | ||
} | ||
|
||
func use<T>(_ t: T) {} | ||
|
||
func main() { | ||
let mystruct = MyStruct() | ||
use(mystruct) // break here | ||
} | ||
|
||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.