Skip to content

Commit 1939bca

Browse files
authored
Merge branch 'development' into f-LCAImprovements
2 parents 732a7cd + 61a8aad commit 1939bca

88 files changed

Lines changed: 2366 additions & 2286 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Checks: '-*,
1616
-readability-convert-member-functions-to-static,
1717
-readability-isolate-declaration,
1818
cppcoreguidelines-*,
19+
-cppcoreguidelines-avoid-non-const-global-variables,
1920
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
2021
-cppcoreguidelines-owning-memory,
2122
-cppcoreguidelines-pro-type-reinterpret-cast,
@@ -53,6 +54,8 @@ CheckOptions:
5354
value: (c|d|d1|d2|d3|d4|d5|d5_restoredCtx|eP|f|f3|f4|f5|fCalleeSummary|g|n|dPrime|fPrime)
5455
- key: readability-identifier-naming.ParameterIgnoredRegexp
5556
value: (d|d1|d2|d3|d4|d5|eP|f|n)
57+
- key: readability-identifier-naming.FunctionIgnoredRegexp
58+
value: (try_emplace|from_json|to_json)
5659
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
5760
value: 1
5861
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ class LLVMBasedICFG
321321

322322
template <typename Fn> void forEachGlobalCtor(Fn &&F) const {
323323
for (auto [Prio, Fun] : GlobalCtors) {
324-
F(static_cast<const llvm::Function *>(Fun));
324+
std::invoke(F, static_cast<const llvm::Function *>(Fun));
325325
}
326326
}
327327

