Skip to content

Commit 2640f29

Browse files
Martin Moryvulder
authored andcommitted
clang-tidy fixes for IDEGeneralizedLCA
1 parent 70fb317 commit 2640f29

23 files changed

Lines changed: 843 additions & 791 deletions

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEGeneralizedLCA/AllBot.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ namespace psr {
1818
struct AllBot {
1919
using type = AllBottom<IDEGeneralizedLCA::l_t>;
2020
static std::shared_ptr<type> getInstance();
21-
static bool isBot(const EdgeFunction<IDEGeneralizedLCA::l_t> *edgeFn,
22-
bool nonRec = false);
21+
static bool isBot(const EdgeFunction<IDEGeneralizedLCA::l_t> *EdgeFn,
22+
bool NonRec = false);
2323
static bool
24-
isBot(const std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> &edgeFn,
25-
bool nonRec = false);
24+
isBot(const std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> &EdgeFn,
25+
bool NonRec = false);
2626
};
2727

2828
} // namespace psr

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEGeneralizedLCA/BinaryEdgeFunction.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ namespace psr {
1919
class BinaryEdgeFunction
2020
: public EdgeFunction<IDEGeneralizedLCA::l_t>,
2121
public std::enable_shared_from_this<BinaryEdgeFunction> {
22-
llvm::BinaryOperator::BinaryOps op;
23-
const IDEGeneralizedLCA::l_t cnst;
24-
bool leftConst;
25-
size_t maxSize;
22+
llvm::BinaryOperator::BinaryOps Op;
23+
const IDEGeneralizedLCA::l_t Const;
24+
bool LeftConst;
25+
size_t MaxSize;
2626

2727
public:
28-
BinaryEdgeFunction(llvm::BinaryOperator::BinaryOps op,
29-
const IDEGeneralizedLCA::l_t &cnst, bool leftConst,
30-
size_t maxSize)
31-
: op(op), cnst(cnst), leftConst(leftConst), maxSize(maxSize) {}
28+
BinaryEdgeFunction(llvm::BinaryOperator::BinaryOps Op,
29+
const IDEGeneralizedLCA::l_t &Const, bool LeftConst,
30+
size_t MaxSize)
31+
: Op(Op), Const(Const), LeftConst(LeftConst), MaxSize(MaxSize) {}
3232

33-
IDEGeneralizedLCA::l_t computeTarget(IDEGeneralizedLCA::l_t source) override;
33+
IDEGeneralizedLCA::l_t computeTarget(IDEGeneralizedLCA::l_t Source) override;
3434

3535
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> composeWith(
36-
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> secondFunction)
36+
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> SecondFunction)
3737
override;
3838

3939
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>>
40-
joinWith(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> otherFunction)
40+
joinWith(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> OtherFunction)
4141
override;
4242

43-
bool equal_to(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> other)
43+
bool equal_to(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> Other)
4444
const override;
4545

46-
void print(std::ostream &OS, bool isForDebug = false) const override;
46+
void print(std::ostream &OS, bool IsForDebug = false) const override;
4747
};
4848

4949
} // namespace psr

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEGeneralizedLCA/EdgeValue.h

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -29,91 +29,94 @@ class EdgeValue {
2929
enum Type { Top, Integer, String, FloatingPoint };
3030

3131
private:
32-
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t> value =
33-
nullptr;
34-
Type type;
32+
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t>
33+
ValVariant = nullptr;
34+
Type VariantType;
3535

3636
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 d);
45-
EdgeValue(float d);
46-
EdgeValue(std::string &&vs);
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);
4747
EdgeValue(std::nullptr_t);
4848
~EdgeValue();
49-
const static EdgeValue top;
50-
bool tryGetInt(uint64_t &res) const;
51-
bool tryGetFP(double &res) const;
52-
bool tryGetString(std::string &res) const;
53-
bool isTop() const;
54-
bool isNumeric() const;
55-
bool isString() const;
56-
Type getKind() const;
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;
5757
// std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const;
58-
bool sqSubsetEq(const EdgeValue &other) const;
59-
EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps op,
60-
const EdgeValue &other) const;
61-
EdgeValue typecast(Type dest, unsigned bits) const;
62-
EdgeValue &operator=(const EdgeValue &ev);
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);
6363

6464
operator bool();
65-
friend bool operator==(const EdgeValue &v1, const EdgeValue &v2);
65+
friend bool operator==(const EdgeValue &Lhs, const EdgeValue &Rhs);
6666

6767
// binary operators
68-
friend EdgeValue operator+(const EdgeValue &v1, const EdgeValue &v2);
69-
friend EdgeValue operator-(const EdgeValue &v1, const EdgeValue &v2);
70-
friend EdgeValue operator*(const EdgeValue &v1, const EdgeValue &v2);
71-
friend EdgeValue operator/(const EdgeValue &v1, const EdgeValue &v2);
72-
friend EdgeValue operator%(const EdgeValue &v1, const EdgeValue &v2);
73-
friend EdgeValue operator&(const EdgeValue &v1, const EdgeValue &v2);
74-
friend EdgeValue operator|(const EdgeValue &v1, const EdgeValue &v2);
75-
friend EdgeValue operator^(const EdgeValue &v1, const EdgeValue &v2);
76-
friend EdgeValue operator<<(const EdgeValue &v1, const EdgeValue &v2);
77-
friend EdgeValue operator>>(const EdgeValue &v1, const EdgeValue &v2);
78-
static int compare(const EdgeValue &v1, const EdgeValue &v2);
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);
7979

