]> granicus.if.org Git - clang/commitdiff
Add helper method to BodyFarm for creatinging integral casts.
authorTed Kremenek <kremenek@apple.com>
Fri, 21 Sep 2012 18:13:23 +0000 (18:13 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 21 Sep 2012 18:13:23 +0000 (18:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164396 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BodyFarm.cpp

index fc874e0c8b14d0dd4d7f8806b28129ca307aa873..f7fbcc933dcbbffd18b5e68dba5c10232adae1c8 100644 (file)
@@ -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,