1 //===--- LoopUnrolling.h - Unroll loops -------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// \file 9 /// This header contains the declarations of functions which are used to decide 10 /// which loops should be completely unrolled and mark their corresponding 11 /// CFGBlocks. It is done by tracking a stack of loops in the ProgramState. This 12 /// way specific loops can be marked as completely unrolled. For considering a 13 /// loop to be completely unrolled it has to fulfill the following requirements: 14 /// - Currently only forStmts can be considered. 15 /// - The bound has to be known. 16 /// - The counter variable has not escaped before/in the body of the loop and 17 /// changed only in the increment statement corresponding to the loop. It also 18 /// has to be initialized by a literal in the corresponding initStmt. 19 /// - Does not contain goto, switch and returnStmt. 20 /// 21 //===----------------------------------------------------------------------===// 22 23 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H 24 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H 25 26 #include "clang/Analysis/CFG.h" 27 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" 28 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" 29 namespace clang { 30 namespace ento { 31 32 /// Returns if the given State indicates that is inside a completely unrolled 33 /// loop. 34 bool isUnrolledState(ProgramStateRef State); 35 36 /// Updates the stack of loops contained by the ProgramState. 37 ProgramStateRef updateLoopStack(const Stmt *LoopStmt, ASTContext &ASTCtx, 38 ExplodedNode* Pred, unsigned maxVisitOnPath); 39 40 /// Updates the given ProgramState. In current implementation it removes the top 41 /// element of the stack of loops. 42 ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State); 43 44 } // end namespace ento 45 } // end namespace clang 46 47 #endif 48