328328
template <typename Fn> void forEachGlobalDtor(Fn &&F) const {
329329
for (auto [Prio, Fun] : GlobalDtors) {
330-
F(static_cast<const llvm::Function *>(Fun));
330+
std::invoke(F, static_cast<const llvm::Function *>(Fun));
331331
}
332332
}
333333

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/FlowFunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class GenIf : public FlowFunction<D, Container> {
185185
: GenValues({GenValue}), Predicate(std::move(Predicate)) {}
186186

187187
GenIf(container_type GenValues, std::function<bool(D)> Predicate)
188-
: GenValues(std::move(GenValues)), Predicate(Predicate) {}
188+
: GenValues(std::move(GenValues)), Predicate(std::move(Predicate)) {}
189189

190190
~GenIf() override = default;
191191

Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,125 @@
1-
/******************************************************************************
2-
* Copyright (c) 2020 Fabian Schiebel.
3-
* All rights reserved. This program and the accompanying materials are made
4-
* available under the terms of LICENSE.txt.
5-
*
6-
* Contributors:
7-
* Fabian Schiebel, Alexander Meinhold and others
8-
*****************************************************************************/
9-
10-
#ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H_
11-
#define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H_
12-
13-
#include <iostream>
14-
#include <memory>
15-
#include <unordered_set>
16-
#include <variant>
17-
18-
#include "llvm/ADT/APSInt.h"
19-
#include "llvm/ADT/Twine.h"
20-
#include "llvm/IR/Constant.h"
21-
#include "llvm/IR/Instructions.h"
22-
23-
namespace psr {
24-
25-
enum class Ordering { Less, Greater, Equal, Incomparable };
26-
27-
class EdgeValue {
28-
public:
29-
enum Type { Top, Integer, String, FloatingPoint };
30-
31-
private:
32-
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t>
33-
ValVariant = nullptr;
34-
Type VariantType;
35-
36-
public:
37-
EdgeValue(const llvm::Value *Val);
38-
EdgeValue(const EdgeValue &EV);
39-
EdgeValue(llvm::APInt &&VI);
40-
EdgeValue(const llvm::APInt &VI);
41-
EdgeValue(llvm::APFloat &&VF);
42-
EdgeValue(long long VI);
43-
EdgeValue(int VI);
44-
EdgeValue(double Double);
45-
EdgeValue(float Float);
46-
EdgeValue(std::string &&VS);
47-
EdgeValue(std::nullptr_t);
48-
~EdgeValue();
49-
const static EdgeValue TopValue;
50-
[[nodiscard]] bool tryGetInt(uint64_t &Res) const;
51-
[[nodiscard]] bool tryGetFP(double &Res) const;
52-
[[nodiscard]] bool tryGetString(std::string &Res) const;
53-
[[nodiscard]] bool isTop() const;
54-
[[nodiscard]] bool isNumeric() const;
55-
[[nodiscard]] bool isString() const;
56-
[[nodiscard]] Type getKind() const;
57-
// std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const;
58-
[[nodiscard]] bool sqSubsetEq(const EdgeValue &Other) const;
59-
[[nodiscard]] EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps Op,
60-
const EdgeValue &Other) const;
61-
[[nodiscard]] EdgeValue typecast(Type Dest, unsigned Bits) const;
62-
EdgeValue &operator=(const EdgeValue &EV);
63-
64-
operator bool();
65-
friend bool operator==(const EdgeValue &Lhs, const EdgeValue &Rhs);
66-
67-
// binary operators
68-
friend EdgeValue operator+(const EdgeValue &Lhs, const EdgeValue &Rhs);
69-
friend EdgeValue operator-(const EdgeValue &Lhs, const EdgeValue &Rhs);
70-
friend EdgeValue operator*(const EdgeValue &Lhs, const EdgeValue &Rhs);
71-
friend EdgeValue operator/(const EdgeValue &Lhs, const EdgeValue &Rhs);
72-
friend EdgeValue operator%(const EdgeValue &Lhs, const EdgeValue &Rhs);
73-
friend EdgeValue operator&(const EdgeValue &Lhs, const EdgeValue &Rhs);
74-
friend EdgeValue operator|(const EdgeValue &Lhs, const EdgeValue &Rhs);
75-
friend EdgeValue operator^(const EdgeValue &Lhs, const EdgeValue &Rhs);
76-
friend EdgeValue operator<<(const EdgeValue &Lhs, const EdgeValue &Rhs);
77-
friend EdgeValue operator>>(const EdgeValue &Lhs, const EdgeValue &Rhs);
78-
static int compare(const EdgeValue &Lhs, const EdgeValue &Rhs);
79-
80-
// unary operators
81-
EdgeValue operator-() const;
82-
EdgeValue operator~() const;
83-
friend std::ostream &operator<<(std::ostream &Os, const EdgeValue &EV);
84-
static std::string typeToString(Type Ty);
85-
};
86-
class EdgeValueSet;
87-
typedef EdgeValueSet ev_t;
88-
89-
ev_t performBinOp(llvm::BinaryOperator::BinaryOps Op, const ev_t &Lhs,
90-
const ev_t &Rhs, size_t MaxSize);
91-
ev_t performTypecast(const ev_t &Ev, EdgeValue::Type Dest, unsigned Bits);
92-
Ordering compare(const ev_t &Lhs, const ev_t &Rhs);
93-
ev_t join(const ev_t &Lhs, const ev_t &Rhs, size_t MaxSize);
94-
/// \brief implements square subset equal
95-
bool operator<(const ev_t &Lhs, const ev_t &Rhs);
96-
bool isTopValue(const ev_t &Val);
97-
std::ostream &operator<<(std::ostream &Os, const ev_t &Val);
98-
99-
} // namespace psr
100-
101-
namespace std {
102-
103-
template <> struct hash<psr::EdgeValue> {
104-
hash() = default;
105-
size_t operator()(const psr::EdgeValue &Val) const {
106-
auto Hash = hash<int>()(Val.getKind());
107-
uint64_t AsInt;
108-
double AsFloat;
109-
string AsString;
110-
if (Val.tryGetInt(AsInt)) {
111-
return hash<uint64_t>()(AsInt) * 31 + Hash;
112-
}
113-
if (Val.tryGetFP(AsFloat)) {
114-
return hash<double>()(round(AsFloat)) * 31 + Hash;
115-
}
116-
if (Val.tryGetString(AsString)) {
117-
return hash<string>()(AsString) * 31 + Hash;
118-
}
119-
return Hash;
120-
}
121-
};
122-
123-
} // namespace std
124-
125-
#endif
1+
/******************************************************************************
2+
* Copyright (c) 2020 Fabian Schiebel.
3+
* All rights reserved. This program and the accompanying materials are made
4+
* available under the terms of LICENSE.txt.
5+
*
6+
* Contributors:
7+
* Fabian Schiebel, Alexander Meinhold and others
8+
*****************************************************************************/
9+
10+
#ifndef PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H
11+
#define PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H
12+
13+
#include <iostream>
14+
#include <memory>
15+
#include <unordered_set>
16+
#include <variant>
17+
18+
#include "llvm/ADT/APSInt.h"
19+
#include "llvm/ADT/Twine.h"
20+
#include "llvm/IR/Constant.h"
21+
#include "llvm/IR/Instructions.h"
22+
23+
namespace psr {
24+
25+
enum class Ordering { Less, Greater, Equal, Incomparable };
26+
27+
class EdgeValue {
28+
public:
29+
enum Type { Top, Integer, String, FloatingPoint };
30+
31+
private:
32+
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t>
33+
ValVariant = nullptr;
34+
Type VariantType;
35+
36+
public:
37+
EdgeValue(const llvm::Value *Val);
38+
EdgeValue(const EdgeValue &EV);
39+
EdgeValue(llvm::APInt &&VI);
40+
EdgeValue(const llvm::APInt &VI);
41+
EdgeValue(llvm::APFloat &&VF);
42+
EdgeValue(long long VI);
43+
EdgeValue(int VI);
44+
EdgeValue(double Double);
45+
EdgeValue(float Float);
46+
EdgeValue(std::string &&VS);
47+
EdgeValue(std::nullptr_t);
48+
~EdgeValue();
49+
const static EdgeValue TopValue;
50+
[[nodiscard]] bool tryGetInt(uint64_t &Res) const;
51+
[[nodiscard]] bool tryGetFP(double &Res) const;
52+
[[nodiscard]] bool tryGetString(std::string &Res) const;
53+
[[nodiscard]] bool isTop() const;
54+
[[nodiscard]] bool isNumeric() const;
55+
[[nodiscard]] bool isString() const;
56+
[[nodiscard]] Type getKind() const;
57+
// std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const;
58+
[[nodiscard]] bool sqSubsetEq(const EdgeValue &Other) const;
59+
[[nodiscard]] EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps Op,
60+
const EdgeValue &Other) const;
61+
[[nodiscard]] EdgeValue typecast(Type Dest, unsigned Bits) const;
62+
EdgeValue &operator=(const EdgeValue &EV);
63+
64+
operator bool();
65+
friend bool operator==(const EdgeValue &Lhs, const EdgeValue &Rhs);
66+
67+
// binary operators
68+
friend EdgeValue operator+(const EdgeValue &Lhs, const EdgeValue &Rhs);
69+
friend EdgeValue operator-(const EdgeValue &Lhs, const EdgeValue &Rhs);
70+
friend EdgeValue operator*(const EdgeValue &Lhs, const EdgeValue &Rhs);
71+
friend EdgeValue operator/(const EdgeValue &Lhs, const EdgeValue &Rhs);
72+
friend EdgeValue operator%(const EdgeValue &Lhs, const EdgeValue &Rhs);
73+
friend EdgeValue operator&(const EdgeValue &Lhs, const EdgeValue &Rhs);
74+
friend EdgeValue operator|(const EdgeValue &Lhs, const EdgeValue &Rhs);
75+
friend EdgeValue operator^(const EdgeValue &Lhs, const EdgeValue &Rhs);
76+
friend EdgeValue operator<<(const EdgeValue &Lhs, const EdgeValue &Rhs);
77+
friend EdgeValue operator>>(const EdgeValue &Lhs, const EdgeValue &Rhs);
78+
static int compare(const EdgeValue &Lhs, const EdgeValue &Rhs);
79+
80+
// unary operators
81+
EdgeValue operator-() const;
82+
EdgeValue operator~() const;
83+
friend std::ostream &operator<<(std::ostream &Os, const EdgeValue &EV);
84+
static std::string typeToString(Type Ty);
85+
};
86+
class EdgeValueSet;
87+
using ev_t = EdgeValueSet;
88+
89+
ev_t performBinOp(llvm::BinaryOperator::BinaryOps Op, const ev_t &Lhs,
90+
const ev_t &Rhs, size_t MaxSize);
91+
ev_t performTypecast(const ev_t &Ev, EdgeValue::Type Dest, unsigned Bits);
92+
Ordering compare(const ev_t &Lhs, const ev_t &Rhs);
93+
ev_t join(const ev_t &Lhs, const ev_t &Rhs, size_t MaxSize);
94+
/// \brief implements square subset equal
95+
bool operator<(const ev_t &Lhs, const ev_t &Rhs);
96+
bool isTopValue(const ev_t &Val);
97+
std::ostream &operator<<(std::ostream &Os, const ev_t &Val);
98+
99+
} // namespace psr
100+
101+
namespace std {
102+
103+
template <> struct hash<psr::EdgeValue> {
104+
hash() = default;
105+
size_t operator()(const psr::EdgeValue &Val) const {
106+
auto Hash = hash<int>()(Val.getKind());
107+
uint64_t AsInt;
108+
double AsFloat;
109+
string AsString;
110+
if (Val.tryGetInt(AsInt)) {
111+
return hash<uint64_t>()(AsInt) * 31 + Hash;
112+
}
113+
if (Val.tryGetFP(AsFloat)) {
114+
return hash<double>()(round(AsFloat)) * 31 + Hash;
115+
}
116+
if (Val.tryGetString(AsString)) {
117+
return hash<string>()(AsString) * 31 + Hash;
118+
}
119+
return Hash;
120+
}
121+
};
122+
123+
} // namespace std
124+
125+
#endif

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEProtoAnalysis.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,76 +55,76 @@ class IDEProtoAnalysis : public IDETabulationProblem<IDEProtoAnalysisDomain> {
5555

5656
// start formulating our analysis by specifying the parts required for IFDS
5757

58-
FlowFunctionPtrType getNormalFlowFunction(n_t curr, n_t succ) override;
58+
FlowFunctionPtrType getNormalFlowFunction(n_t Curr, n_t Succ) override;
5959

60-
FlowFunctionPtrType getCallFlowFunction(n_t callSite, f_t destFun) override;
60+
FlowFunctionPtrType getCallFlowFunction(n_t CallSite, f_t DestFun) override;
6161

62-
FlowFunctionPtrType getRetFlowFunction(n_t callSite, f_t calleeFun,
63-
n_t exitInst, n_t retSite) override;
62+
FlowFunctionPtrType getRetFlowFunction(n_t CallSite, f_t CalleeFun,
63+
n_t ExitInst, n_t RetSite) override;
6464

65-
FlowFunctionPtrType getCallToRetFlowFunction(n_t callSite, n_t retSite,
66-
std::set<f_t> callees) override;
65+
FlowFunctionPtrType getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
66+
std::set<f_t> Callees) override;
6767

