This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Ignore certain Clang type sugar when creating the type name
ClosedPublic

Authored by teemperor on Sep 10 2020, 1:55 PM.

Details

Summary

Clang has some type sugar that only serves as a way to preserve the way
a user has typed a certain type in the source code. These types are currently
not unwrapped when we query the type name for a Clang type, which means
that this type sugar actually influences what formatters are picked for a certain
type. Currently if a user decides to reference a type by doing ::GlobalDecl Var = 3;,
the type formatter for GlobalDecl will not be used (as the type sugar around the
type gives it the name ::GlobalDecl. The same goes for other ways to spell out
a type such as auto etc.

With this patch most of this type sugar gets stripped when the full type name is
calculated. Typedefs are not getting desugared as that seems counterproductive.
I also don't desugar atomic types as that's technically not type sugar.

Diff Detail

Event Timeline

teemperor created this revision.Sep 10 2020, 1:55 PM
teemperor requested review of this revision.Sep 10 2020, 1:55 PM
jarin accepted this revision.Sep 14 2020, 4:50 AM

This makes sense, thanks!

Since your main motivation is formatter selection, you might want to consider adding a formatting test, too. To be precise, I see that you have a formatting test for typedef already, but that one would pass even without your change (as far as I can see). I mean a formatting test for the case described in your patch summary, that one should fail without your patch.

This revision is now accepted and ready to land.Sep 14 2020, 4:50 AM
teemperor planned changes to this revision.Sep 14 2020, 9:38 AM

This makes sense, thanks!

Since your main motivation is formatter selection, you might want to consider adding a formatting test, too. To be precise, I see that you have a formatting test for typedef already, but that one would pass even without your change (as far as I can see). I mean a formatting test for the case described in your patch summary, that one should fail without your patch.

Good point! It seems I broke the last test while simplifying it to use a typedef which has its own special code path. I'll go back to using the record type also for last part of the test.

teemperor updated this revision to Diff 293403.Sep 22 2020, 3:40 AM
  • Don't use a typedef in the formatter test case (which already has a special code path) but just a struct.
This revision is now accepted and ready to land.Sep 22 2020, 3:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2020, 4:38 AM