[all-commits] [llvm/llvm-project] efa9aa: [clang] Suppress "follow-up" diagnostics on recove...

Haojian Wu via All-commits all-commits at lists.llvm.org
Mon Oct 26 04:45:52 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: efa9aaad703e6b150980ed1a74b4e7c9da7d85a2
      https://github.com/llvm/llvm-project/commit/efa9aaad703e6b150980ed1a74b4e7c9da7d85a2
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2020-10-26 (Mon, 26 Oct 2020)

  Changed paths:
    M clang/lib/Sema/SemaOverload.cpp
    M clang/test/AST/ast-dump-recovery.cpp
    M clang/test/SemaCXX/typo-correction-delayed.cpp

  Log Message:
  -----------
  [clang] Suppress "follow-up" diagnostics on recovery call expressions.

Because of typo-correction, the AST can be transformed, and the transformed
AST is marginally useful for diagnostics purpose, the following
diagnostics usually do harm than good (easily cause confusions).

Given the following code:

```
void abcc();
void test() {
  if (abc());
  // diagnostic 1 (for the typo-correction): the typo is correct to `abcc()`, so the code is treate as `if (abcc())` in AST perspective;
  // diagnostic 2 (for mismatch type): we perform an type-analysis on `if`, discover the type is not match
}
```

The secondary diagnostic "convertable to bool" is likely bogus to users.

The idea is to use RecoveryExpr (clang's dependent mechanism) to preserve the
recovery behavior but suppress all follow-up diagnostics.

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




More information about the All-commits mailing list