[cfe-commits] r164400 - /cfe/trunk/lib/Analysis/BodyFarm.cpp
Ted Kremenek
kremenek at apple.com
Fri Sep 21 11:33:54 PDT 2012
Author: kremenek
Date: Fri Sep 21 13:33:54 2012
New Revision: 164400
URL: http://llvm.org/viewvc/llvm-project?rev=164400&view=rev
Log:
Create helper method in BodyFarm for creating simple assignments.
Modified:
cfe/trunk/lib/Analysis/BodyFarm.cpp
Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=164400&r1=164399&r2=164400&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 21 13:33:54 2012
@@ -46,6 +46,9 @@
public:
ASTMaker(ASTContext &C) : C(C) {}
+ /// Create a new BinaryOperator representing a simple assignment.
+ BinaryOperator *makeAssignment(const Expr *LHS, const Expr *RHS, QualType Ty);
+
/// Create a new DeclRefExpr for the referenced variable.
DeclRefExpr *makeDeclRefExpr(const VarDecl *D);
@@ -63,6 +66,13 @@
};
}
+BinaryOperator *ASTMaker::makeAssignment(const Expr *LHS, const Expr *RHS,
+ QualType Ty) {
+ return new (C) BinaryOperator(const_cast<Expr*>(LHS), const_cast<Expr*>(RHS),
+ BO_Assign, Ty, VK_RValue,
+ OK_Ordinary, SourceLocation());
+}
+
DeclRefExpr *ASTMaker::makeDeclRefExpr(const VarDecl *D) {
DeclRefExpr *DR =
DeclRefExpr::Create(/* Ctx = */ C,
@@ -145,10 +155,8 @@
DR = M.makeDeclRefExpr(Predicate);
ImplicitCastExpr *LValToRval = M.makeLvalueToRvalue(DR, PredicateQPtrTy);
UnaryOperator *UO = M.makeDereference(LValToRval, PredicateTy);
- BinaryOperator *B = new (C) BinaryOperator(UO, ICE, BO_Assign,
- PredicateTy, VK_RValue,
- OK_Ordinary,
- SourceLocation());
+ BinaryOperator * B = M.makeAssignment(UO, ICE, PredicateTy);
+
// (3) Create the compound statement.
Stmt *Stmts[2];
Stmts[0] = B;
More information about the cfe-commits
mailing list