[clang] 8852d30 - [AST][RecoveryExpr] Don't perform early typo correction in C.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 12 02:28:07 PDT 2020


Author: Haojian Wu
Date: 2020-10-12T11:24:45+02:00
New Revision: 8852d30b1c1b3b65cec0147cdf442051aa35e31b

URL: https://github.com/llvm/llvm-project/commit/8852d30b1c1b3b65cec0147cdf442051aa35e31b
DIFF: https://github.com/llvm/llvm-project/commit/8852d30b1c1b3b65cec0147cdf442051aa35e31b.diff

LOG: [AST][RecoveryExpr] Don't perform early typo correction in C.

The dependent mechanism for C error-recovery is mostly finished,
this is the only place we have missed.

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

Added: 
    

Modified: 
    clang/lib/Sema/SemaExpr.cpp
    clang/test/AST/ast-dump-recovery.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b5a366bc7175..f0cb227ff58e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8494,7 +8494,7 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
                                     SourceLocation ColonLoc,
                                     Expr *CondExpr, Expr *LHSExpr,
                                     Expr *RHSExpr) {
-  if (!getLangOpts().CPlusPlus) {
+  if (!Context.isDependenceAllowed()) {
     // C cannot handle TypoExpr nodes in the condition because it
     // doesn't handle dependent types properly, so make sure any TypoExprs have
     // been dealt with before checking the operands.

diff  --git a/clang/test/AST/ast-dump-recovery.c b/clang/test/AST/ast-dump-recovery.c
index 4cb0c5be21e0..f7b3c7bb4f2f 100644
--- a/clang/test/AST/ast-dump-recovery.c
+++ b/clang/test/AST/ast-dump-recovery.c
@@ -24,14 +24,10 @@ int postfix_inc = a++;
 int unary_address = &(a + 1);
 
 // CHECK:       VarDecl {{.*}} ternary 'int' cinit
-// CHECK-NEXT:  `-RecoveryExpr {{.*}}
+// CHECK-NEXT:  `-ConditionalOperator {{.*}}
 // CHECK-NEXT:    |-DeclRefExpr {{.*}} 'a'
-// CHECK-NEXT:    |-TypoExpr {{.*}}
+// CHECK-NEXT:    |-RecoveryExpr {{.*}}
 // CHECK-NEXT:    `-DeclRefExpr {{.*}} 'a'
-// FIXME: The TypoExpr should never be print, and should be downgraded to
-// RecoveryExpr -- typo correction is performed too early in C-only codepath,
-// which makes no correction when clang finishes the full expr (Sema::Sema::ActOnFinishFullExpr).
-// this will be fixed when we support dependent mechanism and delayed typo correction for C.
 int ternary = a ? undef : a;
 
 void test1() {


        


More information about the cfe-commits mailing list