[all-commits] [llvm/llvm-project] e417f0: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXX...

Congcong Cai via All-commits all-commits at lists.llvm.org
Tue Mar 14 10:09:58 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e417f02b5159c13f011335636faaf8c6847b627f
      https://github.com/llvm/llvm-project/commit/e417f02b5159c13f011335636faaf8c6847b627f
  Author: Congcong Cai <congcongcai0907 at 163.com>
  Date:   2023-03-15 (Wed, 15 Mar 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaTemplateVariadic.cpp
    A clang/test/SemaCXX/fold_expr_typo.cpp

  Log Message:
  -----------
  [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

PR #61326

- fix clang crash when fold expression contains a delayed typos correction.

code snippet in `ActOnCXXFoldExpr`
```  if (!LHS || !RHS) {
    Expr *Pack = LHS ? LHS : RHS;
    assert(Pack && "fold expression with neither LHS nor RHS");
    DiscardOperands();
    if (!Pack->containsUnexpandedParameterPack())
      return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
             << Pack->getSourceRange();
  }
```
`DiscardOperands` will be triggered when LHS/RHS is delayed typo correction expression.
It will output and clean all diagnose but still return a valid expression. (in else branch)
valid expression will be handled in caller function. When caller wants to output the diagnose, the diagnose in delayed typo correction expression has been consumed in `ActOnCXXFoldExpr`. It causes clang crash.

Reviewed By: erichkeane

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




More information about the All-commits mailing list