Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Checks: '-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
readability-*,
-readability-function-cognitive-complexity,
-readability-else-after*,
-readability-simplify-boolean-expr,
-readability-implicit-bool-cast,
Expand Down Expand Up @@ -48,6 +49,10 @@ CheckOptions:
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: CamelCase
- key: readability-identifier-naming.VariableIgnoredRegexp
value: (c|d|d1|d2|d3|d4|d5|d5_restoredCtx|eP|f|f3|f4|f5|fCalleeSummary|g|n|dPrime|fPrime)
- key: readability-identifier-naming.ParameterIgnoredRegexp
value: (d|d1|d2|d3|d4|d5|eP|f|n)
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: 1
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
Expand Down
1,126 changes: 563 additions & 563 deletions include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver/IDESolver.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@ template <typename N, typename D, typename F, typename I, typename V,
typename ConcreteTabulationProblem, typename ConcreteSolver>
class IDESummaryGenerator {
protected:
const std::string toSummarize;
const I icfg;
const std::string ToSummarize;
const I ICFG;
const SummaryGenerationStrategy CTXStrategy;

class CTXFunctionProblem : public ConcreteTabulationProblem {
public:
const N start;
std::set<D> facts;
const N Start;
std::set<D> Facts;

CTXFunctionProblem(N start, std::set<D> facts, I icfg)
: ConcreteTabulationProblem(icfg), start(start), facts(facts) {
CTXFunctionProblem(N Start, std::set<D> Facts, I ICFG)
: ConcreteTabulationProblem(ICFG), Start(Start), Facts(Facts) {
this->solver_config.followReturnsPastSeeds = false;
this->solver_config.autoAddZero = true;
this->solver_config.computeValues = true;
this->solver_config.recordEdges = false;
this->solver_config.computePersistedSummaries = false;
}

virtual std::map<N, std::set<D>> initialSeeds() override {
std::map<N, std::set<D>> seeds;
seeds.insert(make_pair(start, facts));
return seeds;
std::map<N, std::set<D>> initialSeeds() override {
std::map<N, std::set<D>> Seeds;
Seeds.insert({Start, Facts});
return Seeds;
}
};

public:
IDESummaryGenerator(std::string Function, I Icfg,
SummaryGenerationStrategy Strategy)
: toSummarize(Function), icfg(Icfg), CTXStrategy(Strategy) {}
: ToSummarize(std::move(Function)), ICFG(Icfg), CTXStrategy(Strategy) {}
virtual ~IDESummaryGenerator() = default;
void generateSummaries() {
// initialize the input combinations that should be considered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IFDSSolver : public IDESolver<AnalysisDomainExtender<AnalysisDomainTy>> {
[[nodiscard]] virtual std::set<D> ifdsResultsAt(N Inst) {
std::set<D> KeySet;
std::unordered_map<D, BinaryDomain> ResultMap = this->resultsAt(Inst);
for (auto FlowFact : ResultMap) {
for (const auto &FlowFact : ResultMap) {
KeySet.insert(FlowFact.first);
}
return KeySet;
Expand All @@ -74,18 +74,18 @@ class IFDSSolver : public IDESolver<AnalysisDomainExtender<AnalysisDomainTy>> {
std::is_same_v<std::remove_reference_t<NTy>, llvm::Instruction *>,
std::set<D>>
ifdsResultsAtInLLVMSSA(NTy Inst) {
auto getResultMap = [this, Inst]() {
if (Inst->getType()->isVoidTy()) {
return this->resultsAt(Inst);
} else {
// In this case we have a value on the left-hand side and must return
// the results at the successor instruction. Note that terminator
// instructions are always of void type.
assert(Inst->getNextNode() &&
"Expected to find a valid successor node!");
return this->resultsAt(Inst->getNextNode());
}
};
auto getResultMap // NOLINT
= [this, Inst]() {
if (Inst->getType()->isVoidTy()) {
return this->resultsAt(Inst);
}
// In this case we have a value on the left-hand side and must
// return the results at the successor instruction. Note that
// terminator instructions are always of void type.
assert(Inst->getNextNode() &&
"Expected to find a valid successor node!");
return this->resultsAt(Inst->getNextNode());
};
std::set<D> KeySet;
for (auto &[FlowFact, LatticeValue] : getResultMap()) {
KeySet.insert(FlowFact);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct AnalysisDomainExtender : public OriginalAnalysisDomain {
};

template <typename, typename = void>
struct is_analysis_domain_extensions : std::false_type {};
struct is_analysis_domain_extensions : std::false_type {}; // NOLINT

template <typename AnalysisDomainTy>
struct is_analysis_domain_extensions<
Expand Down Expand Up @@ -75,27 +75,27 @@ class IFDSToIDETabulationProblem
this->ZeroValue = Problem.createZeroValue();
}

FlowFunctionPtrType getNormalFlowFunction(n_t curr, n_t succ) override {
return Problem.getNormalFlowFunction(curr, succ);
FlowFunctionPtrType getNormalFlowFunction(n_t Curr, n_t Succ) override {
return Problem.getNormalFlowFunction(Curr, Succ);
}

FlowFunctionPtrType getCallFlowFunction(n_t callSite, f_t destFun) override {
return Problem.getCallFlowFunction(callSite, destFun);
FlowFunctionPtrType getCallFlowFunction(n_t CallSite, f_t DestFun) override {
return Problem.getCallFlowFunction(CallSite, DestFun);
}

FlowFunctionPtrType getRetFlowFunction(n_t callSite, f_t calleeFun,
n_t exitInst, n_t retSite) override {
return Problem.getRetFlowFunction(callSite, calleeFun, exitInst, retSite);
FlowFunctionPtrType getRetFlowFunction(n_t CallSite, f_t CalleeFun,
n_t ExitInst, n_t RetSite) override {
return Problem.getRetFlowFunction(CallSite, CalleeFun, ExitInst, RetSite);
}

FlowFunctionPtrType getCallToRetFlowFunction(n_t callSite, n_t retSite,
std::set<f_t> callees) override {
return Problem.getCallToRetFlowFunction(callSite, retSite, callees);
FlowFunctionPtrType getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
std::set<f_t> Callees) override {
return Problem.getCallToRetFlowFunction(CallSite, RetSite, Callees);
}

FlowFunctionPtrType getSummaryFlowFunction(n_t callSite,
f_t destFun) override {
return Problem.getSummaryFlowFunction(callSite, destFun);
FlowFunctionPtrType getSummaryFlowFunction(n_t CallSite,
f_t DestFun) override {
return Problem.getSummaryFlowFunction(CallSite, DestFun);
}

InitialSeeds<n_t, d_t, l_t> initialSeeds() override {
Expand All @@ -114,73 +114,75 @@ class IFDSToIDETabulationProblem

BinaryDomain bottomElement() override { return BinaryDomain::BOTTOM; }

BinaryDomain join(BinaryDomain left, BinaryDomain right) override {
if (left == BinaryDomain::TOP && right == BinaryDomain::TOP) {
BinaryDomain join(BinaryDomain Lhs, BinaryDomain Rhs) override {
if (Lhs == BinaryDomain::TOP && Rhs == BinaryDomain::TOP) {
return BinaryDomain::TOP;
} else {
return BinaryDomain::BOTTOM;
}
return BinaryDomain::BOTTOM;
}

std::shared_ptr<EdgeFunction<BinaryDomain>> allTopFunction() override {
return std::make_shared<AllTop<BinaryDomain>>(BinaryDomain::TOP);
}

std::shared_ptr<EdgeFunction<BinaryDomain>>
getNormalEdgeFunction(n_t src, d_t srcNode, n_t tgt, d_t tgtNode) override {
if (Problem.isZeroValue(srcNode)) {
getNormalEdgeFunction(n_t /*Src*/, d_t SrcNode, n_t /*Tgt*/,
d_t /*TgtNode*/) override {
if (Problem.isZeroValue(SrcNode)) {
return ALLBOTTOM;
}
return EdgeIdentity<BinaryDomain>::getInstance();
}

std::shared_ptr<EdgeFunction<BinaryDomain>>
getCallEdgeFunction(n_t callSite, d_t srcNode, f_t destinationFunction,
d_t destNode) override {
if (Problem.isZeroValue(srcNode)) {
getCallEdgeFunction(n_t /*CallSite*/, d_t SrcNode,
f_t /*DestinationFunction*/, d_t /*DestNode*/) override {
if (Problem.isZeroValue(SrcNode)) {
return ALLBOTTOM;
}
return EdgeIdentity<BinaryDomain>::getInstance();
}

std::shared_ptr<EdgeFunction<BinaryDomain>>
getReturnEdgeFunction(n_t callSite, f_t calleeFunction, n_t exitInst,
d_t exitNode, n_t returnSite, d_t retNode) override {
if (Problem.isZeroValue(exitNode)) {
getReturnEdgeFunction(n_t /*CallSite*/, f_t /*CalleeFunction*/,
n_t /*ExitInst*/, d_t ExitNode, n_t /*ReturnSite*/,
d_t /*RetNode*/) override {
if (Problem.isZeroValue(ExitNode)) {
return ALLBOTTOM;
}
return EdgeIdentity<BinaryDomain>::getInstance();
}

std::shared_ptr<EdgeFunction<BinaryDomain>>
getCallToRetEdgeFunction(n_t callSite, d_t callNode, n_t returnSite,
d_t returnSideNode, std::set<f_t> callees) override {
if (Problem.isZeroValue(callNode)) {
getCallToRetEdgeFunction(n_t /*CallSite*/, d_t CallNode, n_t /*ReturnSite*/,
d_t /*ReturnSideNode*/,
std::set<f_t> /*Callees*/) override {
if (Problem.isZeroValue(CallNode)) {
return ALLBOTTOM;
}
return EdgeIdentity<BinaryDomain>::getInstance();
}

std::shared_ptr<EdgeFunction<BinaryDomain>>
getSummaryEdgeFunction(n_t callSite, d_t callNode, n_t retSite,
d_t retSiteNode) override {
getSummaryEdgeFunction(n_t /*CallSite*/, d_t /*CallNode*/, n_t /*RetSite*/,
d_t /*RetSiteNode*/) override {
return EdgeIdentity<BinaryDomain>::getInstance();
}

void printNode(std::ostream &os, n_t n) const override {
Problem.printNode(os, n);
void printNode(std::ostream &OS, n_t Stmt) const override {
Problem.printNode(OS, Stmt);
}

void printDataFlowFact(std::ostream &os, d_t d) const override {
Problem.printDataFlowFact(os, d);
void printDataFlowFact(std::ostream &OS, d_t Fact) const override {
Problem.printDataFlowFact(OS, Fact);
}

void printFunction(std::ostream &os, f_t f) const override {
Problem.printFunction(os, f);
void printFunction(std::ostream &OS, f_t Func) const override {
Problem.printFunction(OS, Func);
}

void printEdgeFact(std::ostream &os, BinaryDomain v) const override {
os << v;
void printEdgeFact(std::ostream &OS, BinaryDomain Val) const override {
OS << Val;
}

void emitTextReport(const SolverResults<n_t, d_t, l_t> &Results,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace psr {
template <typename T> class JoinHandlingNode {
public:
virtual ~JoinHandlingNode();
JoinHandlingNode(JoinHandlingNode &Other) = delete;
JoinHandlingNode &operator=(JoinHandlingNode &Other) = delete;
/**
*
Expand All @@ -33,19 +34,19 @@ template <typename T> class JoinHandlingNode {
* {@code joiningNode} is necessary, otherwise false meaning
* the node should be propagated by the solver.
*/
virtual bool handleJoin(T joiningNode) = 0;
virtual bool handleJoin(T JoiningNode) = 0;

class JoinKey {
private:
std::vector<T> elements;
std::vector<T> Elements;

public:
/**
*
* @param elements Passed elements must be immutable with respect to their
* hashCode and equals implementations.
*/
JoinKey(std::vector<T> elems) : elements(elems) {}
JoinKey(std::vector<T> Elems) : Elements(Elems) {}
int hash() { return 0; }
bool equals() { return false; }
};
Expand Down
Loading