This is an archive of the discontinued LLVM Phabricator instance.

[clangd] show underlying type in type hint for `decltype(expr)`
ClosedPublic

Authored by v1nh1shungry on Dec 31 2022, 8:55 PM.

Diff Detail

Event Timeline

v1nh1shungry created this revision.Dec 31 2022, 8:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 31 2022, 8:55 PM
v1nh1shungry requested review of this revision.Dec 31 2022, 8:55 PM

Thanks, I think this behaviour change is reasonable.

clang-tools-extra/clangd/InlayHints.cpp
680

Can we factor out a function ShouldPrintCanonicalType(QualType), and add a comment like this in its implementation:

// The sugared type is more useful in some cases, and the canonical
// type in other cases. For now, prefer the sugared type unless
// we are printing `decltype(expr)`. This could be refined further
// (see https://github.com/clangd/clangd/issues/1298).

Then in this function we can set:

TypeHintPolicy.PrintCanonicalTypes = ShouldPrintCanonicalType(T);

apply comment's suggestions

v1nh1shungry marked an inline comment as done.Jan 2 2023, 3:18 AM

Thanks for reviewing and giving suggestions!

nridge accepted this revision.Jan 2 2023, 10:23 PM

Thanks!

clang-tools-extra/clangd/InlayHints.cpp
665

small nit: could you put the comment inside the function, since it's more an explanation of the current logic in the implementation

This revision is now accepted and ready to land.Jan 2 2023, 10:23 PM

move the comment

v1nh1shungry marked an inline comment as done.Jan 2 2023, 11:45 PM
This revision was automatically updated to reflect the committed changes.