Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make NToString and friends free functions #652

Merged
merged 6 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CheckOptions:
- key: readability-identifier-naming.ParameterIgnoredRegexp
value: (d|d1|d2|d3|d4|d5|eP|f|n)
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: (try_emplace|from_json|to_json|equal_to|to_string)
value: (try_emplace|from_json|to_json|equal_to|to_string,DToString|NToString|FToString|LToString)
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: 1
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
Expand Down
6 changes: 1 addition & 5 deletions include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ struct HasNoConfigurationType;
template <typename AnalysisDomainTy,
typename Container = std::set<typename AnalysisDomainTy::d_t>>
class IDETabulationProblem : public FlowFunctions<AnalysisDomainTy, Container>,
public NodePrinter<AnalysisDomainTy>,
public DataFlowFactPrinter<AnalysisDomainTy>,
public FunctionPrinter<AnalysisDomainTy>,
public EdgeFunctions<AnalysisDomainTy>,
public JoinLattice<AnalysisDomainTy>,
public EdgeFactPrinter<AnalysisDomainTy> {
public JoinLattice<AnalysisDomainTy> {
public:
using ProblemAnalysisDomain = AnalysisDomainTy;
using d_t = typename AnalysisDomainTy::d_t;
Expand Down
4 changes: 0 additions & 4 deletions include/phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ class IFDSTabulationProblem
}

EdgeFunction<l_t> allTopFunction() final { return AllTop<l_t>{}; }

void printEdgeFact(llvm::raw_ostream &OS, BinaryDomain Val) const final {
OS << Val;
}
};
} // namespace psr

Expand Down
2 changes: 1 addition & 1 deletion include/phasar/DataFlow/IfdsIde/InitialSeeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ template <typename N, typename D, typename L> class InitialSeeds {
}

void addSeed(N Node, D Fact, L Value) {
Seeds[Node][Fact] = std::move(Value);
Seeds[std::move(Node)].insert_or_assign(std::move(Fact), std::move(Value));
}

