Skip to content

Make Swift result variables persistent #7141

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

Conversation

adrian-prantl
Copy link

While also being more efficient and shorter, this is done mainly in preparation for followup changes.

@adrian-prantl
Copy link
Author

rdar://113352990

@adrian-prantl
Copy link
Author

@swift-ci test

Copy link

@kastiglione kastiglione left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this a multimap, and why can it now be a (single) map?

I did a quick read of the places where equal_range was used, but on first look it's not clear to me why it was a multimap, nor is it clear what DeclsAreEquivalent was used for.

Note: DeclsAreEquivalent is no longer used now as of this change.

@adrian-prantl
Copy link
Author

Why was this a multimap, and why can it now be a (single) map?

I converted a multimap<String, Decl *> into a Stringmap<SmallVector<Decl *>>

I did a quick read of the places where equal_range was used, but on first look it's not clear to me why it was a multimap, nor is it clear what DeclsAreEquivalent was used for.

Note: DeclsAreEquivalent is no longer used now as of this change.

Let me check ...

@adrian-prantl
Copy link
Author

Fix call to the wrong version of SmallVector.erase()

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

Added a second NFC refactoring on top of this patch.

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

The last patch in the series is still WIP, in the sense of that I still need to add a test for it.

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl adrian-prantl changed the title Replace std::multimap with llvm::StringMap (NFC) Make Swift result variables persistent Aug 4, 2023
@adrian-prantl
Copy link
Author

@swift-ci test windows

@adrian-prantl
Copy link
Author

@augusto2112 @kastiglione Would you mind taking another look at this? The goal here is to make Swift result variables portable between different SwiftASTContext instances.

Generally, LLDB takes compiler plugin search paths from serialized
options in Swift modules, however, for the REPL and Playgrounds it is
useful to always add the host toolchain plugins by default.

Unfortunately this is a property of the toolchain lldb is installed
with, so this is not really testable from within an uninstalled build.

rdar://112122752
@adrian-prantl
Copy link
Author

ping :-)

While also being more efficient and shorter, this is done mainly in
preparation for followup changes.
A CompilerDecl is a pair of TypeSystem and Decl *. This is in
preparation for a later patch.
…xtFE (NFC)

This change is (somewhat surprisingly) NFC, since the list is only
consumed by SwiftExpressionParser and only populated by it as well.
When SwiftASTContextForExpressions is destroyed the persistent state is too.
@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test windows

…ftTypeRefFE

This allows result variables to persist across SwiftASTContexts.
User declarations become invisible in other contexts (NFC)
User imports also don't affect other contexts (NFC)
@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test windows

1 similar comment
@adrian-prantl
Copy link
Author

@swift-ci test windows

@adrian-prantl adrian-prantl merged commit 379927e into swiftlang:swift/release/5.9 Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants