1 //===--- LoopUnrolling.h - Unroll loops -------------------------*- 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 header contains the declarations of functions which are used to decide 11 /// which loops should be completely unrolled and mark their corresponding 12 /// CFGBlocks. It is done by tracking a stack of loops in the ProgramState. This 13 /// way specific loops can be marked as completely unrolled. For considering a 14 /// loop to be completely unrolled it has to fulfill the following requirements: 15 /// - Currently only forStmts can be considered. 16 /// - The bound has to be known. 17 /// - The counter variable has not escaped before/in the body of the loop and 18 /// changed only in the increment statement corresponding to the loop. It also 19 /// has to be initialized by a literal in the corresponding initStmt. 20 /// - Does not contain goto, switch and returnStmt. 21 /// 22 /// 23 //===----------------------------------------------------------------------===// 24 25 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H 26 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H 27 28 #include "clang/Analysis/CFG.h" 29 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" 30 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" 31 namespace clang { 32 namespace ento { 33 class AnalysisManager; 34 35 /// Returns if the given State indicates that is inside a completely unrolled 36 /// loop. 37 bool isUnrolledState(ProgramStateRef State); 38 39 /// Updates the stack of loops contained by the ProgramState. 40 ProgramStateRef updateLoopStack(const Stmt *LoopStmt, ASTContext &ASTCtx, 41 ExplodedNode* Pred, unsigned maxVisitOnPath); 42 43 /// Updates the given ProgramState. In current implementation it removes the top 44 /// element of the stack of loops. 45 ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State); 46 47 } // end namespace ento 48 } // end namespace clang 49 50 #endif 51