diff options
Diffstat (limited to 'clang/lib/Analysis/BodyFarm.cpp')
-rw-r--r-- | clang/lib/Analysis/BodyFarm.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp index 05a311e5b21..ac8fcdc912a 100644 --- a/clang/lib/Analysis/BodyFarm.cpp +++ b/clang/lib/Analysis/BodyFarm.cpp @@ -50,33 +50,33 @@ namespace { class ASTMaker { public: ASTMaker(ASTContext &C) : C(C) {} - + /// Create a new BinaryOperator representing a simple assignment. BinaryOperator *makeAssignment(const Expr *LHS, const Expr *RHS, QualType Ty); - + /// Create a new BinaryOperator representing a comparison. BinaryOperator *makeComparison(const Expr *LHS, const Expr *RHS, BinaryOperator::Opcode Op); - + /// Create a new compound stmt using the provided statements. CompoundStmt *makeCompound(ArrayRef<Stmt*>); - + /// Create a new DeclRefExpr for the referenced variable. DeclRefExpr *makeDeclRefExpr(const VarDecl *D, bool RefersToEnclosingVariableOrCapture = false); - + /// Create a new UnaryOperator representing a dereference. UnaryOperator *makeDereference(const Expr *Arg, QualType Ty); - + /// Create an implicit cast for an integer conversion. Expr *makeIntegralCast(const Expr *Arg, QualType Ty); - + /// Create an implicit cast to a builtin boolean type. ImplicitCastExpr *makeIntegralCastToBoolean(const Expr *Arg); - + /// Create an implicit cast for lvalue-to-rvaluate conversions. ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg, QualType Ty); - + /// Make RValue out of variable declaration, creating a temporary /// DeclRefExpr in the process. ImplicitCastExpr * @@ -92,10 +92,10 @@ public: /// Create an Objective-C ivar reference. ObjCIvarRefExpr *makeObjCIvarRef(const Expr *Base, const ObjCIvarDecl *IVar); - + /// Create a Return statement. ReturnStmt *makeReturn(const Expr *RetVal); - + /// Create an integer literal expression of the given type. IntegerLiteral *makeIntegerLiteral(uint64_t Value, QualType Ty); @@ -506,9 +506,9 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) { // block(); // } // } - + ASTMaker M(C); - + // (1) Create the call. CallExpr *CE = new (C) CallExpr( /*ASTContext=*/C, @@ -532,11 +532,11 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) { PredicateTy), M.makeIntegralCast(DoneValue, PredicateTy), PredicateTy); - + // (3) Create the compound statement. Stmt *Stmts[] = { B, CE }; CompoundStmt *CS = M.makeCompound(Stmts); - + // (4) Create the 'if' condition. ImplicitCastExpr *LValToRval = M.makeLvalueToRvalue( @@ -576,7 +576,7 @@ static Stmt *create_dispatch_sync(ASTContext &C, const FunctionDecl *D) { // void dispatch_sync(dispatch_queue_t queue, void (^block)(void)) { // block(); // } - // + // ASTMaker M(C); DeclRefExpr *DR = M.makeDeclRefExpr(PV); ImplicitCastExpr *ICE = M.makeLvalueToRvalue(DR, Ty); @@ -612,16 +612,16 @@ static Stmt *create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D) const ParmVarDecl *NewValue = D->getParamDecl(1); QualType NewValueTy = NewValue->getType(); - + assert(OldValueTy == NewValueTy); - + const ParmVarDecl *TheValue = D->getParamDecl(2); QualType TheValueTy = TheValue->getType(); const PointerType *PT = TheValueTy->getAs<PointerType>(); if (!PT) return nullptr; QualType PointeeTy = PT->getPointeeType(); - + ASTMaker M(C); // Construct the comparison. Expr *Comparison = @@ -643,29 +643,29 @@ static Stmt *create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D) PointeeTy), M.makeLvalueToRvalue(M.makeDeclRefExpr(NewValue), NewValueTy), NewValueTy); - + Expr *BoolVal = M.makeObjCBool(true); Expr *RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal) : M.makeIntegralCast(BoolVal, ResultTy); Stmts[1] = M.makeReturn(RetVal); CompoundStmt *Body = M.makeCompound(Stmts); - + // Construct the else clause. BoolVal = M.makeObjCBool(false); RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal) : M.makeIntegralCast(BoolVal, ResultTy); Stmt *Else = M.makeReturn(RetVal); - + /// Construct the If. Stmt *If = new (C) IfStmt(C, SourceLocation(), false, nullptr, nullptr, Comparison, Body, SourceLocation(), Else); - return If; + return If; } Stmt *BodyFarm::getBody(const FunctionDecl *D) { D = D->getCanonicalDecl(); - + Optional<Stmt *> &Val = Bodies[D]; if (Val.hasValue()) return Val.getValue(); @@ -692,7 +692,7 @@ Stmt *BodyFarm::getBody(const FunctionDecl *D) { .Case("dispatch_once", create_dispatch_once) .Default(nullptr); } - + if (FF) { Val = FF(C, D); } else if (Injector) { Val = Injector->getBody(D); } return Val.getValue(); |