68-
FlowFunctionPtrType getSummaryFlowFunction(n_t callSite,
69-
f_t destFun) override;
68+
FlowFunctionPtrType getSummaryFlowFunction(n_t CallSite,
69+
f_t DestFun) override;
7070

7171
InitialSeeds<n_t, d_t, l_t> initialSeeds() override;
7272

7373
[[nodiscard]] d_t createZeroValue() const override;
7474

75-
bool isZeroValue(d_t d) const override;
75+
bool isZeroValue(d_t Fact) const override;
7676

7777
// in addition provide specifications for the IDE parts
7878

7979
std::shared_ptr<EdgeFunction<l_t>>
80-
getNormalEdgeFunction(n_t curr, d_t currNode, n_t succ,
81-
d_t succNode) override;
80+
getNormalEdgeFunction(n_t Curr, d_t CurrNode, n_t Succ,
81+
d_t SuccNode) override;
8282

8383
std::shared_ptr<EdgeFunction<l_t>>
84-
getCallEdgeFunction(n_t callSite, d_t srcNode, f_t destinationFunction,
85-
d_t destNode) override;
84+
getCallEdgeFunction(n_t CallSite, d_t SrcNode, f_t DestinationFunction,
85+
d_t DestNode) override;
8686

8787
std::shared_ptr<EdgeFunction<l_t>>
88-
getReturnEdgeFunction(n_t callSite, f_t calleeFunction, n_t exitInst,
89-
d_t exitNode, n_t reSite, d_t retNode) override;
88+
getReturnEdgeFunction(n_t CallSite, f_t CalleeFunction, n_t ExitInst,
89+
d_t ExitNode, n_t RetSite, d_t RetNode) override;
9090

