[PATCH] D84226: [AST][RecoveryExpr] Part1: Support dependent binary operator in C for error recovery.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 5 06:09:05 PDT 2020


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/include/clang/AST/ASTContext.h:668
 
+  // clang's C-only codepath doesn't support dependent types yet, it is used to
+  // perform early typo correction for C.
----------------
This is a bit hard to follow.
I think it's two separate sentences, and the second is something like
"If this condition is false, typo correction must be performed eagerly rather than delayed in many places, as it makes use of dependent types".


================
Comment at: clang/lib/Sema/SemaExpr.cpp:14365
+           "Should only occur in error-recovery path.");
+    if (BinaryOperator::isCompoundAssignmentOp(Opc))
+      return CompoundAssignOperator::Create(
----------------
isAssignmentOp instead? including = itself


================
Comment at: clang/lib/Sema/SemaExpr.cpp:14383
+                                    Context.IntTy, VK_RValue, OK_Ordinary,
+                                    OpLoc, CurFPFeatureOverrides());
+    default:
----------------
comma could get the RHS :-)
May get some mileage for comma operators in macros, not sure though.

(Other aspect is value category: fortunately *in C* comma is an rvalue)


================
Comment at: clang/test/AST/ast-dump-recovery.c:45
   int* ptr;
-  // FIXME: the top-level expr should be a binary operator.
-  // CHECK:      ImplicitCastExpr {{.*}} contains-errors <LValueToRValue>
-  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
-  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
-  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
-  // CHECK-NEXT:     `-DeclRefExpr {{.*}} 'some_func'
+  // CHECK:     BinaryOperator {{.*}} contains-errors '='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ptr' 'int *'
----------------
`'int *' lvalue contains-errors '='`


================
Comment at: clang/test/AST/ast-dump-recovery.c:52
+  int compoundOp;
+  // CHECK:     CompoundAssignOperator {{.*}} '+='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'compoundOp'
----------------
`'int' lvalue contains-errors '+='`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84226



More information about the cfe-commits mailing list