This is an archive of the discontinued LLVM Phabricator instance.

[Templight] Don't display empty strings for names of unnamed template parameters
ClosedPublic

Authored by Szelethus on Dec 10 2021, 7:06 AM.

Details

Summary

Patch originally by oktal3000: https://github.com/mikael-s-persson/templight/pull/40

When a template parameter is unnamed, the name of -templight-dump might return an empty string. This is fine, they are unnamed after all, but it might be more user friendly to at least describe what entity is unnamed.

Diff Detail

Event Timeline

Szelethus created this revision.Dec 10 2021, 7:06 AM
Szelethus requested review of this revision.Dec 10 2021, 7:06 AM
Szelethus retitled this revision from [Templight] Don't return string for name for unnamed template parameters to [Templight] Don't display empty strings for names of unnamed template parameters.Dec 11 2021, 6:56 AM
Szelethus edited the summary of this revision. (Show Details)
sabel83 added inline comments.Dec 11 2021, 7:37 AM
clang/lib/Frontend/FrontendActions.cpp
554

Have you considered generating some default text here?

In case a new, uncovered case does not get covered here in the future generating something like unknown type can keep the overall output (apart from this type) usable until the bug gets fixed.

Szelethus updated this revision to Diff 397054.Jan 3 2022, 6:25 AM

Add a default text, if another, unhandled unnamed identifier pops up.

Szelethus marked an inline comment as done.Jan 3 2022, 6:25 AM
sabel83 accepted this revision.Jan 5 2022, 11:58 AM
This revision is now accepted and ready to land.Jan 5 2022, 11:58 AM
martong added inline comments.Jan 6 2022, 7:50 AM
clang/lib/Frontend/FrontendActions.cpp
501

Should this handle variable templates (VarTemplateDecl) as well? Or it is not possible to have unnamed variable templates?

501–510

Should this handle EnumDecls as well? An enum declaration itself cannot be a primary template, however, it can be 1) a member of a specialization of a templated class 2) an instantiation of a member enumeration of a class template specialization.

Szelethus added inline comments.Jan 11 2022, 1:38 AM
clang/lib/Frontend/FrontendActions.cpp
501

Right now, yes, it seems to that unnamed variable templates are not a thing.

501–510

EnumDecl is a subclass of TagDecl, unless I misunderstood what you meant?

martong accepted this revision.Jan 19 2022, 9:29 AM

LGTM

This revision was landed with ongoing or failed builds.Jan 24 2022, 7:37 AM
This revision was automatically updated to reflect the committed changes.