Remove the Dump method from Printable (#7118)

Because this is an `__attribute__((used))` method in a templated base
class it forces a _huge_ amount of template instantiation in every
translation unit.

Often this was just printing the members of the type, which is still
useful in some cases (such as test output), but adds no value in the
debugger.

A more successful pattern for dumping has been namespace level
functions, and particularly static ones that more transparently don't
expand the non-debugger API surface. Add the few missing functions there
that cover `Printable` types with more interesting contents.

For several of these, it just gives us a "dump the whole thing" function
as a compliment to "dump this entity in the thing". These probably
aren't especially high value, but moving them here they become cheap, so
I've left them in.

For a couple, this expands the rich dumping support of SemIR constructs,
which should be substantially more useful than the previous `Dump`
behavior.

This reduces `check` cumulative object file size by another 14%.

Assisted-by: Antigravity with Gemini
This commit is contained in:
Chandler Carruth
2026-04-26 16:21:07 +00:00
committed by GitHub
parent 235267680b
commit df6a5a50dc
4 changed files with 67 additions and 8 deletions
+4
View File
@@ -14,6 +14,10 @@
namespace Carbon::Parse {
static LLVM_DUMP_METHOD auto Dump(const Tree& tree) -> std::string {
return PrintToString(tree);
}
LLVM_DUMP_METHOD auto Dump(const Tree& tree, Lex::TokenIndex token)
-> std::string {
return Lex::Dump(tree.tokens(), token);