[PATCH] D62814: [clangd] Treat lambdas as functions when preparing hover response

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 4 03:35:56 PDT 2019


ilya-biryukov added inline comments.


================
Comment at: clang-tools-extra/clangd/XRefs.cpp:628
+    auto QT = VD->getType();
+    while (!QT->getPointeeType().isNull())
+      QT = QT->getPointeeType();
----------------
We need a check for `!QT.isNull` here


================
Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:831
+         };
          return HI;
        }},
----------------
kadircet wrote:
> ilya-biryukov wrote:
> > Could you add another test with even weirder types where we fail to show the signature? To make sure we don't break when reaching the limitations of the chosen approach and document what those limitations are.
> > 
> > Something like:
> > ```
> > auto a = [](int a) { return 10; };
> > auto *b = &a;
> > auto *c = &b;
> > ```
> > 
> > We would fail to show the signature here, but it's totally ok to ignore it.
> added cases, and changed code(a lot simpler now) to generate signatures for those cases as well.
Here's an example when the new approach falls short too:

```
auto a = [](int) { return 10; }
std::function<void(decltype(a) x)> b;
```

In general, are we ok with loosing all the information about the type that we drop?
One level of references and pointers seemed ok, dropping more is a bit more cheesy..

At the same time, either case is **so** rare that we probably don't care.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62814





More information about the cfe-commits mailing list