Skip to content

AST: Rename debugger pretty printer Type::dumpPrint to print #77920

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
merged 1 commit into from
Mar 25, 2025

Conversation

AnthonyLatsis
Copy link
Collaborator

This name is consistent with other output API and, thus, more discoverable.

This name is consistent with other output API and, thus, more
discoverable.
@@ -7633,7 +7633,7 @@ std::string TypeBase::getStringAsComponent(const PrintOptions &PO) const {
return OS.str();
}

void TypeBase::dumpPrint() const {
void TypeBase::print() const {
Copy link
Contributor

@gottesmm gottesmm Dec 3, 2024

Choose a reason for hiding this comment

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

This is actually inconsistent. "print" is never used for debug dumping. You can see this by doing a git grep of SWIFT_DEBUG_DUMPER in the code base. Just a small sample:

swift % git grep SWIFT_DEBUG_DUMPER
include/swift/AST/ActorIsolation.h:  SWIFT_DEBUG_DUMPER(dump());
include/swift/AST/ActorIsolation.h:  SWIFT_DEBUG_DUMPER(dumpForDiagnostics());
include/swift/AST/Attr.h:  SWIFT_DEBUG_DUMPER(dump(const Decl *D = nullptr));
include/swift/AST/Attr.h:  SWIFT_DEBUG_DUMPER(dump());
include/swift/AST/AvailabilityScope.h:  SWIFT_DEBUG_DUMPER(dump(SourceManager &SrcMgr));
include/swift/AST/Decl.h:  SWIFT_DEBUG_DUMPER(dump(const char *filename));
include/swift/AST/Decl.h:  SWIFT_DEBUG_DUMPER(dumpRef());
include/swift/AST/DeclContext.h:  SWIFT_DEBUG_DUMPER(dumpContext());
include/swift/AST/FileUnit.h:  SWIFT_DEBUG_DUMPER(dumpDisplayDecls());
include/swift/AST/FileUnit.h:  SWIFT_DEBUG_DUMPER(dumpTopLevelDecls());

It is always some variant of "dumpX". print is always used for the non-debug dump variant that can be called programatically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, in that sense the name is inconsistent. But is that an intentional consistency? I personally find print useful for debugging and want to be able to call it on AST nodes from the debugger by the same name (just as I would by print debugging) without it forcing me to provide arguments, only to fail to resolve some LLVM symbols because my LLVM build is RelWithDebInfo. I also don’t want other contributors to have a hard time figuring out how to spell these out in the debugger.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@beccadax Hey Becca, I would appreciate an opinion on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

dump() means "print detailed s-expression notation" while print() is "print this node as Swift source". Renaming dumpPrint() to print() is fine, because it just calls the other overload of print().

We similarly overload dump() for no arguments vs a stream argument as well.

@@ -7633,7 +7633,7 @@ std::string TypeBase::getStringAsComponent(const PrintOptions &PO) const {
return OS.str();
}

void TypeBase::dumpPrint() const {
void TypeBase::print() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

dump() means "print detailed s-expression notation" while print() is "print this node as Swift source". Renaming dumpPrint() to print() is fine, because it just calls the other overload of print().

We similarly overload dump() for no arguments vs a stream argument as well.

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test

@AnthonyLatsis AnthonyLatsis enabled auto-merge March 25, 2025 18:51
@AnthonyLatsis AnthonyLatsis merged commit a75b63a into swiftlang:main Mar 25, 2025
3 checks passed
@AnthonyLatsis AnthonyLatsis deleted the fissidens branch March 26, 2025 00:13
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