[cfe-commits] r164396 - /cfe/trunk/lib/Analysis/BodyFarm.cpp

Ted Kremenek kremenek at apple.com
Fri Sep 21 11:13:23 PDT 2012


Author: kremenek
Date: Fri Sep 21 13:13:23 2012
New Revision: 164396

URL: http://llvm.org/viewvc/llvm-project?rev=164396&view=rev
Log:
Add helper method to BodyFarm for creatinging integral casts.

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=164396&r1=164395&r2=164396&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 21 13:13:23 2012
@@ -46,8 +46,12 @@
 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 @@
   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 @@
   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,





More information about the cfe-commits mailing list