Skip to content

Conversation

@hamishknight
Copy link
Contributor

  • Avoid tracking the @abi declaration in SourceKit's AnnotatingPrinter
  • Ignore the @abi declaration when mangling USRs for semantic functionality since we need to be able to perform name lookup using the mangled name to retrieve the original decl. It also seems like it makes more sense in general for USRs to only be concerned about the API of a given declaration since for semantic functionality we don't care about ABI.

Resolves #85030

@hamishknight
Copy link
Contributor Author

hamishknight commented Oct 22, 2025

Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

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

I can't speak for the larger picture of this fix, but the logic looks sound.

return true;

// We only care about API for documentation purposes.
if (!ABIRoleInfo(D).providesAPI())
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks right.

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

Thanks 🙇

Comment on lines -193 to +201
DWARFMangling = true;
this->DWARFMangling = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

😨 wasn't breaking any tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently not, mangleTypeForDebugger also sets this to true though, which seems to be the main client that relies on it. I somewhat suspect we could remove this parameter from the constructor

Make sure we avoid adding these to the entity stack entirely, which
avoids hitting the assertion that a top-level entity isn't encountered
with a non-empty stack.
Turns out this constructor was never actually setting this bit.
`mangleTypeForDebugger` also sets this to `true`, so it doesn't seem
like this caused issues in practice, but let's actually set it. This
parameter seems like it could be removed at this point, but I'll
leave that for a follow-up.
Rather than setting the USR-specific bits for each USR entrypoint
into the mangler just expose a convenience constructor for USR
generation that sets them.
This was always set to `true` except for USR mangling, where we already
have it set to `false` for IDE USRs. The other clients were:

- AutoDiff, which is just using the resulting string as a dictionary
key, so don't seem to have any preference.
- The ClangImporter, which always overrides `@_originallyDefinedIn`
anyway.
This is used by other things that don't necessarily want an IDE
USR.
For semantic functionality the API decl is the more useful thing to
mangle, and redeclaration checking ensures we can't end up with
conflicts. This ensures we're able to perform a name lookup for the
decl based on its USR without having to maintain a separate lookup 
table for ABI names.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit 7f6a4da into swiftlang:main Oct 23, 2025
4 of 5 checks passed
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.

The new verifyUSRToDeclReconstruction checking cannot handle @abi when the abi name does not exist in real ast

3 participants