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

2020-10-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8852d30b1c1b: [AST][RecoveryExpr] Dont perform early 
typo correction in C. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89045/new/

https://reviews.llvm.org/D89045

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


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -24,14 +24,10 @@
 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() {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8494,7 +8494,7 @@
 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.


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -24,14 +24,10 @@
 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() {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8494,7 +8494,7 @@
 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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-10-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
hokein requested review of this revision.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89045

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


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -24,14 +24,10 @@
 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() {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8558,7 +8558,7 @@
 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.


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -24,14 +24,10 @@
 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() {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8558,7 +8558,7 @@
 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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits