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

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 10:09:26 PDT 2019


ilya-biryukov added a comment.

Do we care about pointers or references to lambda types?



================
Comment at: clang-tools-extra/clangd/XRefs.cpp:662
+      if (const DecltypeType *DT =
+              llvm::dyn_cast<DecltypeType>(VD->getType().getTypePtr()))
+        if (!DT->getUnderlyingType().isNull())
----------------
Variable types can be null (for C++17 deconstruction syntax), use `getTypePtrOrNull`.


================
Comment at: clang-tools-extra/clangd/XRefs.cpp:664
+        if (!DT->getUnderlyingType().isNull())
+          if (const auto *CD = DT->getUnderlyingType()->getAsCXXRecordDecl())
+            return CD->getLambdaCallOperator();
----------------
NIT: add extra braces to the inner `if` for more readable code


================
Comment at: clang-tools-extra/clangd/XRefs.cpp:669
+      if (const Expr *E = VD->getInit())
+        if (const LambdaExpr *LE = llvm::dyn_cast<LambdaExpr>(E))
+          return LE->getCallOperator();
----------------
NIT: add extra braces to the inner `if` for more readable code


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