diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-09-21 18:13:27 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-09-21 18:13:27 +0000 |
commit | 9ba05cd2e24e600ab59b2ed893ae598abbbc9a36 (patch) | |
tree | 55860d2a80cd48e483efbe527cbc8dffc3f0ff20 /lib/Analysis | |
parent | a6d62a10a6e1b8aa3c8294d8cac842c3720df7ff (diff) |
Add helper method to BodyFarm for creating lvalue-to-rvalue conversions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164397 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/BodyFarm.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Analysis/BodyFarm.cpp b/lib/Analysis/BodyFarm.cpp index f7fbcc933d..be8bf52d02 100644 --- a/lib/Analysis/BodyFarm.cpp +++ b/lib/Analysis/BodyFarm.cpp @@ -52,6 +52,9 @@ public: /// 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 @@ DeclRefExpr *ASTMaker::makeDeclRefExpr(const VarDecl *D) { 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 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) { // (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 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) { 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 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) { // (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()); |