| 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 | /// |
| 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 | |
| 24 | #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H |
| 25 | #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H |
| 26 | |
| 27 | #include "clang/Analysis/CFG.h" |
| 28 | #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" |
| 29 | #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" |
| 30 | namespace clang { |
| 31 | namespace ento { |
| 32 | class AnalysisManager; |
| 33 | |
| 34 | /// Returns if the given State indicates that is inside a completely unrolled |
| 35 | /// loop. |
| 36 | bool isUnrolledState(ProgramStateRef State); |
| 37 | |
| 38 | /// Updates the stack of loops contained by the ProgramState. |
| 39 | ProgramStateRef updateLoopStack(const Stmt *LoopStmt, ASTContext &ASTCtx, |
| 40 | ExplodedNode* Pred, unsigned maxVisitOnPath); |
| 41 | |
| 42 | /// Updates the given ProgramState. In current implementation it removes the top |
| 43 | /// element of the stack of loops. |
| 44 | ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State); |
| 45 | |
| 46 | } // end namespace ento |
| 47 | } // end namespace clang |
| 48 | |
| 49 | #endif |
| 50 |