[cfe-commits] r39684 - /cfe/cfe/trunk/AST/Expr.cpp
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:47:08 PDT 2007
Author: clattner
Date: Wed Jul 11 11:47:07 2007
New Revision: 39684
URL: http://llvm.org/viewvc/llvm-project?rev=39684&view=rev
Log:
implement the rest of Expr::hasLocalSideEffect
Modified:
cfe/cfe/trunk/AST/Expr.cpp
Modified: cfe/cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Expr.cpp?rev=39684&r1=39683&r2=39684&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Expr.cpp (original)
+++ cfe/cfe/trunk/AST/Expr.cpp Wed Jul 11 11:47:07 2007
@@ -146,9 +146,14 @@
case UnaryOperator::PreDec:
return true; // ++/--
- // FIXME: real/imag volatile
- // deref volatile;
-
+ case UnaryOperator::Deref:
+ // Dereferencing a volatile pointer is a side-effect.
+ return getType().isVolatileQualified();
+ case UnaryOperator::Real:
+ case UnaryOperator::Imag:
+ // accessing a piece of a volatile complex is a side-effect.
+ return UO->getSubExpr()->getType().isVolatileQualified();
+
case UnaryOperator::Extension:
return UO->getSubExpr()->hasLocalSideEffect();
}
@@ -156,17 +161,16 @@
case BinaryOperatorClass:
return cast<BinaryOperator>(this)->isAssignmentOp();
+ case MemberExprClass:
case ArraySubscriptExprClass:
- // volatile
- return false;
+ // If the base pointer or element is to a volatile pointer/field, accessing
+ // if is a side effect.
+ return getType().isVolatileQualified();
case CallExprClass:
- // TODO: check attributes for pure/const.
+ // TODO: check attributes for pure/const. "void foo() { strlen("bar"); }"
+ // should warn.
return true;
-
- case MemberExprClass:
- // volatile load.
- return false;
case CastExprClass:
// If this is a cast to void, check the operand. Otherwise, the result of
More information about the cfe-commits
mailing list