forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 349
[lldb] Increment index of field we're looking for when not an enum #5307
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
augusto2112
merged 1 commit into
swiftlang:stable/20220421
from
augusto2112:increment-not-enum
Oct 4, 2022
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SWIFT_SOURCES := main.swift | ||
SWIFT_BRIDGING_HEADER := bridging-header.h | ||
include Makefile.rules |
39 changes: 39 additions & 0 deletions
39
lldb/test/API/lang/swift/c_type_external_provider/TestSwiftCTypeExternalProvider.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,39 @@ | ||
""" | ||
Tests that LLDB uses the external type info provider for C types. | ||
""" | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
import unittest2 | ||
|
||
|
||
|
||
class TestSwiftCTypeExternalProvider(TestBase): | ||
def setUp(self): | ||
TestBase.setUp(self) | ||
self.main_source = "main.swift" | ||
self.main_source_spec = lldb.SBFileSpec(self.main_source) | ||
|
||
@swiftTest | ||
def test_swift_regex(self): | ||
"""Test that C types with builtin metadata emitted are looked up using | ||
external type info provider.""" | ||
self.build() | ||
log = self.getBuildArtifact("types.log") | ||
self.runCmd('log enable lldb types -f "%s"' % log) | ||
lldbutil.run_to_source_breakpoint( | ||
self, 'Set breakpoint here', self.main_source_spec) | ||
|
||
# Consult the second field to ensure we call GetIndexOfChildMemberWithName. | ||
self.expect('v dummy.second', substrs=['2']) | ||
|
||
# Make sure we look up the type with the external type info provider. | ||
provider_log_found = False | ||
with open(log, "r", encoding='utf-8') as logfile: | ||
|
||
for line in logfile: | ||
if '[LLDBTypeInfoProvider] Looking up debug type info for So5DummyV' in line: | ||
provider_log_found = True | ||
break | ||
self.assertTrue(provider_log_found) | ||
|
8 changes: 8 additions & 0 deletions
8
lldb/test/API/lang/swift/c_type_external_provider/bridging-header.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,8 @@ | ||
#ifndef bridging_header_h | ||
#define bridging_header_h | ||
|
||
struct Dummy { | ||
int first; | ||
int second; | ||
}; | ||
#endif /* bridging_header_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,6 @@ | ||
var dummy = Dummy() | ||
dummy.first = 1; | ||
dummy.second = 2; | ||
// Print dummy so we ensure we generate it's metadata. | ||
print(Dummy.self) // Set breakpoint here. | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to comment (I assume it's because enums have exactly 1 field?)
Also: should this be
!is_enum &&
field.TR`?Finally: testcase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment there still applies. If it's an enum and there's no typeref then we don't increment the index, because that's a case without a payload.
I don't think so? If it's not not an enum we always want to increment the index (given the previous comment), in case it's an enum we wan't to increment only if there's a typeref.
If we merge swiftlang/swift#61081
TestSwiftFoundation.py
will catch this. Otherwise I'll have to figure out a way to trigger this behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right.