[PATCH] D156300: [clangd] Avoid unexpected desugaring in isSugaredTemplateParameter
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 31 01:12:09 PDT 2023
nridge added inline comments.
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:198
bool isSugaredTemplateParameter(QualType QT) {
static auto PeelWrappers = [](QualType QT) {
// Neither `PointerType` nor `ReferenceType` is considered as sugared
----------------
nit: since it's only doing one level of peeling, let's call it `PeelWrapper` (no `s`)
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:202
QualType Next;
- while (!(Next = QT->getPointeeType()).isNull())
+ if (!(Next = QT->getPointeeType()).isNull())
QT = Next;
----------------
Now that the function is not looping, we can simplify the body a bit:
```
QualType Peeled = QT->getPointeeType();
return Peeled.isNull() ? QT : Peeled;
```
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:207
+
+ // This is a bit tricky: we traverse the type structure and find whether or
+ // not a type in the desugaring process is of SubstTemplateTypeParmType.
----------------
Nice find, this is indeed pretty tricky. I remember running into a similar issue before in https://reviews.llvm.org/D124690#inline-1205484.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156300/new/
https://reviews.llvm.org/D156300
More information about the cfe-commits
mailing list