[all-commits] [llvm/llvm-project] 13a86c: [Sema] Preserve invalid CXXCtorInitializers using ...

Sam McCall via All-commits all-commits at lists.llvm.org
Tue Aug 10 06:22:01 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 13a86c2bb465edf315ecbccccac622d73d39abe7
      https://github.com/llvm/llvm-project/commit/13a86c2bb465edf315ecbccccac622d73d39abe7
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2021-08-10 (Tue, 10 Aug 2021)

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

  Log Message:
  -----------
  [Sema] Preserve invalid CXXCtorInitializers using RecoveryExpr in initializer

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)

Differential Revision: https://reviews.llvm.org/D101641




More information about the All-commits mailing list