8080
// unary operators
8181
EdgeValue operator-() const;
8282
EdgeValue operator~() const;
83-
friend std::ostream &operator<<(std::ostream &os, const EdgeValue &ev);
84-
static std::string typeToString(Type ty);
83+
friend std::ostream &operator<<(std::ostream &Os, const EdgeValue &EV);
84+
static std::string typeToString(Type Ty);
8585
};
8686
class EdgeValueSet;
8787
typedef EdgeValueSet ev_t;
8888

89-
ev_t performBinOp(llvm::BinaryOperator::BinaryOps op, const ev_t &v1,
90-
const ev_t &v2, size_t maxSize);
91-
ev_t performTypecast(const ev_t &ev, EdgeValue::Type dest, unsigned bits);
92-
Ordering compare(const ev_t &v1, const ev_t &v2);
93-
ev_t join(const ev_t &v1, const ev_t &v2, size_t maxSize);
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);
9494
/// \brief implements square subset equal
95-
bool operator<(const ev_t &v1, const ev_t &v2);
96-
bool isTopValue(const ev_t &v);
97-
std::ostream &operator<<(std::ostream &os, const ev_t &v);
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);
9898

9999
} // namespace psr
100100

101101
namespace std {
102102

103103
template <> struct hash<psr::EdgeValue> {
104-
hash() {}
105-
size_t operator()(const psr::EdgeValue &val) const {
106-
auto hc = 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 + hc;
112-
else if (val.tryGetFP(asFloat))
113-
return hash<double>()(round(asFloat)) * 31 + hc;
114-
else if (val.tryGetString(asString))
115-
return hash<string>()(asString) * 31 + hc;
116-
return hc;
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;
117120
}
118121
};
119122

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEGeneralizedLCA/EdgeValueSet.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@
1818
namespace psr {
1919

2020
class EdgeValueSet {
21-
std::unordered_set<EdgeValue> underlying;
21+
std::unordered_set<EdgeValue> Underlying;
2222

2323
public:
2424
EdgeValueSet();
2525
template <typename Iter>
26-
EdgeValueSet(Iter beg, Iter ed) : underlying(beg, ed) {}
27-
EdgeValueSet(std::initializer_list<EdgeValue> ilist);
28-
auto begin() -> decltype(underlying.begin());
29-
auto end() -> decltype(underlying.end());
30-
auto begin() const -> decltype(underlying.begin());
31-
auto end() const -> decltype(underlying.end());
32-
int count(const EdgeValue &ev) const;
33-
auto find(const EdgeValue &ev) -> decltype(underlying.find(ev));
34-
auto find(const EdgeValue &ev) const -> decltype(underlying.find(ev));
26+
EdgeValueSet(Iter Begin, Iter End) : Underlying(Begin, End) {}
27+
EdgeValueSet(std::initializer_list<EdgeValue> IList);
28+
auto begin() -> decltype(Underlying.begin());
29+
auto end() -> decltype(Underlying.end());
30+
auto begin() const -> decltype(Underlying.begin());
31+
auto end() const -> decltype(Underlying.end());
32+
int count(const EdgeValue &EV) const;
33+
auto find(const EdgeValue &EV) -> decltype(Underlying.find(EV));
34+
auto find(const EdgeValue &EV) const -> decltype(Underlying.find(EV));
3535

3636
size_t size() const;
37-
auto insert(const EdgeValue &ev) -> decltype(underlying.insert(ev));
38-
auto insert(EdgeValue &&ev) -> decltype(underlying.insert(ev));
37+
auto insert(const EdgeValue &EV) -> decltype(Underlying.insert(EV));
38+
auto insert(EdgeValue &&EV) -> decltype(Underlying.insert(EV));
3939
bool empty() const;
40-
bool operator==(const EdgeValueSet &other) const;
41-
bool operator!=(const EdgeValueSet &other) const;
40+
bool operator==(const EdgeValueSet &Other) const;
41+
bool operator!=(const EdgeValueSet &Other) const;
4242
};
4343

4444
} // namespace psr

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEGeneralizedLCA/GenConstant.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ namespace psr {
1717

1818
class GenConstant : public EdgeFunction<IDEGeneralizedLCA::l_t>,
1919
public std::enable_shared_from_this<GenConstant> {
20-
IDEGeneralizedLCA::l_t val;
21-
size_t maxSize;
20+
IDEGeneralizedLCA::l_t Val;
21+
size_t MaxSize;
2222

2323
public:
24-
GenConstant(const IDEGeneralizedLCA::l_t &val, size_t maxSize);
25-
IDEGeneralizedLCA::l_t computeTarget(IDEGeneralizedLCA::l_t source) override;
24+
GenConstant(const IDEGeneralizedLCA::l_t &Val, size_t MaxSize);
25+
IDEGeneralizedLCA::l_t computeTarget(IDEGeneralizedLCA::l_t Source) override;
2626

2727
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> composeWith(
28-
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> secondFunction)
28+
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> SecondFunction)
2929
override;
3030

3131
std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>>
32-
joinWith(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> otherFunction)
32+
joinWith(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> OtherFunction)
3333
override;
3434

35-
bool equal_to(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> other)
35+
bool equal_to(std::shared_ptr<EdgeFunction<IDEGeneralizedLCA::l_t>> Other)
3636
const override;
37-
void print(std::ostream &OS, bool isForDebug = false) const override;
37+
void print(std::ostream &OS, bool IsForDebug = false) const override;
3838
};
3939

4040
} // namespace psr

0 commit comments

Comments
 (0)