-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[NFC] Distinguish references to names from declarations of those names by type #27683
[NFC] Distinguish references to names from declarations of those names by type #27683
Conversation
04d2fc4
to
fc9bbe6
Compare
fc03843
to
2a8e86e
Compare
This comment has been minimized.
This comment has been minimized.
2a8e86e
to
f44c115
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'm going to try running tests from the llvm-project side in swiftlang/llvm-project#430. |
e9f6114
to
abe6208
Compare
With swiftlang/llvm-project#430 @swift-ci please test |
Build failed |
Notes for reviewers:
|
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 can't spot anything wrong, but then again this is a lot of code. Can the smaller refactorings be merged off separately? Ideally this patch would just be the renaming and the type plumbing afterwards.
@CodaFi I could pull b1fbdbfe (Miscellaneous improvements to Playground and PCMacro transforms) into a separate followup PR; that part is +84 -88 and nothing else needs it. I don't know if there's anything else I can easily extract, though. Any suggestions? |
Build failed |
3c6e4e2
to
504a815
Compare
With swiftlang/llvm-project#430 @swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
We were unnecessarily converting back and forth between base names and full names, which seemed a bit silly.
This change adds UnresolvedDotExpr::createImplicit() and UnresolvedDeclRefExpr::createImplicit() helpers. These calls simplify several tedious bits of code synthesis that would otherwise become even more tedious with DeclNameRef in the picture.
This has the side effect of threading compound name support through more enum pattern code, although it’s still not complete.
So that DeclName can have a spare bit, allowing it to be used in places where we’re currently using PointerIntPair<Identifier, 1> or PointerUnion<Identifier, Whatever>.
Replaces `ComponentIdentTypeRepr::getIdentifier()` and `getIdLoc()` with `getNameRef()` and `getNameLoc()`, which use `DeclName` and `DeclNameRef` respectively.
This feature is barely used and needs refactoring that would be outside the scope of this series of commits (see https://bugs.swift.org/browse/SR-11241).
Change the various AST transforms to use prebuilt DeclName constants more heavily rather than an ad-hoc mix of Identifiers, string literals, std::strings, and StringRefs with questionable memory management.
This type wraps a DeclName, indicating that it is a reference to a declaration that exists somewhere else and it requires slightly “fuzzy” comparison (i.e. if it’s not compound, only the base names should be compared). DeclName::matchesRef() and MemberLookupTable::find() both now take a DeclNameRef instead of a DeclName. This commit temporarily allows implicit conversion from DeclName; I’ll flip the switch on that in a later commit.
This huge commit contains as many of the mechanical changes as possible.
Seems to have been a mismerge or something?
504a815
to
db15d82
Compare
Needed yet another rebase. With swiftlang/llvm-project#430 @swift-ci please smoke test |
With swiftlang/llvm-project#430 @swift-ci please test compiler performance |
With swiftlang/llvm-project#430 @swift-ci please test source compatibility |
With swiftlang/llvm-project#430 @swift-ci please smoke test compiler performance |
LLDB update for swiftlang/swift#27683 "Distinguish references to names from declarations of those names by type"
This is a refactoring in support of the module qualification feature I've previously pitched on Evolution.
The eventual goal for that feature is to allow any place that uses a name for a declaration defined elsewhere to qualify it with a module name. That is, all of these should allow modules:
But things like this should not:
To support this distinction, this PR adds a
DeclNameRef
type to the compiler. This type currently just wrapsDeclName
, but in the future it will also be able to store a module name when the user module-qualifies a name. Declarations will continue to store aDeclName
orIdentifier
for their own names, but name lookup entry points—and therefore many other AST nodes likeUnresolvedDeclRefExpr
s andTypeRepr
s—will switch over to usingDeclNameRef
. Thus, this PR will establish the pathways through which module qualification information will flow without actually making any functional changes to the compiler. This will reduce the amount of merge conflicts during the feature's design and review.While this PR is in progress,DeclNameRef
's constructors will be implicit but deprecated, and aDeclNameRef_
function is used whenever we want to explicitly construct aDeclNameRef
. Before I merge this commit, I will make theDeclNameRef
constructors explicit, rename allDeclNameRef_
s toDeclNameRef
, and delete theDeclNameRef
function.