ExprEngine.h revision 5e5440ba9c135f523f72e7e7c5da59d390d697c5
1//===-- ExprEngine.h - Path-Sensitive Expression-Level Dataflow ---*- C++ -*-=// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines a meta-engine for path-sensitive dataflow analysis that 11// is built on CoreEngine, but provides the boilerplate to execute transfer 12// functions and build the ExplodedGraph at the expression level. 13// 14//===----------------------------------------------------------------------===// 15 16#ifndef LLVM_CLANG_GR_EXPRENGINE 17#define LLVM_CLANG_GR_EXPRENGINE 18 19#include "clang/AST/Expr.h" 20#include "clang/AST/Type.h" 21#include "clang/Analysis/DomainSpecific/ObjCNoReturn.h" 22#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" 23#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" 24#include "clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h" 25#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" 26#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" 27#include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h" 28 29namespace clang { 30 31class AnalysisDeclContextManager; 32class CXXCatchStmt; 33class CXXConstructExpr; 34class CXXDeleteExpr; 35class CXXNewExpr; 36class CXXTemporaryObjectExpr; 37class CXXThisExpr; 38class MaterializeTemporaryExpr; 39class ObjCAtSynchronizedStmt; 40class ObjCForCollectionStmt; 41 42namespace ento { 43 44class AnalysisManager; 45class CallEvent; 46class SimpleCall; 47class CXXConstructorCall; 48 49class ExprEngine : public SubEngine { 50public: 51 /// The modes of inlining. 52 enum InliningModes { 53 /// Do not inline any of the callees. 54 Inline_None = 0, 55 /// Inline all callees. 56 Inline_All = 0x1 57 } ; 58 59private: 60 AnalysisManager &AMgr; 61 62 AnalysisDeclContextManager &AnalysisDeclContexts; 63 64 CoreEngine Engine; 65 66 /// G - the simulation graph. 67 ExplodedGraph& G; 68 69 /// StateMgr - Object that manages the data for all created states. 70 ProgramStateManager StateMgr; 71 72 /// SymMgr - Object that manages the symbol information. 73 SymbolManager& SymMgr; 74 75 /// svalBuilder - SValBuilder object that creates SVals from expressions. 76 SValBuilder &svalBuilder; 77 78 unsigned int currStmtIdx; 79 const NodeBuilderContext *currBldrCtx; 80 81 /// Helper object to determine if an Objective-C message expression 82 /// implicitly never returns. 83 ObjCNoReturn ObjCNoRet; 84 85 /// Whether or not GC is enabled in this analysis. 86 bool ObjCGCEnabled; 87 88 /// The BugReporter associated with this engine. It is important that 89 /// this object be placed at the very end of member variables so that its 90 /// destructor is called before the rest of the ExprEngine is destroyed. 91 GRBugReporter BR; 92 93 /// The functions which have been analyzed through inlining. This is owned by 94 /// AnalysisConsumer. It can be null. 95 SetOfConstDecls *VisitedCallees; 96 97 /// The flag, which specifies the mode of inlining for the engine. 98 InliningModes HowToInline; 99 100public: 101 ExprEngine(AnalysisManager &mgr, bool gcEnabled, 102 SetOfConstDecls *VisitedCalleesIn, 103 FunctionSummariesTy *FS, 104 InliningModes HowToInlineIn); 105 106 ~ExprEngine(); 107 108 /// Returns true if there is still simulation state on the worklist. 109 bool ExecuteWorkList(const LocationContext *L, unsigned Steps = 150000) { 110 return Engine.ExecuteWorkList(L, Steps, 0); 111 } 112 113 /// Execute the work list with an initial state. Nodes that reaches the exit 114 /// of the function are added into the Dst set, which represent the exit 115 /// state of the function call. Returns true if there is still simulation 116 /// state on the worklist. 117 bool ExecuteWorkListWithInitialState(const LocationContext *L, unsigned Steps, 118 ProgramStateRef InitState, 119 ExplodedNodeSet &Dst) { 120 return Engine.ExecuteWorkListWithInitialState(L, Steps, InitState, Dst); 121 } 122 123 /// getContext - Return the ASTContext associated with this analysis. 124 ASTContext &getContext() const { return AMgr.getASTContext(); } 125 126 virtual AnalysisManager &getAnalysisManager() { return AMgr; } 127 128 CheckerManager &getCheckerManager() const { 129 return *AMgr.getCheckerManager(); 130 } 131 132 SValBuilder &getSValBuilder() { return svalBuilder; } 133 134 BugReporter& getBugReporter() { return BR; } 135 136 const NodeBuilderContext &getBuilderContext() { 137 assert(currBldrCtx); 138 return *currBldrCtx; 139 } 140 141 bool isObjCGCEnabled() { return ObjCGCEnabled; } 142 143 const Stmt *getStmt() const; 144 145 void GenerateAutoTransition(ExplodedNode *N); 146 void enqueueEndOfPath(ExplodedNodeSet &S); 147 void GenerateCallExitNode(ExplodedNode *N); 148 149 /// ViewGraph - Visualize the ExplodedGraph created by executing the 150 /// simulation. 151 void ViewGraph(bool trim = false); 152 153 void ViewGraph(ExplodedNode** Beg, ExplodedNode** End); 154 155 /// getInitialState - Return the initial state used for the root vertex 156 /// in the ExplodedGraph. 157 ProgramStateRef getInitialState(const LocationContext *InitLoc); 158 159 ExplodedGraph& getGraph() { return G; } 160 const ExplodedGraph& getGraph() const { return G; } 161 162 /// \brief Run the analyzer's garbage collection - remove dead symbols and 163 /// bindings from the state. 164 /// 165 /// Checkers can participate in this process with two callbacks: 166 /// \c checkLiveSymbols and \c checkDeadSymbols. See the CheckerDocumentation 167 /// class for more information. 168 /// 169 /// \param Node The predecessor node, from which the processing should start. 170 /// \param Out The returned set of output nodes. 171 /// \param ReferenceStmt The statement which is about to be processed. 172 /// Everything needed for this statement should be considered live. 173 /// A null statement means that everything in child LocationContexts 174 /// is dead. 175 /// \param LC The location context of the \p ReferenceStmt. A null location 176 /// context means that we have reached the end of analysis and that 177 /// all statements and local variables should be considered dead. 178 /// \param DiagnosticStmt Used as a location for any warnings that should 179 /// occur while removing the dead (e.g. leaks). By default, the 180 /// \p ReferenceStmt is used. 181 /// \param K Denotes whether this is a pre- or post-statement purge. This 182 /// must only be ProgramPoint::PostStmtPurgeDeadSymbolsKind if an 183 /// entire location context is being cleared, in which case the 184 /// \p ReferenceStmt must either be a ReturnStmt or \c NULL. Otherwise, 185 /// it must be ProgramPoint::PreStmtPurgeDeadSymbolsKind (the default) 186 /// and \p ReferenceStmt must be valid (non-null). 187 void removeDead(ExplodedNode *Node, ExplodedNodeSet &Out, 188 const Stmt *ReferenceStmt, const LocationContext *LC, 189 const Stmt *DiagnosticStmt = 0, 190 ProgramPoint::Kind K = ProgramPoint::PreStmtPurgeDeadSymbolsKind); 191 192 /// processCFGElement - Called by CoreEngine. Used to generate new successor 193 /// nodes by processing the 'effects' of a CFG element. 194 void processCFGElement(const CFGElement E, ExplodedNode *Pred, 195 unsigned StmtIdx, NodeBuilderContext *Ctx); 196 197 void ProcessStmt(const CFGStmt S, ExplodedNode *Pred); 198 199 void ProcessInitializer(const CFGInitializer I, ExplodedNode *Pred); 200 201 void ProcessImplicitDtor(const CFGImplicitDtor D, ExplodedNode *Pred); 202 203 void ProcessAutomaticObjDtor(const CFGAutomaticObjDtor D, 204 ExplodedNode *Pred, ExplodedNodeSet &Dst); 205 void ProcessBaseDtor(const CFGBaseDtor D, 206 ExplodedNode *Pred, ExplodedNodeSet &Dst); 207 void ProcessMemberDtor(const CFGMemberDtor D, 208 ExplodedNode *Pred, ExplodedNodeSet &Dst); 209 void ProcessTemporaryDtor(const CFGTemporaryDtor D, 210 ExplodedNode *Pred, ExplodedNodeSet &Dst); 211 212 /// Called by CoreEngine when processing the entrance of a CFGBlock. 213 virtual void processCFGBlockEntrance(const BlockEdge &L, 214 NodeBuilderWithSinks &nodeBuilder, 215 ExplodedNode *Pred); 216 217 /// ProcessBranch - Called by CoreEngine. Used to generate successor 218 /// nodes by processing the 'effects' of a branch condition. 219 void processBranch(const Stmt *Condition, const Stmt *Term, 220 NodeBuilderContext& BuilderCtx, 221 ExplodedNode *Pred, 222 ExplodedNodeSet &Dst, 223 const CFGBlock *DstT, 224 const CFGBlock *DstF); 225 226 /// processIndirectGoto - Called by CoreEngine. Used to generate successor 227 /// nodes by processing the 'effects' of a computed goto jump. 228 void processIndirectGoto(IndirectGotoNodeBuilder& builder); 229 230 /// ProcessSwitch - Called by CoreEngine. Used to generate successor 231 /// nodes by processing the 'effects' of a switch statement. 232 void processSwitch(SwitchNodeBuilder& builder); 233 234 /// Called by CoreEngine. Used to generate end-of-path 235 /// nodes when the control reaches the end of a function. 236 void processEndOfFunction(NodeBuilderContext& BC, 237 ExplodedNode *Pred); 238 239 /// Remove dead bindings/symbols before exiting a function. 240 void removeDeadOnEndOfFunction(NodeBuilderContext& BC, 241 ExplodedNode *Pred, 242 ExplodedNodeSet &Dst); 243 244 /// Generate the entry node of the callee. 245 void processCallEnter(CallEnter CE, ExplodedNode *Pred); 246 247 /// Generate the sequence of nodes that simulate the call exit and the post 248 /// visit for CallExpr. 249 void processCallExit(ExplodedNode *Pred); 250 251 /// Called by CoreEngine when the analysis worklist has terminated. 252 void processEndWorklist(bool hasWorkRemaining); 253 254 /// evalAssume - Callback function invoked by the ConstraintManager when 255 /// making assumptions about state values. 256 ProgramStateRef processAssume(ProgramStateRef state, SVal cond,bool assumption); 257 258 /// wantsRegionChangeUpdate - Called by ProgramStateManager to determine if a 259 /// region change should trigger a processRegionChanges update. 260 bool wantsRegionChangeUpdate(ProgramStateRef state); 261 262 /// processRegionChanges - Called by ProgramStateManager whenever a change is made 263 /// to the store. Used to update checkers that track region values. 264 ProgramStateRef 265 processRegionChanges(ProgramStateRef state, 266 const InvalidatedSymbols *invalidated, 267 ArrayRef<const MemRegion *> ExplicitRegions, 268 ArrayRef<const MemRegion *> Regions, 269 const CallEvent *Call); 270 271 /// printState - Called by ProgramStateManager to print checker-specific data. 272 void printState(raw_ostream &Out, ProgramStateRef State, 273 const char *NL, const char *Sep); 274 275 virtual ProgramStateManager& getStateManager() { return StateMgr; } 276 277 StoreManager& getStoreManager() { return StateMgr.getStoreManager(); } 278 279 ConstraintManager& getConstraintManager() { 280 return StateMgr.getConstraintManager(); 281 } 282 283 // FIXME: Remove when we migrate over to just using SValBuilder. 284 BasicValueFactory& getBasicVals() { 285 return StateMgr.getBasicVals(); 286 } 287 288 // FIXME: Remove when we migrate over to just using ValueManager. 289 SymbolManager& getSymbolManager() { return SymMgr; } 290 const SymbolManager& getSymbolManager() const { return SymMgr; } 291 292 // Functions for external checking of whether we have unfinished work 293 bool wasBlocksExhausted() const { return Engine.wasBlocksExhausted(); } 294 bool hasEmptyWorkList() const { return !Engine.getWorkList()->hasWork(); } 295 bool hasWorkRemaining() const { return Engine.hasWorkRemaining(); } 296 297 const CoreEngine &getCoreEngine() const { return Engine; } 298 299public: 300 /// Visit - Transfer function logic for all statements. Dispatches to 301 /// other functions that handle specific kinds of statements. 302 void Visit(const Stmt *S, ExplodedNode *Pred, ExplodedNodeSet &Dst); 303 304 /// VisitArraySubscriptExpr - Transfer function for array accesses. 305 void VisitLvalArraySubscriptExpr(const ArraySubscriptExpr *Ex, 306 ExplodedNode *Pred, 307 ExplodedNodeSet &Dst); 308 309 /// VisitGCCAsmStmt - Transfer function logic for inline asm. 310 void VisitGCCAsmStmt(const GCCAsmStmt *A, ExplodedNode *Pred, 311 ExplodedNodeSet &Dst); 312 313 /// VisitMSAsmStmt - Transfer function logic for MS inline asm. 314 void VisitMSAsmStmt(const MSAsmStmt *A, ExplodedNode *Pred, 315 ExplodedNodeSet &Dst); 316 317 /// VisitBlockExpr - Transfer function logic for BlockExprs. 318 void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred, 319 ExplodedNodeSet &Dst); 320 321 /// VisitBinaryOperator - Transfer function logic for binary operators. 322 void VisitBinaryOperator(const BinaryOperator* B, ExplodedNode *Pred, 323 ExplodedNodeSet &Dst); 324 325 326 /// VisitCall - Transfer function for function calls. 327 void VisitCallExpr(const CallExpr *CE, ExplodedNode *Pred, 328 ExplodedNodeSet &Dst); 329 330 /// VisitCast - Transfer function logic for all casts (implicit and explicit). 331 void VisitCast(const CastExpr *CastE, const Expr *Ex, ExplodedNode *Pred, 332 ExplodedNodeSet &Dst); 333 334 /// VisitCompoundLiteralExpr - Transfer function logic for compound literals. 335 void VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL, 336 ExplodedNode *Pred, ExplodedNodeSet &Dst); 337 338 /// Transfer function logic for DeclRefExprs and BlockDeclRefExprs. 339 void VisitCommonDeclRefExpr(const Expr *DR, const NamedDecl *D, 340 ExplodedNode *Pred, ExplodedNodeSet &Dst); 341 342 /// VisitDeclStmt - Transfer function logic for DeclStmts. 343 void VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred, 344 ExplodedNodeSet &Dst); 345 346 /// VisitGuardedExpr - Transfer function logic for ?, __builtin_choose 347 void VisitGuardedExpr(const Expr *Ex, const Expr *L, const Expr *R, 348 ExplodedNode *Pred, ExplodedNodeSet &Dst); 349 350 void VisitInitListExpr(const InitListExpr *E, ExplodedNode *Pred, 351 ExplodedNodeSet &Dst); 352 353 /// VisitLogicalExpr - Transfer function logic for '&&', '||' 354 void VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred, 355 ExplodedNodeSet &Dst); 356 357 /// VisitMemberExpr - Transfer function for member expressions. 358 void VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred, 359 ExplodedNodeSet &Dst); 360 361 /// Transfer function logic for ObjCAtSynchronizedStmts. 362 void VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S, 363 ExplodedNode *Pred, ExplodedNodeSet &Dst); 364 365 /// Transfer function logic for computing the lvalue of an Objective-C ivar. 366 void VisitLvalObjCIvarRefExpr(const ObjCIvarRefExpr *DR, ExplodedNode *Pred, 367 ExplodedNodeSet &Dst); 368 369 /// VisitObjCForCollectionStmt - Transfer function logic for 370 /// ObjCForCollectionStmt. 371 void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S, 372 ExplodedNode *Pred, ExplodedNodeSet &Dst); 373 374 void VisitObjCMessage(const ObjCMessageExpr *ME, ExplodedNode *Pred, 375 ExplodedNodeSet &Dst); 376 377 /// VisitReturnStmt - Transfer function logic for return statements. 378 void VisitReturnStmt(const ReturnStmt *R, ExplodedNode *Pred, 379 ExplodedNodeSet &Dst); 380 381 /// VisitOffsetOfExpr - Transfer function for offsetof. 382 void VisitOffsetOfExpr(const OffsetOfExpr *Ex, ExplodedNode *Pred, 383 ExplodedNodeSet &Dst); 384 385 /// VisitUnaryExprOrTypeTraitExpr - Transfer function for sizeof. 386 void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Ex, 387 ExplodedNode *Pred, ExplodedNodeSet &Dst); 388 389 /// VisitUnaryOperator - Transfer function logic for unary operators. 390 void VisitUnaryOperator(const UnaryOperator* B, ExplodedNode *Pred, 391 ExplodedNodeSet &Dst); 392 393 /// Handle ++ and -- (both pre- and post-increment). 394 void VisitIncrementDecrementOperator(const UnaryOperator* U, 395 ExplodedNode *Pred, 396 ExplodedNodeSet &Dst); 397 398 void VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred, 399 ExplodedNodeSet &Dst); 400 401 void VisitCXXThisExpr(const CXXThisExpr *TE, ExplodedNode *Pred, 402 ExplodedNodeSet & Dst); 403 404 void VisitCXXConstructExpr(const CXXConstructExpr *E, ExplodedNode *Pred, 405 ExplodedNodeSet &Dst); 406 407 void VisitCXXDestructor(QualType ObjectType, const MemRegion *Dest, 408 const Stmt *S, bool IsBaseDtor, 409 ExplodedNode *Pred, ExplodedNodeSet &Dst); 410 411 void VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred, 412 ExplodedNodeSet &Dst); 413 414 void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE, ExplodedNode *Pred, 415 ExplodedNodeSet &Dst); 416 417 /// Create a C++ temporary object for an rvalue. 418 void CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, 419 ExplodedNode *Pred, 420 ExplodedNodeSet &Dst); 421 422 /// evalEagerlyAssumeBinOpBifurcation - Given the nodes in 'Src', eagerly assume symbolic 423 /// expressions of the form 'x != 0' and generate new nodes (stored in Dst) 424 /// with those assumptions. 425 void evalEagerlyAssumeBinOpBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, 426 const Expr *Ex); 427 428 std::pair<const ProgramPointTag *, const ProgramPointTag*> 429 geteagerlyAssumeBinOpBifurcationTags(); 430 431 SVal evalMinus(SVal X) { 432 return X.isValid() ? svalBuilder.evalMinus(X.castAs<NonLoc>()) : X; 433 } 434 435 SVal evalComplement(SVal X) { 436 return X.isValid() ? svalBuilder.evalComplement(X.castAs<NonLoc>()) : X; 437 } 438 439public: 440 441 SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, 442 NonLoc L, NonLoc R, QualType T) { 443 return svalBuilder.evalBinOpNN(state, op, L, R, T); 444 } 445 446 SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, 447 NonLoc L, SVal R, QualType T) { 448 return R.isValid() ? svalBuilder.evalBinOpNN(state, op, L, 449 R.castAs<NonLoc>(), T) : R; 450 } 451 452 SVal evalBinOp(ProgramStateRef ST, BinaryOperator::Opcode Op, 453 SVal LHS, SVal RHS, QualType T) { 454 return svalBuilder.evalBinOp(ST, Op, LHS, RHS, T); 455 } 456 457protected: 458 /// evalBind - Handle the semantics of binding a value to a specific location. 459 /// This method is used by evalStore, VisitDeclStmt, and others. 460 void evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE, ExplodedNode *Pred, 461 SVal location, SVal Val, bool atDeclInit = false, 462 const ProgramPoint *PP = 0); 463 464 /// Call PointerEscape callback when a value escapes as a result of bind. 465 ProgramStateRef processPointerEscapedOnBind(ProgramStateRef State, 466 SVal Loc, SVal Val); 467 /// Call PointerEscape callback when a value escapes as a result of 468 /// region invalidation. 469 ProgramStateRef processPointerEscapedOnInvalidateRegions( 470 ProgramStateRef State, 471 const InvalidatedSymbols *Invalidated, 472 ArrayRef<const MemRegion *> ExplicitRegions, 473 ArrayRef<const MemRegion *> Regions, 474 const CallEvent *Call); 475 476public: 477 // FIXME: 'tag' should be removed, and a LocationContext should be used 478 // instead. 479 // FIXME: Comment on the meaning of the arguments, when 'St' may not 480 // be the same as Pred->state, and when 'location' may not be the 481 // same as state->getLValue(Ex). 482 /// Simulate a read of the result of Ex. 483 void evalLoad(ExplodedNodeSet &Dst, 484 const Expr *NodeEx, /* Eventually will be a CFGStmt */ 485 const Expr *BoundExpr, 486 ExplodedNode *Pred, 487 ProgramStateRef St, 488 SVal location, 489 const ProgramPointTag *tag = 0, 490 QualType LoadTy = QualType()); 491 492 // FIXME: 'tag' should be removed, and a LocationContext should be used 493 // instead. 494 void evalStore(ExplodedNodeSet &Dst, const Expr *AssignE, const Expr *StoreE, 495 ExplodedNode *Pred, ProgramStateRef St, SVal TargetLV, SVal Val, 496 const ProgramPointTag *tag = 0); 497 498 /// \brief Create a new state in which the call return value is binded to the 499 /// call origin expression. 500 ProgramStateRef bindReturnValue(const CallEvent &Call, 501 const LocationContext *LCtx, 502 ProgramStateRef State); 503 504 /// Evaluate a call, running pre- and post-call checks and allowing checkers 505 /// to be responsible for handling the evaluation of the call itself. 506 void evalCall(ExplodedNodeSet &Dst, ExplodedNode *Pred, 507 const CallEvent &Call); 508 509 /// \brief Default implementation of call evaluation. 510 void defaultEvalCall(NodeBuilder &B, ExplodedNode *Pred, 511 const CallEvent &Call); 512private: 513 void evalLoadCommon(ExplodedNodeSet &Dst, 514 const Expr *NodeEx, /* Eventually will be a CFGStmt */ 515 const Expr *BoundEx, 516 ExplodedNode *Pred, 517 ProgramStateRef St, 518 SVal location, 519 const ProgramPointTag *tag, 520 QualType LoadTy); 521 522 // FIXME: 'tag' should be removed, and a LocationContext should be used 523 // instead. 524 void evalLocation(ExplodedNodeSet &Dst, 525 const Stmt *NodeEx, /* This will eventually be a CFGStmt */ 526 const Stmt *BoundEx, 527 ExplodedNode *Pred, 528 ProgramStateRef St, SVal location, 529 const ProgramPointTag *tag, bool isLoad); 530 531 /// Count the stack depth and determine if the call is recursive. 532 void examineStackFrames(const Decl *D, const LocationContext *LCtx, 533 bool &IsRecursive, unsigned &StackDepth); 534 535 bool shouldInlineDecl(const Decl *D, ExplodedNode *Pred); 536 bool inlineCall(const CallEvent &Call, const Decl *D, NodeBuilder &Bldr, 537 ExplodedNode *Pred, ProgramStateRef State); 538 539 /// \brief Conservatively evaluate call by invalidating regions and binding 540 /// a conjured return value. 541 void conservativeEvalCall(const CallEvent &Call, NodeBuilder &Bldr, 542 ExplodedNode *Pred, ProgramStateRef State); 543 544 /// \brief Either inline or process the call conservatively (or both), based 545 /// on DynamicDispatchBifurcation data. 546 void BifurcateCall(const MemRegion *BifurReg, 547 const CallEvent &Call, const Decl *D, NodeBuilder &Bldr, 548 ExplodedNode *Pred); 549 550 bool replayWithoutInlining(ExplodedNode *P, const LocationContext *CalleeLC); 551 552 /// Models a trivial copy or move constructor call with a simple bind. 553 void performTrivialCopy(NodeBuilder &Bldr, ExplodedNode *Pred, 554 const CXXConstructorCall &Call); 555 556 /// If the value of the given expression is a NonLoc, copy it into a new 557 /// temporary object region, and replace the value of the expression with 558 /// that. 559 /// 560 /// If \p ResultE is provided, the new region will be bound to this expression 561 /// instead of \p E. 562 ProgramStateRef createTemporaryRegionIfNeeded(ProgramStateRef State, 563 const LocationContext *LC, 564 const Expr *E, 565 const Expr *ResultE = 0); 566}; 567 568/// Traits for storing the call processing policy inside GDM. 569/// The GDM stores the corresponding CallExpr pointer. 570// FIXME: This does not use the nice trait macros because it must be accessible 571// from multiple translation units. 572struct ReplayWithoutInlining{}; 573template <> 574struct ProgramStateTrait<ReplayWithoutInlining> : 575 public ProgramStatePartialTrait<const void*> { 576 static void *GDMIndex() { static int index = 0; return &index; } 577}; 578 579} // end ento namespace 580 581} // end clang namespace 582 583#endif 584