Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu updated this revision to Diff 72026. 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 @@ -2863,8 +2863,20 @@ // These never have a side-effect. return false; + case CXXOperatorCallExprClass: { +// When looking for potential side-effects, we assume that an overloaded +// assignment operator is intended to have a side-effect and other overloaded +// operators are not. Otherwise fall through the logic of call expression. +OverloadedOperatorKind Op = cast(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +return true; +} +LLVM_FALLTHROUGH; + } 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; }; Index: lib/AST/Expr.cpp === --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -2863,8 +2863,20 @@ // These never have a side-effect. return false; + case CXXOperatorCallExprClass: { +// When looking for potential side-effects, we assume that an overloaded +// assignment operator is intended to have a side-effect and other overloaded +// operators are not. Otherwise fall through the logic of call expression. +OverloadedOperatorKind Op = cast(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +return true; +} +LLVM_FALLTHROUGH; + } 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; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu updated this revision to Diff 72790. Abpostelnicu marked 2 inline comments as done. Abpostelnicu added a comment. i will add the unit tests in the next patch. 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 @@ -2863,8 +2863,23 @@ // These never have a side-effect. return false; + case CXXOperatorCallExprClass: { +// When looking for potential side-effects, we assume that these +// operators: assignment, increement 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(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op) +|| CXXOperatorCallExpr::isIncrementOp(Op) +|| CXXOperatorCallExpr::isDecrementOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +return true; +} +LLVM_FALLTHROUGH; + } 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,26 @@ // 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; + } + + // Check to see if a given overloaded operator is of increment kind + static bool isIncrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_PlusPlus; + } + + // Check to see if a given overloaded operator is of decrement kind + static bool isDecrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_MinusMinus; + } + friend class ASTStmtReader; friend class ASTStmtWriter; }; Index: lib/AST/Expr.cpp === --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -2863,8 +2863,23 @@ // These never have a side-effect. return false; + case CXXOperatorCallExprClass: { +// When looking for potential side-effects, we assume that these +// operators: assignment, increement 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(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op) +|| CXXOperatorCallExpr::isIncrementOp(Op) +|| CXXOperatorCallExpr::isDecrementOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +return true; +} +LLVM_FALLTHROUGH; + } 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,26 @@ // 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; + } + + // Check to see if a given overloaded operator is of increment kind + static bool isIncrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_PlusPlus; + } + + // Check to see if a given overloaded operator is of decrement kind + static bool isDecrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_MinusMinus; + } + friend class ASTStmtReader; friend class ASTStmtWriter; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu updated this revision to Diff 72806. Abpostelnicu marked an inline comment as done. Abpostelnicu added a comment. corrected typo 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 @@ -2863,8 +2863,23 @@ // 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(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op) +|| CXXOperatorCallExpr::isIncrementOp(Op) +|| CXXOperatorCallExpr::isDecrementOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +return true; +} +LLVM_FALLTHROUGH; + } 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,26 @@ // 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; + } + + // Check to see if a given overloaded operator is of increment kind + static bool isIncrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_PlusPlus; + } + + // Check to see if a given overloaded operator is of decrement kind + static bool isDecrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_MinusMinus; + } + friend class ASTStmtReader; friend class ASTStmtWriter; }; Index: lib/AST/Expr.cpp === --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -2863,8 +2863,23 @@ // 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(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op) +|| CXXOperatorCallExpr::isIncrementOp(Op) +|| CXXOperatorCallExpr::isDecrementOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +return true; +} +LLVM_FALLTHROUGH; + } 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,26 @@ // 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; + } + + // Check to see if a given overloaded operator is of increment kind + static bool isIncrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_PlusPlus; + } + + // Check to see if a given overloaded operator is of decrement kind + static bool isDecrementOp(OverloadedOperatorKind Opc) { +return Opc == OO_MinusMinus; + } + friend class ASTStmtReader; friend class ASTStmtWriter; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
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(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op) +|| Op == OO_PlusPlus || Op == OO_Minus) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + 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(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op) +|| Op == OO_PlusPlus || Op == OO_Minus) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +return true; +} +LLVM_FALLTHROUGH; + } case CallExprClass: - case CXXOperatorCallExprClass: case CXXMemberCallExprClass: case CUDAKernelCallExprClass: case UserDefinedLiteralClass: { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu marked 2 inline comments as done. Comment at: lib/AST/Expr.cpp:2868 @@ +2867,3 @@ +OverloadedOperatorKind binOp = cast(this)->getOperator(); +if (binOp == OO_Equal || (binOp >= OO_PlusEqual && binOp <= OO_PipeEqual)) { + return true; rsmith wrote: > Please don't hard-code the order of OO enumerators like this (and this isn't > even correct: you missed `<<=` and `>>=`). > > Instead, consider extending `BinaryOperator::isAssignmentOp` / > `BinaryOperator::getOverloadedOpcode` so you can use them for this. i was thinking more on doing for this specific case since BinaryOperator::isAssignmentOp and BinaryOperator::getOverloadedOpcode only accepts binary op codes and CXXOperatorCallExpr incapsulates operators both binary and unary Repository: rL LLVM https://reviews.llvm.org/D22910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
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(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; }; 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(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; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu updated this revision to Diff 69205. 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,19 @@ // These never have a side-effect. return false; + case CXXOperatorCallExprClass: { +// When looking for potential side-effects, we assume that an overloaded +// assignment operator is intended to have a side-effect and other overloaded +// operators are not. +OverloadedOperatorKind Op = cast(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +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; }; Index: lib/AST/Expr.cpp === --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -2861,8 +2861,19 @@ // These never have a side-effect. return false; + case CXXOperatorCallExprClass: { +// When looking for potential side-effects, we assume that an overloaded +// assignment operator is intended to have a side-effect and other overloaded +// operators are not. +OverloadedOperatorKind Op = cast(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); + bool IsPure = FD && (FD->hasAttr() || FD->hasAttr()); + if (!IsPure) +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; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu marked 4 inline comments as done. Abpostelnicu added a comment. I've added also support for pure in case CXXOperatorCallExprClass::isAssignmentOperator is true. https://reviews.llvm.org/D22910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu added inline comments. Comment at: lib/AST/Expr.cpp:2869 @@ +2868,3 @@ +OverloadedOperatorKind Op = cast(this)->getOperator(); +if (CXXOperatorCallExpr::isAssignmentOp(Op)) { + const Decl *FD = cast(this)->getCalleeDecl(); aaron.ballman wrote: > Should this also handle overloaded ++ and -- if they're the prefix forms? > What about overloaded operator new and delete (and the array forms)? I think for now i should prefer only to have the implementation for assignment operator when it's overloaded. https://reviews.llvm.org/D22910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu added a comment. Can someone please show me an example on how to write a test for this patch? https://reviews.llvm.org/D22910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects
Abpostelnicu added a comment. In https://reviews.llvm.org/D22910#499082, @aaron.ballman wrote: > Thank you for the patch! > > One thing this patch is missing is a test case that exercises this code path. > For instance, there are diagnostics triggered for expressions with side > effects when used as part of an unevaluated expression like sizeof, noexcept, > etc. You should include a test case that demonstrates some behavioral change > in the compiler that this patch addresses. > > > The AST node that will get generated for the assignment is of type > > CXXOperatorCallExpr so calling HasSideEffects on that expression would have > > resulted in a false return since CXXOperatorCallExpr was not considered to > > have a possible side effect when it's underlying operator type is > > assignment. > > > I think the underlying issue here is that `HasSideEffects()` accepts an > argument as to whether possible side effects should count as definite side > effects, and for the unevaluated context diagnostics, we do not want to > include possible side effects, only definite ones. For instance, consider > this very common code pattern where the function definition is not available > to the TU: > > struct S { > S& operator=(int); > }; > > > There's no way to know whether side effects will or won't happen for an > assignment operator on an object of the above type because the definition > does not exist. Assuming that side effects *definitely* happen, as your patch > does, can then trigger false positives. So the second question is: how many > false-positives will it generate? I think it may be reasonable to assume that > `operator=()` has side effects, but you should run some large C++ projects > (like LLVM itself) through Clang to see how many new diagnostics this change > triggers and how many of those diagnostics are true positives vs false > positives. That will tell us for sure whether this is adding value or not. You are right, using this patch i've built the firefox codebase, witch is rather a very large product, and there is no issues triggered. I will also add some test cases. Repository: rL LLVM https://reviews.llvm.org/D22910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits