[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

Hamza Sood via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 08:55:20 PDT 2017


hamzasood updated this revision to Diff 113271.
hamzasood added a comment.
Herald added a subscriber: klimek.

Implemented pretty printing and recursive AST visiting (both with appropriate unit tests).

The pretty printing implementation includes fixing a few printing bugs (which I needed fixed to write decent tests);

- Unnamed template parameters now print without a trailing space (e.g. <class> instead of <class >).
- C++14 generic lambda parameters are now printed as `auto` as opposed to `typeparameter-depth-index`.

RecursiveASTVisitor now visits each explicit template parameter, and also the implicit ones if shouldVisitImplicitCode is set.
However there is a problem with this implementation that I'm not sure about.
Consider a TU that is simply: `auto l = []<typename T>() { };`
If shouldVisitImplicitCode is set, the template parameter will be visited twice, Once when visiting the lambda (which is what I added) and once when visiting the implicit lambda class type (existing behaviour). Is that a problem?

With regards to serialisation, I don't think any changes are needed. However I've added a PCH test to be sure (which passes).


https://reviews.llvm.org/D36527

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/DeclPrinter.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  test/PCH/cxx11-lambdas.mm
  test/PCH/cxx1y-lambdas.mm
  test/PCH/cxx2a-template-lambdas.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  unittests/AST/StmtPrinterTest.cpp
  unittests/Tooling/RecursiveASTVisitorTest.cpp
  unittests/Tooling/TestVisitor.h
  www/cxx_status.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36527.113271.patch
Type: text/x-patch
Size: 36792 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170830/e9c8dd5b/attachment-0001.bin>


More information about the cfe-commits mailing list