18
18
#include " phasar/DataFlow/IfdsIde/IFDSIDESolverConfig.h"
19
19
#include " phasar/DataFlow/IfdsIde/InitialSeeds.h"
20
20
#include " phasar/DataFlow/IfdsIde/Solver/GenericSolverResults.h"
21
- #include " phasar/DataFlow/IfdsIde/SolverResults .h"
21
+ #include " phasar/Utils/DefaultAnalysisPrinterSelector .h"
22
22
#include " phasar/Utils/JoinLattice.h"
23
+ #include " phasar/Utils/MaybeUniquePtr.h"
23
24
#include " phasar/Utils/NullAnalysisPrinter.h"
24
25
#include " phasar/Utils/SemiRing.h"
25
26
#include " phasar/Utils/Soundness.h"
26
27
28
+ #include " llvm/Support/raw_ostream.h"
29
+
27
30
#include < cassert>
31
+ #include < memory>
28
32
#include < optional>
29
33
#include < set>
30
34
#include < string>
@@ -96,20 +100,28 @@ class IDETabulationProblem : public FlowFunctions<AnalysisDomainTy, Container>,
96
100
ZeroValue) noexcept (std::is_nothrow_move_constructible_v<d_t >)
97
101
: IRDB(IRDB), EntryPoints(std::move(EntryPoints)),
98
102
ZeroValue(std::move(ZeroValue)),
99
- Printer(NullAnalysisPrinter<AnalysisDomainTy>::getInstance()) {
103
+ Printer(std::make_unique<typename DefaultAnalysisPrinterSelector<
104
+ AnalysisDomainTy>::type>()) {
100
105
assert (IRDB != nullptr );
101
106
}
102
107
103
- void setAnalysisPrinter (AnalysisPrinterBase<AnalysisDomainTy> *P) {
108
+ IDETabulationProblem (IDETabulationProblem &&) noexcept = default ;
109
+ IDETabulationProblem &operator =(IDETabulationProblem &&) noexcept = default ;
110
+
111
+ IDETabulationProblem (const IDETabulationProblem &) = delete ;
112
+ IDETabulationProblem &operator =(const IDETabulationProblem &) = delete ;
113
+
114
+ ~IDETabulationProblem () override = default ;
115
+
116
+ void
117
+ setAnalysisPrinter (MaybeUniquePtr<AnalysisPrinterBase<AnalysisDomainTy>> P) {
104
118
if (P) {
105
- Printer = P ;
119
+ Printer = std::move (P) ;
106
120
} else {
107
121
Printer = NullAnalysisPrinter<AnalysisDomainTy>::getInstance ();
108
122
}
109
123
}
110
124
111
- ~IDETabulationProblem () override = default ;
112
-
113
125
// / Checks if the given data-flow fact is the special tautological lambda (or
114
126
// / zero) fact.
115
127
[[nodiscard]] virtual bool isZeroValue (d_t FlowFact) const noexcept {
@@ -148,7 +160,7 @@ class IDETabulationProblem : public FlowFunctions<AnalysisDomainTy, Container>,
148
160
virtual void
149
161
emitTextReport ([[maybe_unused]] GenericSolverResults<n_t , d_t , l_t > Results,
150
162
llvm::raw_ostream &OS = llvm::outs()) {
151
- OS << " No text report available! \n " ;
163
+ Printer-> onFinalize (OS) ;
152
164
}
153
165
154
166
// / Generates a graphical report, e.g. in html or other markup languages, of
@@ -163,7 +175,9 @@ class IDETabulationProblem : public FlowFunctions<AnalysisDomainTy, Container>,
163
175
// / the level of soundness is ignored. Otherwise, true.
164
176
virtual bool setSoundness (Soundness /* S*/ ) { return false ; }
165
177
166
- const ProjectIRDBBase<db_t > *getProjectIRDB () const noexcept { return IRDB; }
178
+ [[nodiscard]] const ProjectIRDBBase<db_t > *getProjectIRDB () const noexcept {
179
+ return IRDB;
180
+ }
167
181
168
182
protected:
169
183
typename FlowFunctions<AnalysisDomainTy, Container>::FlowFunctionPtrType
@@ -172,6 +186,19 @@ class IDETabulationProblem : public FlowFunctions<AnalysisDomainTy, Container>,
172
186
std::move (FactToGenerate), getZeroValue ());
173
187
}
174
188
189
+ template <typename L = l_t >
190
+ std::enable_if_t <!std::is_same_v<std::decay_t <L>, psr::BinaryDomain>>
191
+ onResult (n_t Instr, d_t DfFact, l_t LatticeElement,
192
+ DataFlowAnalysisType AnalysisType) {
193
+ Printer->onResult (Instr, std::move (DfFact), std::move (LatticeElement),
194
+ AnalysisType);
195
+ }
196
+ template <typename L = l_t >
197
+ std::enable_if_t <std::is_same_v<std::decay_t <L>, psr::BinaryDomain>>
198
+ onResult (n_t Instr, d_t DfFact, DataFlowAnalysisType AnalysisType) {
199
+ Printer->onResult (Instr, std::move (DfFact), AnalysisType);
200
+ }
201
+
175
202
// / Seeds that just start with ZeroValue and bottomElement() at the starting
176
203
// / points of each EntryPoint function.
177
204
// / Takes the __ALL__ EntryPoint into account.
@@ -196,7 +223,7 @@ class IDETabulationProblem : public FlowFunctions<AnalysisDomainTy, Container>,
196
223
197
224
[[maybe_unused]] Soundness SF = Soundness::Soundy;
198
225
199
- AnalysisPrinterBase<AnalysisDomainTy> * Printer;
226
+ MaybeUniquePtr< AnalysisPrinterBase<AnalysisDomainTy>> Printer;
200
227
};
201
228
202
229
} // namespace psr
0 commit comments