[cfe-commits] r164399 - /cfe/trunk/lib/Analysis/BodyFarm.cpp
Ted Kremenek
kremenek at apple.com
Fri Sep 21 11:33:52 PDT 2012
Author: kremenek
Date: Fri Sep 21 13:33:52 2012
New Revision: 164399
URL: http://llvm.org/viewvc/llvm-project?rev=164399&view=rev
Log:
Add helper method in BodyFarm to create unary dereferences.
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=164399&r1=164398&r2=164399&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 21 13:33:52 2012
@@ -49,6 +49,9 @@
/// Create a new DeclRefExpr for the referenced variable.
DeclRefExpr *makeDeclRefExpr(const VarDecl *D);
+ /// Create a new UnaryOperator representing a dereference.
+ UnaryOperator *makeDereference(const Expr *Arg, QualType Ty);
+
/// Create an implicit cast for an integer conversion.
ImplicitCastExpr *makeIntegralCast(const Expr *Arg, QualType Ty);
@@ -73,6 +76,11 @@
return DR;
}
+UnaryOperator *ASTMaker::makeDereference(const Expr *Arg, QualType Ty) {
+ return new (C) UnaryOperator(const_cast<Expr*>(Arg), UO_Deref, Ty,
+ VK_LValue, OK_Ordinary, SourceLocation());
+}
+
ImplicitCastExpr *ASTMaker::makeLvalueToRvalue(const Expr *Arg, QualType Ty) {
return ImplicitCastExpr::Create(C, Ty, CK_LValueToRValue,
const_cast<Expr*>(Arg), 0, VK_RValue);
@@ -136,9 +144,7 @@
ICE = M.makeIntegralCast(IL, PredicateTy);
DR = M.makeDeclRefExpr(Predicate);
ImplicitCastExpr *LValToRval = M.makeLvalueToRvalue(DR, PredicateQPtrTy);
- UnaryOperator *UO = new (C) UnaryOperator(LValToRval, UO_Deref, PredicateTy,
- VK_LValue, OK_Ordinary,
- SourceLocation());
+ UnaryOperator *UO = M.makeDereference(LValToRval, PredicateTy);
BinaryOperator *B = new (C) BinaryOperator(UO, ICE, BO_Assign,
PredicateTy, VK_RValue,
OK_Ordinary,
@@ -153,9 +159,7 @@
// (4) Create the 'if' condition.
DR = M.makeDeclRefExpr(Predicate);
LValToRval = M.makeLvalueToRvalue(DR, PredicateQPtrTy);
- UO = new (C) UnaryOperator(LValToRval, UO_Deref, PredicateTy,
- VK_LValue, OK_Ordinary,
- SourceLocation());
+ UO = M.makeDereference(LValToRval, PredicateTy);
LValToRval = M.makeLvalueToRvalue(UO, PredicateTy);
UO = new (C) UnaryOperator(LValToRval, UO_LNot, C.IntTy,
VK_RValue, OK_Ordinary, SourceLocation());
@@ -186,8 +190,7 @@
//
ASTMaker M(C);
DeclRefExpr *DR = M.makeDeclRefExpr(PV);
- ImplicitCastExpr *ICE = ImplicitCastExpr::Create(C, Ty, CK_LValueToRValue,
- DR, 0, VK_RValue);
+ ImplicitCastExpr *ICE = M.makeLvalueToRvalue(DR, Ty);
CallExpr *CE = new (C) CallExpr(C, ICE, ArrayRef<Expr*>(), C.VoidTy,
VK_RValue, SourceLocation());
return CE;
More information about the cfe-commits
mailing list