[PATCH] D85033: [clang] Provide a better pretty-printed name for unnamed parameters, lambda classes and lambda captures.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 5 04:23:49 PDT 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a minor nit.



================
Comment at: clang/lib/AST/Decl.cpp:2130
+  // the pretty-printed name of the capture instead.
+  if (isa<FieldDecl>(DD) &&
+      maybePrintFieldForLambdaCapture(OS, Policy, cast<FieldDecl>(DD)))
----------------
Rather than `isa<>` followed by a `cast<>`, how about:
```
if (const auto *FD = dyn_cast<FieldDecl>(DD)) {
  if (maybePrintFieldForLambdaCapture(...)
    return;
}
```
Alternatively, you could sink the `dyn_cast<>` down into `maybePrintFieldForLambdaCapture()` since that already has to handle case where it's not printing a field capture.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85033



More information about the cfe-commits mailing list