Abpostelnicu updated this revision to Diff 73766.
Abpostelnicu marked 3 inline comments as done.
https://reviews.llvm.org/D22910
Files:
lib/AST/Expr.cpp
Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,22 @@
// These never have a side-effect.
return false;
+ case CXXOperatorCallExprClass: {
+ // When looking for potential side-effects, we assume that these
+ // operators: assignment, increment and decrement are intended
+ // to have a side-effect and other overloaded operators are not.
+ // Otherwise fall through the logic of call expression.
+ OverloadedOperatorKind Op = cast<CXXOperatorCallExpr>(this)->getOperator();
+ if (CXXOperatorCallExpr::isAssignmentOp(Op)
+ || Op == OO_PlusPlus || Op == OO_Minus) {
+ const Decl *FD = cast<CallExpr>(this)->getCalleeDecl();
+ bool IsPure = FD && (FD->hasAttr<ConstAttr>() ||
FD->hasAttr<PureAttr>());
+ if (!IsPure)
+ return true;
+ }
+ LLVM_FALLTHROUGH;
+ }
case CallExprClass:
- case CXXOperatorCallExprClass:
case CXXMemberCallExprClass:
case CUDAKernelCallExprClass:
case UserDefinedLiteralClass: {
Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,22 @@
// These never have a side-effect.
return false;
+ case CXXOperatorCallExprClass: {
+ // When looking for potential side-effects, we assume that these
+ // operators: assignment, increment and decrement are intended
+ // to have a side-effect and other overloaded operators are not.
+ // Otherwise fall through the logic of call expression.
+ OverloadedOperatorKind Op = cast<CXXOperatorCallExpr>(this)->getOperator();
+ if (CXXOperatorCallExpr::isAssignmentOp(Op)
+ || Op == OO_PlusPlus || Op == OO_Minus) {
+ const Decl *FD = cast<CallExpr>(this)->getCalleeDecl();
+ bool IsPure = FD && (FD->hasAttr<ConstAttr>() || FD->hasAttr<PureAttr>());
+ if (!IsPure)
+ return true;
+ }
+ LLVM_FALLTHROUGH;
+ }
case CallExprClass:
- case CXXOperatorCallExprClass:
case CXXMemberCallExprClass:
case CUDAKernelCallExprClass:
case UserDefinedLiteralClass: {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits