[PATCH] D101641: [Sema] Preserve invalid CXXCtorInitializers using RecoveryExpr in initializer

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 30 08:22:12 PDT 2021


sammccall created this revision.
sammccall added a reviewer: hokein.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before this patch, CXXCtorInitializers that don't typecheck get discarded in
most cases. In particular:

- typos that can't be corrected don't turn into RecoveryExpr. The full expr disappears instead, and without an init expr we discard the node.
- initializers that fail initialization (e.g. constructor overload resolution) are discarded too.

This patch addresses both these issues (a bit clunkily and repetitively, for
member/base/delegating initializers)

It does not preserve any AST nodes when the member/base can't be resolved or
other problems of that nature. That breaks invariants of CXXCtorInitializer
itself, and we don't have a "weak" RecoveryCtorInitializer like we do for Expr.

I believe the changes to diagnostics in existing tests are improvements.
(We're able to do some analysis on the non-broken parts of the initializer)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101641

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101641.341920.patch
Type: text/x-patch
Size: 12328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210430/2a2ed790/attachment.bin>


More information about the cfe-commits mailing list