1 //===--- LoopUnrolling.h - Unroll loops -------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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.
22 //===----------------------------------------------------------------------===//
24 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
25 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
27 #include "clang/Analysis/CFG.h"
28 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
29 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
32 class AnalysisManager;
34 /// Returns if the given State indicates that is inside a completely unrolled
36 bool isUnrolledState(ProgramStateRef State);
38 /// Updates the stack of loops contained by the ProgramState.
39 ProgramStateRef updateLoopStack(const Stmt *LoopStmt, ASTContext &ASTCtx,
40 ExplodedNode* Pred, unsigned maxVisitOnPath);
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);
46 } // end namespace ento
47 } // end namespace clang