[PATCH] D17239: Sema: typo correct both sides of binary expression

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 23 17:09:28 PST 2016


rtrieu added a comment.

While this change does add the intended error messages, it won't produce a correct a typo-corrected AST.  For instance:

  void run(int sss) {
   sss = ssss ? ssss : ssss;
  }

Will produce an empty function body:

  `-FunctionDecl 0x7082ef0 <typo2.cc:1:1, line:3:1> line:1:6 run 'void (int)'
    |-ParmVarDecl 0x7082e30 <col:10, col:14> col:14 used sss 'int'
    `-CompoundStmt 0x70830f8 <col:19, line:3:1>

While the old code would make an AST for the body:

  `-FunctionDecl 0x59c0790 <typo2.cc:1:1, line:3:1> line:1:6 run 'void (int)'
    |-ParmVarDecl 0x59c06d0 <col:10, col:14> col:14 used sss 'int'
    `-CompoundStmt 0x59c0a90 <col:19, line:3:1>
      `-BinaryOperator 0x59c0a68 <line:2:2, col:22> 'int' lvalue '='
        |-DeclRefExpr 0x59c0880 <col:2> 'int' lvalue ParmVar 0x59c06d0 'sss' 'int'
        `-ImplicitCastExpr 0x59c0a50 <col:8, col:22> 'int' <LValueToRValue>
          `-ConditionalOperator 0x59c0a20 <col:8, col:22> 'int' lvalue
            |-ImplicitCastExpr 0x59c0a08 <col:8> '_Bool' <IntegralToBoolean>
            | `-ImplicitCastExpr 0x59c09f0 <col:8> 'int' <LValueToRValue>
            |   `-DeclRefExpr 0x59c0978 <col:8> 'int' lvalue ParmVar 0x59c06d0 'sss' 'int'
            |-DeclRefExpr 0x59c09a0 <col:15> 'int' lvalue ParmVar 0x59c06d0 'sss' 'int'
            `-DeclRefExpr 0x59c09c8 <col:22> 'int' lvalue ParmVar 0x59c06d0 'sss' 'int'


http://reviews.llvm.org/D17239





More information about the cfe-commits mailing list