SubExprs[LHS] = lhs;
SubExprs[RHS] = rhs;
}
+
+ BinaryOperator(StmtClass SC, EmptyShell Empty)
+ : Expr(SC, Empty), Opc(MulAssign) { }
};
/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
"Only should be used for compound assignments");
}
+ /// \brief Build an empty compound assignment operator expression.
+ explicit CompoundAssignOperator(EmptyShell Empty)
+ : BinaryOperator(CompoundAssignOperatorClass, Empty) { }
+
// The two computation types are the type the LHS is converted
// to for the computation and the type of the result; the two are
// distinct in a few cases (specifically, int+=ptr and ptr-=ptr).
QualType getComputationLHSType() const { return ComputationLHSType; }
+ void setComputationLHSType(QualType T) { ComputationLHSType = T; }
+
QualType getComputationResultType() const { return ComputationResultType; }
-
+ void setComputationResultType(QualType T) { ComputationResultType = T; }
+
static bool classof(const CompoundAssignOperator *) { return true; }
static bool classof(const Stmt *S) {
return S->getStmtClass() == CompoundAssignOperatorClass;
SubExprs[RHS] = rhs;
}
+ /// \brief Build an empty conditional operator.
+ explicit ConditionalOperator(EmptyShell Empty)
+ : Expr(ConditionalOperatorClass, Empty) { }
+
// getCond - Return the expression representing the condition for
// the ?: operator.
Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
+ void setCond(Expr *E) { SubExprs[COND] = E; }
// getTrueExpr - Return the subexpression representing the value of the ?:
// expression if the condition evaluates to true. In most cases this value
Expr *getFalseExpr() const { return cast<Expr>(SubExprs[RHS]); }
Expr *getLHS() const { return cast_or_null<Expr>(SubExprs[LHS]); }
+ void setLHS(Expr *E) { SubExprs[LHS] = E; }
+
Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
+ void setRHS(Expr *E) { SubExprs[RHS] = E; }
virtual SourceRange getSourceRange() const {
return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
EXPR_MEMBER,
/// \brief A BinaryOperator record.
EXPR_BINARY_OPERATOR,
+ /// \brief A CompoundAssignOperator record.
+ EXPR_COMPOUND_ASSIGN_OPERATOR,
+ /// \brief A ConditionOperator record.
+ EXPR_CONDITIONAL_OPERATOR,
/// \brief An ImplicitCastExpr record.
EXPR_IMPLICIT_CAST,
/// \brief A CStyleCastExpr record.
unsigned VisitMemberExpr(MemberExpr *E);
unsigned VisitCastExpr(CastExpr *E);
unsigned VisitBinaryOperator(BinaryOperator *E);
+ unsigned VisitCompoundAssignOperator(CompoundAssignOperator *E);
+ unsigned VisitConditionalOperator(ConditionalOperator *E);
unsigned VisitImplicitCastExpr(ImplicitCastExpr *E);
unsigned VisitExplicitCastExpr(ExplicitCastExpr *E);
unsigned VisitCStyleCastExpr(CStyleCastExpr *E);
return 2;
}
+unsigned PCHStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
+ VisitBinaryOperator(E);
+ E->setComputationLHSType(Reader.GetType(Record[Idx++]));
+ E->setComputationResultType(Reader.GetType(Record[Idx++]));
+ return 2;
+}
+
+unsigned PCHStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
+ VisitExpr(E);
+ E->setCond(ExprStack[ExprStack.size() - 3]);
+ E->setLHS(ExprStack[ExprStack.size() - 2]);
+ E->setRHS(ExprStack[ExprStack.size() - 1]);
+ return 3;
+}
+
unsigned PCHStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
VisitCastExpr(E);
E->setLvalueCast(Record[Idx++]);
E = new (Context) BinaryOperator(Empty);
break;
+ case pch::EXPR_COMPOUND_ASSIGN_OPERATOR:
+ E = new (Context) CompoundAssignOperator(Empty);
+ break;
+
+ case pch::EXPR_CONDITIONAL_OPERATOR:
+ E = new (Context) ConditionalOperator(Empty);
+ break;
+
case pch::EXPR_IMPLICIT_CAST:
E = new (Context) ImplicitCastExpr(Empty);
break;
void VisitMemberExpr(MemberExpr *E);
void VisitCastExpr(CastExpr *E);
void VisitBinaryOperator(BinaryOperator *E);
+ void VisitCompoundAssignOperator(CompoundAssignOperator *E);
+ void VisitConditionalOperator(ConditionalOperator *E);
void VisitImplicitCastExpr(ImplicitCastExpr *E);
void VisitExplicitCastExpr(ExplicitCastExpr *E);
void VisitCStyleCastExpr(CStyleCastExpr *E);
Code = pch::EXPR_BINARY_OPERATOR;
}
+void PCHStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
+ VisitBinaryOperator(E);
+ Writer.AddTypeRef(E->getComputationLHSType(), Record);
+ Writer.AddTypeRef(E->getComputationResultType(), Record);
+ Code = pch::EXPR_COMPOUND_ASSIGN_OPERATOR;
+}
+
+void PCHStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
+ VisitExpr(E);
+ Writer.WriteSubExpr(E->getCond());
+ Writer.WriteSubExpr(E->getLHS());
+ Writer.WriteSubExpr(E->getRHS());
+ Code = pch::EXPR_CONDITIONAL_OPERATOR;
+}
+
void PCHStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
VisitCastExpr(E);
Record.push_back(E->isLvalueCast());
// BinaryOperator
add_result *int_ptr5 = &integer;
+// CompoundAssignOperator
+addeq_result *int_ptr6 = &integer;
+
+// ConditionalOperator
+conditional_operator *double_ptr4 = &floating;
+
// CStyleCastExpr
void_ptr vp1 = &integer;
// BinaryOperator
typedef typeof(i + Enumerator) add_result;
+// CompoundAssignOperator
+typedef typeof(i += Enumerator) addeq_result;
+
+// ConditionalOperator
+typedef typeof(i? : d0) conditional_operator;
+
// CStyleCastExpr
typedef typeof((void *)0) void_ptr;