summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-09-21 18:13:23 +0000
committerTed Kremenek <kremenek@apple.com>2012-09-21 18:13:23 +0000
commit69bcb82c59f61a867af3c0de73aa5779d2a6dd7d (patch)
tree629983b81a245fb3b86f168bbb37e69fa0a79745 /clang/lib
parentf787f171a3139c1f08e590a7e481b204aa118178 (diff)
downloadbcm5719-llvm-69bcb82c59f61a867af3c0de73aa5779d2a6dd7d.tar.gz
bcm5719-llvm-69bcb82c59f61a867af3c0de73aa5779d2a6dd7d.zip
Add helper method to BodyFarm for creatinging integral casts.
llvm-svn: 164396
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/BodyFarm.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index fc874e0c8b1..f7fbcc933dc 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -46,8 +46,12 @@ class ASTMaker {
public:
ASTMaker(ASTContext &C) : C(C) {}
+ /// Create a new DeclRefExpr for the referenced variable.
DeclRefExpr *makeDeclRefExpr(const VarDecl *D);
+ /// Create an implicit cast for an integer conversion.
+ ImplicitCastExpr *makeIntegralCast(const Expr *Arg, QualType Ty);
+
private:
ASTContext &C;
};
@@ -66,6 +70,11 @@ DeclRefExpr *ASTMaker::makeDeclRefExpr(const VarDecl *D) {
return DR;
}
+ImplicitCastExpr *ASTMaker::makeIntegralCast(const Expr *Arg, QualType Ty) {
+ return ImplicitCastExpr::Create(C, Ty, CK_IntegralCast,
+ const_cast<Expr*>(Arg), 0, VK_RValue);
+}
+
//===----------------------------------------------------------------------===//
// Creation functions for faux ASTs.
//===----------------------------------------------------------------------===//
@@ -117,8 +126,7 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
IntegerLiteral *IL =
IntegerLiteral::Create(C, llvm::APInt(C.getTypeSize(C.IntTy), (uint64_t) 1),
C.IntTy, SourceLocation());
- ICE = ImplicitCastExpr::Create(C, PredicateTy, CK_IntegralCast, IL, 0,
- VK_RValue);
+ ICE = M.makeIntegralCast(IL, PredicateTy);
DR = M.makeDeclRefExpr(Predicate);
ImplicitCastExpr *LValToRval =
ImplicitCastExpr::Create(C, PredicateQPtrTy, CK_LValueToRValue, DR,
OpenPOWER on IntegriCloud