]> granicus.if.org Git - clang/commitdiff
Experiment in BodyFarm of structuring AST creation calls in a hierarchy,
authorTed Kremenek <kremenek@apple.com>
Fri, 21 Sep 2012 18:33:56 +0000 (18:33 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 21 Sep 2012 18:33:56 +0000 (18:33 +0000)
so that they visually look like an AST dump.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164401 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BodyFarm.cpp

index 54c8ab4430080f8c757498910a3daba67ec57ec5..be998581d75ac0d545364f5df8ccc834053d6f6a 100644 (file)
@@ -151,12 +151,15 @@ 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 = 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 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
                                           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);