[cfe-commits] r164397 - /cfe/trunk/lib/Analysis/BodyFarm.cpp
Ted Kremenek
kremenek at apple.com
Fri Sep 21 11:13:27 PDT 2012
Author: kremenek
Date: Fri Sep 21 13:13:27 2012
New Revision: 164397
URL: http://llvm.org/viewvc/llvm-project?rev=164397&view=rev
Log:
Add helper method to BodyFarm for creating lvalue-to-rvalue conversions.
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=164397&r1=164396&r2=164397&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 21 13:13:27 2012
@@ -52,6 +52,9 @@
/// Create an implicit cast for an integer conversion.
ImplicitCastExpr *makeIntegralCast(const Expr *Arg, QualType Ty);
+ // Create an implicit cast for lvalue-to-rvaluate conversions.
+ ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg, QualType Ty);
+
private:
ASTContext &C;
};
@@ -70,6 +73,11 @@
return DR;
}
+ImplicitCastExpr *ASTMaker::makeLvalueToRvalue(const Expr *Arg, QualType Ty) {
+ return ImplicitCastExpr::Create(C, Ty, CK_LValueToRValue,
+ const_cast<Expr*>(Arg), 0, VK_RValue);
+}
+
ImplicitCastExpr *ASTMaker::makeIntegralCast(const Expr *Arg, QualType Ty) {
return ImplicitCastExpr::Create(C, Ty, CK_IntegralCast,
const_cast<Expr*>(Arg), 0, VK_RValue);
@@ -117,8 +125,7 @@
// (1) Create the call.
DeclRefExpr *DR = M.makeDeclRefExpr(Block);
- 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());
@@ -128,9 +135,7 @@
C.IntTy, SourceLocation());
ICE = M.makeIntegralCast(IL, PredicateTy);
DR = M.makeDeclRefExpr(Predicate);
- ImplicitCastExpr *LValToRval =
- ImplicitCastExpr::Create(C, PredicateQPtrTy, CK_LValueToRValue, DR,
- 0, VK_RValue);
+ ImplicitCastExpr *LValToRval = M.makeLvalueToRvalue(DR, PredicateQPtrTy);
UnaryOperator *UO = new (C) UnaryOperator(LValToRval, UO_Deref, PredicateTy,
VK_LValue, OK_Ordinary,
SourceLocation());
@@ -147,13 +152,11 @@
// (4) Create the 'if' condition.
DR = M.makeDeclRefExpr(Predicate);
- LValToRval = ImplicitCastExpr::Create(C, PredicateQPtrTy, CK_LValueToRValue,
- DR, 0, VK_RValue);
+ LValToRval = M.makeLvalueToRvalue(DR, PredicateQPtrTy);
UO = new (C) UnaryOperator(LValToRval, UO_Deref, PredicateTy,
VK_LValue, OK_Ordinary,
SourceLocation());
- LValToRval = ImplicitCastExpr::Create(C, PredicateTy, CK_LValueToRValue,
- UO, 0, VK_RValue);
+ LValToRval = M.makeLvalueToRvalue(UO, PredicateTy);
UO = new (C) UnaryOperator(LValToRval, UO_LNot, C.IntTy,
VK_RValue, OK_Ordinary, SourceLocation());
More information about the cfe-commits
mailing list