9191
std::shared_ptr<EdgeFunction<l_t>>
92-
getCallToRetEdgeFunction(n_t callSite, d_t callNode, n_t retSite,
93-
d_t retSiteNode, std::set<f_t> callees) override;
92+
getCallToRetEdgeFunction(n_t CallSite, d_t CallNode, n_t RetSite,
93+
d_t RetSiteNode, std::set<f_t> Callees) override;
9494

9595
std::shared_ptr<EdgeFunction<l_t>>
96-
getSummaryEdgeFunction(n_t callSite, d_t callNode, n_t retSite,
97-
d_t retSiteNode) override;
96+
getSummaryEdgeFunction(n_t CallSite, d_t CallNode, n_t RetSite,
97+
d_t RetSiteNode) override;
9898

9999
l_t topElement() override;
100100

101101
l_t bottomElement() override;
102102

103-
l_t join(l_t lhs, l_t rhs) override;
103+
l_t join(l_t Lhs, l_t Rhs) override;
104104

105105
std::shared_ptr<EdgeFunction<l_t>> allTopFunction() override;
106106

107107
class IDEProtoAnalysisAllTop
108108
: public EdgeFunction<l_t>,
109109
public std::enable_shared_from_this<IDEProtoAnalysisAllTop> {
110-
l_t computeTarget(l_t source) override;
110+
l_t computeTarget(l_t Source) override;
111111

112112
std::shared_ptr<EdgeFunction<l_t>>
113-
composeWith(std::shared_ptr<EdgeFunction<l_t>> secondFunction) override;
113+
composeWith(std::shared_ptr<EdgeFunction<l_t>> SecondFunction) override;
114114

115115
std::shared_ptr<EdgeFunction<l_t>>
116-
joinWith(std::shared_ptr<EdgeFunction<l_t>> otherFunction) override;
116+
joinWith(std::shared_ptr<EdgeFunction<l_t>> OtherFunction) override;
117117

118-
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> other) const override;
118+
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> Other) const override;
119119
};
120120

121-
void printNode(std::ostream &os, n_t n) const override;
121+
void printNode(std::ostream &OS, n_t Stmt) const override;
122122

123-
void printDataFlowFact(std::ostream &os, d_t d) const override;
123+
void printDataFlowFact(std::ostream &OS, d_t Fact) const override;
124124

125-
void printFunction(std::ostream &os, f_t m) const override;
125+
void printFunction(std::ostream &OS, f_t Func) const override;
126126

127-
void printEdgeFact(std::ostream &os, l_t l) const override;
127+
void printEdgeFact(std::ostream &OS, l_t L) const override;
128128
};
129129

130130
} // namespace psr

0 commit comments

Comments
 (0)