mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 05:46:06 +00:00

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
26 lines
1.3 KiB
C++
26 lines
1.3 KiB
C++
int foo(int, int);
|
|
int foo(int, double);
|
|
int x;
|
|
|
|
void testTypedRecoveryExpr1() {
|
|
// Inner bar() is an unresolved overloaded call, outer foo() is an overloaded call.
|
|
foo(x, bar(x));
|
|
}
|
|
// RUN: c-index-test -cursor-at=%s:7:3 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=OUTER-FOO %s
|
|
// OUTER-FOO: OverloadedDeclRef=foo[2:5, 1:5]
|
|
// RUN: c-index-test -cursor-at=%s:7:7 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=OUTER-X %s
|
|
// OUTER-X: DeclRefExpr=x:3:5
|
|
// RUN: c-index-test -cursor-at=%s:7:10 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=INNER-FOO %s
|
|
// INNER-FOO: OverloadedDeclRef=bar
|
|
// RUN: c-index-test -cursor-at=%s:7:14 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=INNER-X %s
|
|
// INNER-X: DeclRefExpr=x:3:5
|
|
|
|
void testTypedRecoveryExpr2() {
|
|
// Inner foo() is a RecoveryExpr (with int type), outer foo() is a valid "foo(int, int)" call.
|
|
foo(x, foo(x));
|
|
}
|
|
// RUN: c-index-test -cursor-at=%s:20:3 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=TEST2-OUTER %s
|
|
// TEST2-OUTER: DeclRefExpr=foo:1:5
|
|
// RUN: c-index-test -cursor-at=%s:20:10 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=TEST2-INNER %s
|
|
// TEST2-INNER: OverloadedDeclRef=foo[2:5, 1:5]
|