diff options
author | Haojian Wu <hokein.wu@gmail.com> | 2020-05-08 16:13:17 +0200 |
---|---|---|
committer | Haojian Wu <hokein.wu@gmail.com> | 2020-05-11 08:46:18 +0200 |
commit | 8222107aa9249aada81334c922a2d284042242ed (patch) | |
tree | ed5af4f55b5a4d93024aa66b1a3915f4eb7a0d89 /clang/lib/AST/ComputeDependence.cpp | |
parent | 20629ca949cddde9f7e41a4b9e8539a970615feb (diff) | |
download | llvm-8222107aa9249aada81334c922a2d284042242ed.zip llvm-8222107aa9249aada81334c922a2d284042242ed.tar.gz llvm-8222107aa9249aada81334c922a2d284042242ed.tar.bz2 |
[AST] Preserve the type in RecoveryExprs for broken function calls.
RecoveryExprs are modeled as dependent type to prevent bogus diagnostics
and crashes in clang.
This patch allows to preseve the type for broken calls when the
RecoveryEprs have a known type, e.g. a broken non-overloaded call, a
overloaded call when the all candidates have the same return type, so
that more features (code completion still work on "take2args(x).^") still
work.
However, adding the type is risky, which may result in more clang code being
affected leading to new crashes and hurt diagnostic, and it requires large
effort to minimize the affect (update all sites in clang to handle errorDepend
case), so we add a new flag (off by default) to allow us to develop/test
them incrementally.
This patch also has some trivial fixes to suppress diagnostics (to prevent regressions).
Tested:
all existing tests are passed (when both "-frecovery-ast", "-frecovery-ast-type" flags are flipped on);
Reviewed By: sammccall
Subscribers: rsmith, arphaman, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D79160
Diffstat (limited to 'clang/lib/AST/ComputeDependence.cpp')
-rw-r--r-- | clang/lib/AST/ComputeDependence.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp index 0f0f79e..56c3b91 100644 --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -485,9 +485,13 @@ ExprDependence clang::computeDependence(DeclRefExpr *E, const ASTContext &Ctx) { } ExprDependence clang::computeDependence(RecoveryExpr *E) { + // Mark the expression as value- and instantiation- dependent to reuse + // existing suppressions for dependent code, e.g. avoiding + // constant-evaluation. // FIXME: drop type+value+instantiation once Error is sufficient to suppress // bogus dianostics. - auto D = ExprDependence::TypeValueInstantiation | ExprDependence::Error; + auto D = toExprDependence(E->getType()->getDependence()) | + ExprDependence::ValueInstantiation | ExprDependence::Error; for (auto *S : E->subExpressions()) D |= S->getDependence(); return D; |