[PATCH] D140814: [clangd] show underlying type in type hint for `decltype(expr)`

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 2 00:57:37 PST 2023


nridge added a comment.

Thanks, I think this behaviour change is reasonable.



================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:667
+    // print the underlying type for `decltype(expr)`
+    if (T->isDecltypeType())
+      TypeHintPolicy.PrintCanonicalTypes = true;
----------------
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);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140814/new/

https://reviews.llvm.org/D140814



More information about the cfe-commits mailing list