[[nodiscard]] size_t countInitialSeeds() const {
Expand Down
103 changes: 38 additions & 65 deletions include/phasar/DataFlow/IfdsIde/Solver/FlowEdgeFunctionCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ class FlowEdgeFunctionCache {
PAMM_GET_INSTANCE;
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Normal flow function factory call");
PHASAR_LOG_LEVEL(DEBUG, "(N) Curr Inst : " << Problem.NtoString(Curr));
PHASAR_LOG_LEVEL(DEBUG, "(N) Succ Inst : " << Problem.NtoString(Succ)));
PHASAR_LOG_LEVEL(DEBUG, "(N) Curr Inst : " << NToString(Curr));
PHASAR_LOG_LEVEL(DEBUG, "(N) Succ Inst : " << NToString(Succ)));
auto Key = createEdgeFunctionInstKey(Curr, Succ);
auto SearchNormalFlowFunction = NormalFunctionCache.find(Key);
if (SearchNormalFlowFunction != NormalFunctionCache.end()) {
Expand Down Expand Up @@ -218,11 +218,10 @@ class FlowEdgeFunctionCache {

FlowFunctionPtrType getCallFlowFunction(n_t CallSite, f_t DestFun) {
PAMM_GET_INSTANCE;
IF_LOG_ENABLED(PHASAR_LOG_LEVEL(DEBUG, "Call flow function factory call");
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Stmt : "
<< Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(
DEBUG, "(F) Dest Fun : " << Problem.FtoString(DestFun)));
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Call flow function factory call");
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Stmt : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG, "(F) Dest Fun : " << FToString(DestFun)));
auto Key = std::tie(CallSite, DestFun);
auto SearchCallFlowFunction = CallFlowFunctionCache.find(Key);
if (SearchCallFlowFunction != CallFlowFunctionCache.end()) {
Expand All @@ -245,14 +244,10 @@ class FlowEdgeFunctionCache {
PAMM_GET_INSTANCE;
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Return flow function factory call");
PHASAR_LOG_LEVEL(DEBUG,
"(N) Call Site : " << Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(DEBUG,
"(F) Callee : " << Problem.FtoString(CalleeFun));
PHASAR_LOG_LEVEL(DEBUG,
"(N) Exit Stmt : " << Problem.NtoString(ExitInst));
PHASAR_LOG_LEVEL(DEBUG,
"(N) Ret Site : " << Problem.NtoString(RetSite)));
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Site : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG, "(F) Callee : " << FToString(CalleeFun));
PHASAR_LOG_LEVEL(DEBUG, "(N) Exit Stmt : " << NToString(ExitInst));
PHASAR_LOG_LEVEL(DEBUG, "(N) Ret Site : " << NToString(RetSite)));
auto Key = std::tie(CallSite, CalleeFun, ExitInst, RetSite);
auto SearchReturnFlowFunction = ReturnFlowFunctionCache.find(Key);
if (SearchReturnFlowFunction != ReturnFlowFunctionCache.end()) {
Expand All @@ -279,13 +274,11 @@ class FlowEdgeFunctionCache {
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Call-to-Return flow function factory call");

PHASAR_LOG_LEVEL(DEBUG,
"(N) Call Site : " << Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(DEBUG,
"(N) Ret Site : " << Problem.NtoString(RetSite));
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Site : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG, "(N) Ret Site : " << NToString(RetSite));
PHASAR_LOG_LEVEL(DEBUG, "(F) Callee's : "); for (auto callee
: Callees) {
PHASAR_LOG_LEVEL(DEBUG, " " << Problem.FtoString(callee));
PHASAR_LOG_LEVEL(DEBUG, " " << FToString(callee));
};);
auto Key = std::tie(CallSite, RetSite);
auto SearchCallToRetFlowFunction = CallToRetFlowFunctionCache.find(Key);
Expand All @@ -311,10 +304,8 @@ class FlowEdgeFunctionCache {
// INC_COUNTER("Summary-FF Construction", 1, PAMM_SEVERITY_LEVEL::Full);
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Summary flow function factory call");
PHASAR_LOG_LEVEL(DEBUG,
"(N) Call Stmt : " << Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(DEBUG,
"(F) Dest Mthd : " << Problem.FtoString(DestFun));
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Stmt : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG, "(F) Dest Mthd : " << FToString(DestFun));
PHASAR_LOG_LEVEL(DEBUG, ' '));
auto FF = Problem.getSummaryFlowFunction(CallSite, DestFun);
return FF;
Expand All @@ -325,12 +316,10 @@ class FlowEdgeFunctionCache {
PAMM_GET_INSTANCE;
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Normal edge function factory call");
PHASAR_LOG_LEVEL(DEBUG, "(N) Curr Inst : " << Problem.NtoString(Curr));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Curr Node : " << Problem.DtoString(CurrNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Succ Inst : " << Problem.NtoString(Succ));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Succ Node : " << Problem.DtoString(SuccNode)));
PHASAR_LOG_LEVEL(DEBUG, "(N) Curr Inst : " << NToString(Curr));
PHASAR_LOG_LEVEL(DEBUG, "(D) Curr Node : " << DToString(CurrNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Succ Inst : " << NToString(Succ));
PHASAR_LOG_LEVEL(DEBUG, "(D) Succ Node : " << DToString(SuccNode)));

EdgeFuncInstKey OuterMapKey = createEdgeFunctionInstKey(Curr, Succ);
auto SearchInnerMap = NormalFunctionCache.find(OuterMapKey);
Expand Down Expand Up @@ -371,15 +360,12 @@ class FlowEdgeFunctionCache {
PAMM_GET_INSTANCE;
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Call edge function factory call");
PHASAR_LOG_LEVEL(DEBUG,
"(N) Call Stmt : " << Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Src Node : " << Problem.DtoString(SrcNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Stmt : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG, "(D) Src Node : " << DToString(SrcNode));

PHASAR_LOG_LEVEL(
DEBUG, "(F) Dest Fun : " << Problem.FtoString(DestinationFunction));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Dest Node : " << Problem.DtoString(DestNode)));
"(F) Dest Fun : " << FToString(DestinationFunction));
PHASAR_LOG_LEVEL(DEBUG, "(D) Dest Node : " << DToString(DestNode)));
auto Key = std::tie(CallSite, SrcNode, DestinationFunction, DestNode);
auto SearchCallEdgeFunction = CallEdgeFunctionCache.find(Key);
if (SearchCallEdgeFunction != CallEdgeFunctionCache.end()) {
Expand All @@ -404,18 +390,13 @@ class FlowEdgeFunctionCache {
PAMM_GET_INSTANCE;
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Return edge function factory call");
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Site : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG,
"(N) Call Site : " << Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(
DEBUG, "(F) Callee : " << Problem.FtoString(CalleeFunction));
PHASAR_LOG_LEVEL(DEBUG,
"(N) Exit Stmt : " << Problem.NtoString(ExitInst));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Exit Node : " << Problem.DtoString(ExitNode));
PHASAR_LOG_LEVEL(DEBUG,
"(N) Ret Site : " << Problem.NtoString(RetSite));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Ret Node : " << Problem.DtoString(RetNode)));
"(F) Callee : " << FToString(CalleeFunction));
PHASAR_LOG_LEVEL(DEBUG, "(N) Exit Stmt : " << NToString(ExitInst));
PHASAR_LOG_LEVEL(DEBUG, "(D) Exit Node : " << DToString(ExitNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Ret Site : " << NToString(RetSite));
PHASAR_LOG_LEVEL(DEBUG, "(D) Ret Node : " << DToString(RetNode)));
auto Key = std::tie(CallSite, CalleeFunction, ExitInst, ExitNode, RetSite,
RetNode);
auto SearchReturnEdgeFunction = ReturnEdgeFunctionCache.find(Key);
Expand All @@ -442,18 +423,14 @@ class FlowEdgeFunctionCache {
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Call-to-Return edge function factory call");

PHASAR_LOG_LEVEL(DEBUG,
"(N) Call Site : " << Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Call Node : " << Problem.DtoString(CallNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Site : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG, "(D) Call Node : " << DToString(CallNode));

PHASAR_LOG_LEVEL(DEBUG,
"(N) Ret Site : " << Problem.NtoString(RetSite));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Ret Node : " << Problem.DtoString(RetSiteNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Ret Site : " << NToString(RetSite));
PHASAR_LOG_LEVEL(DEBUG, "(D) Ret Node : " << DToString(RetSiteNode));
PHASAR_LOG_LEVEL(DEBUG, "(F) Callee's : "); for (auto callee
: Callees) {
PHASAR_LOG_LEVEL(DEBUG, " " << Problem.FtoString(callee));
PHASAR_LOG_LEVEL(DEBUG, " " << FToString(callee));
});

EdgeFuncInstKey OuterMapKey = createEdgeFunctionInstKey(CallSite, RetSite);
Expand Down Expand Up @@ -498,14 +475,10 @@ class FlowEdgeFunctionCache {
PAMM_GET_INSTANCE;
IF_LOG_ENABLED(
PHASAR_LOG_LEVEL(DEBUG, "Summary edge function factory call");
PHASAR_LOG_LEVEL(DEBUG,
"(N) Call Site : " << Problem.NtoString(CallSite));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Call Node : " << Problem.DtoString(CallNode));
PHASAR_LOG_LEVEL(DEBUG,
"(N) Ret Site : " << Problem.NtoString(RetSite));
PHASAR_LOG_LEVEL(DEBUG,
"(D) Ret Node : " << Problem.DtoString(RetSiteNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Call Site : " << NToString(CallSite));
PHASAR_LOG_LEVEL(DEBUG, "(D) Call Node : " << DToString(CallNode));
PHASAR_LOG_LEVEL(DEBUG, "(N) Ret Site : " << NToString(RetSite));
PHASAR_LOG_LEVEL(DEBUG, "(D) Ret Node : " << DToString(RetSiteNode));
PHASAR_LOG_LEVEL(DEBUG, ' '));
auto Key = std::tie(CallSite, CallNode, RetSite, RetSiteNode);
auto SearchSummaryEdgeFunction = SummaryEdgeFunctionCache.find(Key);
Expand Down
Loading
Loading