[all-commits] [llvm/llvm-project] a2132d: [Clang] Fix the do while statement disappearing in...

yronglin via All-commits all-commits at lists.llvm.org
Tue Aug 8 04:35:10 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a2132d72bed153a3347763dfaa7e699de7128647
      https://github.com/llvm/llvm-project/commit/a2132d72bed153a3347763dfaa7e699de7128647
  Author: yrong <yronglin777 at gmail.com>
  Date:   2023-08-08 (Tue, 08 Aug 2023)

  Changed paths:
    M clang/lib/Parse/ParseStmt.cpp
    M clang/test/AST/ast-dump-recovery.cpp
    M clang/test/SemaCXX/constexpr-function-recovery-crash.cpp

  Log Message:
  -----------
  [Clang] Fix the do while statement disappearing in AST when an error occurs in the conditional expression of the do while statement

```
constexpr int test() {
    do {} while (a + 1 < 10);
    return 0;
}
```
Before:
```
`-FunctionDecl 0x56512a172650 <./recovery.cpp:1:1, line:4:1> line:1:15 constexpr test 'int ()' implicit-inline
  `-CompoundStmt 0x56512a172860 <col:22, line:4:1>
    `-ReturnStmt 0x56512a172850 <line:3:5, col:12>
      `-IntegerLiteral 0x56512a172830 <col:12> 'int' 0
```
Now:
```
`-FunctionDecl 0x5642c4804650 <./recovery.cpp:1:1, line:4:1> line:1:15 constexpr test 'int ()' implicit-inline
  `-CompoundStmt 0x5642c48048e0 <col:22, line:4:1>
    |-DoStmt 0x5642c4804890 <line:2:5, col:28>
    | |-CompoundStmt 0x5642c4804740 <col:8, col:9>
    | `-BinaryOperator 0x5642c4804870 <col:18, col:26> '<dependent type>' contains-errors '<'
    |   |-BinaryOperator 0x5642c4804850 <col:18, col:22> '<dependent type>' contains-errors '+'
    |   | |-RecoveryExpr 0x5642c4804830 <col:18> '<dependent type>' contains-errors lvalue
    |   | `-IntegerLiteral 0x5642c48047b0 <col:22> 'int' 1
    |   `-IntegerLiteral 0x5642c48047f0 <col:26> 'int' 10
    `-ReturnStmt 0x5642c48048d0 <line:3:5, col:12>
      `-IntegerLiteral 0x5642c48048b0 <col:12> 'int' 0
```

Reviewed By: hokein

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




More information about the All-commits mailing list