]> granicus.if.org Git - clang/commit
Surpress the UsualUnaryConversions for compound assignment operators. This change
authorSteve Naroff <snaroff@apple.com>
Sat, 25 Aug 2007 19:54:59 +0000 (19:54 +0000)
committerSteve Naroff <snaroff@apple.com>
Sat, 25 Aug 2007 19:54:59 +0000 (19:54 +0000)
commit8702a0f0cd72aca08a7dc1a7d3af8a1906186a35
treeb54f9c8f31e04597fadf04236e02ff7f88957a4c
parentbae35118fc5cea2da08567dbb9763af7f906dae2
Surpress the UsualUnaryConversions for compound assignment operators. This change
eliminates the possibility that the left hand expression is an ImplicitCastExpr.
As a result, I removed the check for ImplicitCastExpr in Expr::isLvalue().

This results in the following AST's...

[dylan:~/llvm/tools/clang] admin% cat fix.c

short x; void test4(char c) {
  x += c;
  x = x + c;
}
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang fix.c -parse-ast-dump
Read top-level variable decl: 'x'

void test4(char c)
(CompoundStmt 0x2605d30
  (CompoundAssignOperator 0x2605c40 'short' '+='
    (DeclRefExpr 0x2605c00 'short' Decl='x' 0x2605a80)
    (DeclRefExpr 0x2605c20 'char' Decl='c' 0x2605bc0))
  (BinaryOperator 0x2605d10 'short' '='
    (DeclRefExpr 0x2605c60 'short' Decl='x' 0x2605a80)
    (ImplicitCastExpr 0x2605d00 'short'
      (BinaryOperator 0x2605ce0 'int' '+'
        (ImplicitCastExpr 0x2605cc0 'int'
          (DeclRefExpr 0x2605c80 'short' Decl='x' 0x2605a80))
        (ImplicitCastExpr 0x2605cd0 'int'
          (DeclRefExpr 0x2605ca0 'char' Decl='c' 0x2605bc0))))))

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41404 91177308-0d34-0410-b5e6-96231b3b80d8
AST/Expr.cpp
Sema/SemaExpr.cpp