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

Ted Kremenek kremenek at apple.com
Fri Sep 21 11:33:57 PDT 2012


Author: kremenek
Date: Fri Sep 21 13:33:56 2012
New Revision: 164401

URL: http://llvm.org/viewvc/llvm-project?rev=164401&view=rev
Log:
Experiment in BodyFarm of structuring AST creation calls in a hierarchy,
so that they visually look like an AST dump.

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=164401&r1=164400&r2=164401&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 21 13:33:56 2012
@@ -151,12 +151,15 @@
   IntegerLiteral *IL =
     IntegerLiteral::Create(C, llvm::APInt(C.getTypeSize(C.IntTy), (uint64_t) 1),
                            C.IntTy, SourceLocation());
-  ICE = M.makeIntegralCast(IL, PredicateTy);
-  DR = M.makeDeclRefExpr(Predicate);
-  ImplicitCastExpr *LValToRval = M.makeLvalueToRvalue(DR, PredicateQPtrTy);
-  UnaryOperator *UO = M.makeDereference(LValToRval, PredicateTy);
-  BinaryOperator * B = M.makeAssignment(UO, ICE, PredicateTy);
-
+  BinaryOperator *B =
+    M.makeAssignment(
+       M.makeDereference(
+          M.makeLvalueToRvalue(
+            M.makeDeclRefExpr(Predicate), PredicateQPtrTy),
+            PredicateTy),
+       M.makeIntegralCast(IL, PredicateTy),
+       PredicateTy);
+  
   // (3) Create the compound statement.
   Stmt *Stmts[2];
   Stmts[0] = B;
@@ -165,12 +168,18 @@
                                           SourceLocation());
   
   // (4) Create the 'if' condition.
-  DR = M.makeDeclRefExpr(Predicate);
-  LValToRval = M.makeLvalueToRvalue(DR, PredicateQPtrTy);
-  UO = M.makeDereference(LValToRval, PredicateTy);
-  LValToRval = M.makeLvalueToRvalue(UO, PredicateTy);
-  UO = new (C) UnaryOperator(LValToRval, UO_LNot, C.IntTy,
-                             VK_RValue, OK_Ordinary, SourceLocation());
+  ImplicitCastExpr *LValToRval =
+    M.makeLvalueToRvalue(
+      M.makeDereference(
+        M.makeLvalueToRvalue(
+          M.makeDeclRefExpr(Predicate),
+          PredicateQPtrTy),
+        PredicateTy),
+    PredicateTy);
+  
+  UnaryOperator *UO = new (C) UnaryOperator(LValToRval, UO_LNot, C.IntTy,
+                                           VK_RValue, OK_Ordinary,
+                                           SourceLocation());
   
   // (5) Create the 'if' statement.
   IfStmt *If = new (C) IfStmt(C, SourceLocation(), 0, UO, CS);





More information about the cfe-commits mailing list