Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## development HEAD

- `IDESolver::initialize()` does no longer return a `bool`. Now, you are always allowed to call `next()` at least once.
- `IntraMonoProblem` and `InterMonoProblem`, and all reference-implementations of these problems do not receive a TypeHierarchy-pointer anymore in the ctor.
- Requiring C++20 instead of C++17
- Type-traits and other templates that are specialized now use `requires` instead of `enable_if`, wherever possible. This may reduce the number of (defaulted) template parameters in some cases.
Expand Down
39 changes: 19 additions & 20 deletions examples/how-to/04-run-ifds-analysis/ifds-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,29 @@ int main(int Argc, char *Argv[]) {
psr::IFDSSolver Solver(&TaintProblem, &ICFG);

// The simple solution. You don't really need an explicit solver for this:
// Solver.solve();
// auto Results = Solver.solve();

// Have more control over the solving process:
if (Solver.initialize()) {
int i = 0;
Solver.initialize();
int i = 0;

// Perform the next 10 analysis steps, while we still have some
while (Solver.nextN(10)) {
// Perform some intermediate task *during* the solving process.
// We could also interrupt the solver at any time and continue later.
llvm::outs() << "\b\b" << Spinner[i] << ' ';
i = (i + 1) % std::size(Spinner);
// Perform the next 10 analysis steps, while we still have some work items
while (Solver.nextN(10)) {
// Perform some intermediate task *during* the solving process.
// We could also interrupt the solver at any time and continue later.
llvm::outs() << "\b\b" << Spinner[i] << ' ';
i = (i + 1) % std::size(Spinner);

// Wait a bit, such that we have time to see the beautiful animation for
// our tiny example target programs:
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
}

Solver.finalize();
llvm::outs() << "\nSolving finished\n";
// Wait a bit, such that we have time to see the beautiful animation for
// our tiny example target programs:
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
}

// Here, we could loop over TaintProblem.Leaks. Instead, we will now use
// the Solver to dump the whole raw IFDS results:
Solver.dumpResults();
auto Results = Solver.finalize();
llvm::outs() << "\nSolving finished\n";

// Here, we could loop over TaintProblem.Leaks. Instead, we will now use dump
// the whole raw IFDS results:
Results.dumpResults(ICFG);
}
2 changes: 2 additions & 0 deletions examples/how-to/04-run-ifds-analysis/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ int main(int Argc, char *Argv[]) {

// Solving the TaintProblem. This may take some time, depending on the size of
// the ICFG
// Note: solveIFDSProblem() returns the raw SolverResults, but we don't use
// them here...
psr::solveIFDSProblem(TaintProblem, ICFG);

// After we have solved the TaintProblem, we can now inspect the detected
Expand Down
42 changes: 19 additions & 23 deletions examples/how-to/05-run-ide-analysis/ide-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,29 @@ int main(int Argc, char *Argv[]) {
// Solver.solve();

// Have more control over the solving process:
if (Solver.initialize()) {
int i = 0;
Solver.initialize();
int i = 0;

// Perform the next 10 analysis steps, while we still have some
while (Solver.nextN(10)) {
// Perform some intermediate task *during* the solving process.
// We could also interrupt the solver at any time and continue later.
llvm::outs() << "\b\b" << Spinner[i] << ' ';
i = (i + 1) % std::size(Spinner);
// Perform the next 10 analysis steps, while we still have some
while (Solver.nextN(10)) {
// Perform some intermediate task *during* the solving process.
// We could also interrupt the solver at any time and continue later.
llvm::outs() << "\b\b" << Spinner[i] << ' ';
i = (i + 1) % std::size(Spinner);

// Wait a bit, such that we have time to see the beautiful animation for
// our tiny example target programs:
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
}

// In contrast to the IFDSSolver, finalize may take some time with IDE.
// It will still be significantly faster than the above loop.
Solver.finalize();
llvm::outs() << "\nSolving finished\n";
// Wait a bit, such that we have time to see the beautiful animation for
// our tiny example target programs:
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
}

// Accessing the results:
auto Results = Solver.getSolverResults();
// In contrast to the IFDSSolver, finalize may take some time with IDE.
// It will still be significantly faster than the above loop.
auto Results = Solver.finalize();
llvm::outs() << "\nSolving finished\n";

// After we have solved the LCAProblem, we can now inspect the detected
// constants. Instead of manually looping, will now use
// the Solver to dump the whole raw IDE results:
Solver.dumpResults();
// constants. Instead of manually looping, will now dump the whole raw IDE
// results:
Results.dumpResults(ICFG);
}
10 changes: 6 additions & 4 deletions include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ class IDESolver

/// -- InteractiveIDESolverMixin implementation

bool doInitialize() {
void doInitialize() {
PAMM_GET_INSTANCE;
REG_COUNTER("Gen facts", 0, Core);
REG_COUNTER("Kill facts", 0, Core);
Expand Down Expand Up @@ -1820,19 +1820,21 @@ class IDESolver

// We start our analysis and construct exploded supergraph
submitInitialSeeds();
return !WorkList.empty();
}

bool doNext() {
assert(!WorkList.empty());
if (WorkList.empty()) {
return false;
}

auto [Edge, EF] = std::move(WorkList.back());
WorkList.pop_back();

auto [SourceVal, Target, TargetVal] = Edge.consume();
propagate(std::move(SourceVal), std::move(Target), std::move(TargetVal),
std::move(EF));

return !WorkList.empty();
return true;
}

void finalizeInternal() {
Expand Down
Loading
Loading