[cfe-commits] r41404 - in /cfe/trunk: AST/Expr.cpp Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Sat Aug 25 12:54:59 PDT 2007
Author: snaroff
Date: Sat Aug 25 14:54:59 2007
New Revision: 41404
URL: http://llvm.org/viewvc/llvm-project?rev=41404&view=rev
Log:
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))))))
Modified:
cfe/trunk/AST/Expr.cpp
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=41404&r1=41403&r2=41404&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Sat Aug 25 14:54:59 2007
@@ -302,8 +302,6 @@
if (cast<OCUVectorElementExpr>(this)->containsDuplicateElements())
return LV_DuplicateVectorComponents;
return LV_Valid;
- case ImplicitCastExprClass: // A side-effect of our implementation.
- return cast<ImplicitCastExpr>(this)->getSubExpr()->isLvalue();
default:
break;
}
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41404&r1=41403&r2=41404&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sat Aug 25 14:54:59 2007
@@ -765,9 +765,10 @@
/// responsible for emitting appropriate error diagnostics.
QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr,
bool isCompAssign) {
- UsualUnaryConversions(lhsExpr);
- UsualUnaryConversions(rhsExpr);
-
+ if (!isCompAssign) {
+ UsualUnaryConversions(lhsExpr);
+ UsualUnaryConversions(rhsExpr);
+ }
QualType lhs = lhsExpr->getType();
QualType rhs = rhsExpr->getType();
More information about the cfe-commits
mailing list