[PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Andi via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 18 04:07:54 PDT 2016
Abpostelnicu removed rL LLVM as the repository for this revision.
Abpostelnicu updated this revision to Diff 68507.
https://reviews.llvm.org/D22910
Files:
include/clang/AST/ExprCXX.h
lib/AST/Expr.cpp
Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2861,8 +2861,16 @@
// These never have a side-effect.
return false;
+ case CXXOperatorCallExprClass: {
+ // If it is an operator call expr it can have side effects when the
+ // underlaying operator is of assignment kind.
+ // Othrwise fall through the rest of cases.
+ OverloadedOperatorKind Op = cast<CXXOperatorCallExpr>(this)->getOperator();
+ if (CXXOperatorCallExpr::isAssignmentOp(Op)) {
+ return true;
+ }
+ }
case CallExprClass:
- case CXXOperatorCallExprClass:
case CXXMemberCallExprClass:
case CUDAKernelCallExprClass:
case UserDefinedLiteralClass: {
Index: include/clang/AST/ExprCXX.h
===================================================================
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -106,6 +106,16 @@
// operations on floating point types.
bool isFPContractable() const { return FPContractable; }
+ // Check to see if a given overloaded operator is of assignment kind
+ static bool isAssignmentOp(OverloadedOperatorKind Opc) {
+ return Opc == OO_Equal || Opc == OO_StarEqual ||
+ Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
+ Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
+ Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
+ Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
+ Opc == OO_PipeEqual;
+ }
+
friend class ASTStmtReader;
friend class ASTStmtWriter;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22910.68507.patch
Type: text/x-patch
Size: 1587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160818/d2b3da6d/attachment.bin>
More information about the cfe-commits
mailing list