Skip to content

Commit fb9b1f9

Browse files
author
Martin Mory
committed
identifier renames and further clang-tidy minor fixes of IfdsIde FF/EF helpers
1 parent 3a4f2c6 commit fb9b1f9

9 files changed

Lines changed: 385 additions & 396 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ namespace psr {
2525

2626
template <typename N, typename D> class DefaultSeeds {
2727
public:
28-
static std::map<N, std::set<D>> make(std::vector<N> node, D zeroNode) {
29-
std::map<N, std::set<D>> res;
30-
for (N n : node) {
31-
res.insert(n, std::set<D>{zeroNode});
28+
static std::map<N, std::set<D>> make(std::vector<N> Nodes, D ZeroNode) {
29+
std::map<N, std::set<D>> Result;
30+
for (N Node : Nodes) {
31+
Result.insert(Node, {ZeroNode});
3232
}
33-
return res;
33+
return Result;
3434
}
3535
};
3636

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace psr {
1919
class EdgeFact {
2020
public:
2121
virtual ~EdgeFact() = default;
22-
virtual void print(std::ostream &os) const = 0;
22+
virtual void print(std::ostream &OS) const = 0;
2323
};
2424

2525
static inline std::ostream &operator<<(std::ostream &OS, const EdgeFact &E) {

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class EdgeFunctionComposer
3939

4040
private:
4141
// For debug purpose only
42-
const unsigned EFComposer_Id;
43-
static inline unsigned CurrEFComposer_Id = 0;
42+
const unsigned EFComposerId;
43+
static inline unsigned CurrEFComposerId = 0; // NOLINT
4444

4545
protected:
4646
/// First edge function
@@ -49,17 +49,17 @@ class EdgeFunctionComposer
4949
EdgeFunctionPtrType G;
5050

5151
public:
52-
EdgeFunctionComposer(EdgeFunctionPtrType F, EdgeFunctionPtrType G)
53-
: EFComposer_Id(++CurrEFComposer_Id), F(F), G(G) {}
52+
EdgeFunctionComposer(EdgeFunctionPtrType &F, EdgeFunctionPtrType &G)
53+
: EFComposerId(++CurrEFComposerId), F(F), G(G) {}
5454

5555
~EdgeFunctionComposer() override = default;
5656

5757
/**
5858
* Target value computation is implemented as
5959
* G(F(source))
6060
*/
61-
L computeTarget(L source) override {
62-
return G->computeTarget(F->computeTarget(source));
61+
L computeTarget(L Source) override {
62+
return G->computeTarget(F->computeTarget(Source));
6363
}
6464

6565
/**
@@ -69,29 +69,30 @@ class EdgeFunctionComposer
6969
* However, it is advised to immediately reduce the resulting edge function
7070
* by providing an own implementation of this function.
7171
*/
72-
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType secondFunction) override {
73-
if (auto *EI = dynamic_cast<EdgeIdentity<L> *>(secondFunction.get())) {
72+
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType SecondFunction) override {
73+
if (auto *EI = dynamic_cast<EdgeIdentity<L> *>(SecondFunction.get())) {
7474
return this->shared_from_this();
7575
}
76-
if (auto *AB = dynamic_cast<AllBottom<L> *>(secondFunction.get())) {
76+
if (auto *AB = dynamic_cast<AllBottom<L> *>(SecondFunction.get())) {
7777
return this->shared_from_this();
7878
}
79-
return F->composeWith(G->composeWith(secondFunction));
79+
return F->composeWith(G->composeWith(SecondFunction));
8080
}
8181

8282
// virtual EdgeFunctionPtrType
8383
// joinWith(EdgeFunctionPtrType otherFunction) = 0;
8484

85-
bool equal_to(EdgeFunctionPtrType other) const override {
86-
if (auto EFC = dynamic_cast<EdgeFunctionComposer<L> *>(other.get())) {
85+
bool equal_to // NOLINT - would break too many client analyses
86+
(EdgeFunctionPtrType Other) const override {
87+
if (auto EFC = dynamic_cast<EdgeFunctionComposer<L> *>(Other.get())) {
8788
return F->equal_to(EFC->F) && G->equal_to(EFC->G);
8889
}
8990
return false;
9091
}
9192

92-
void print(std::ostream &OS, bool isForDebug = false) const override {
93+
void print(std::ostream &OS, bool /*IsForDebug = false*/) const override {
9394
OS << "COMP[ " << F.get()->str() << " , " << G.get()->str()
94-
<< " ] (EF:" << EFComposer_Id << ')';
95+
<< " ] (EF:" << EFComposerId << ')';
9596
}
9697
};
9798

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

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ template <typename L> class EdgeFunction {
6868
// jump functions that describe the effects of everlonger sequences of code.
6969
//
7070
[[nodiscard]] virtual EdgeFunctionPtrType
71-
composeWith(EdgeFunctionPtrType secondFunction) = 0;
71+
composeWith(EdgeFunctionPtrType SecondFunction) = 0;
7272

7373
//
7474
// This function describes the join of the two edge functions this and
@@ -83,7 +83,8 @@ template <typename L> class EdgeFunction {
8383
equal_to // NOLINT - would break too many client analyses
8484
(EdgeFunctionPtrType OtherFunction) const = 0;
8585

86-
virtual void print(std::ostream &OS, bool IsForDebug = false) const {
86+
virtual void print(std::ostream &OS,
87+
[[maybe_unused]] bool IsForDebug = false) const {
8788
OS << "EdgeFunction";
8889
}
8990

@@ -114,31 +115,34 @@ class AllTop : public EdgeFunction<L>,
114115
using typename EdgeFunction<L>::EdgeFunctionPtrType;
115116

116117
private:
117-
const L topElement;
118+
const L TopElement;
118119

119120
public:
120-
AllTop(L topElement) : topElement(topElement) {}
121+
AllTop(const L TopElement) : TopElement(std::move(TopElement)) {}
121122

122123
~AllTop() override = default;
123124

124-
L computeTarget(L source) override { return topElement; }
125+
L computeTarget(L /*Source*/) override { return TopElement; }
125126

126-
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType secondFunction) override {
127+
EdgeFunctionPtrType
128+
composeWith(EdgeFunctionPtrType /*SecondFunction*/) override {
127129
return this->shared_from_this();
128130
}
129131

130-
EdgeFunctionPtrType joinWith(EdgeFunctionPtrType otherFunction) override {
131-
return otherFunction;
132+
EdgeFunctionPtrType joinWith(EdgeFunctionPtrType OtherFunction) override {
133+
return OtherFunction;
132134
}
133135

134-
bool equal_to(EdgeFunctionPtrType other) const override {
135-
if (auto *alltop = dynamic_cast<AllTop<L> *>(other.get())) {
136-
return (alltop->topElement == topElement);
136+
[[nodiscard]] bool equal_to // NOLINT - would break too many client analyses
137+
(EdgeFunctionPtrType Other) const override {
138+
if (auto *Alltop = dynamic_cast<AllTop<L> *>(Other.get())) {
139+
return (Alltop->TopElement == TopElement);
137140
}
138141
return false;
139142
}
140143

141-
void print(std::ostream &OS, bool isForDebug = false) const override {
144+
void print(std::ostream &OS,
145+
[[maybe_unused]] bool IsForDebug = false) const override {
142146
OS << "AllTop";
143147
}
144148
};
@@ -152,47 +156,48 @@ class AllBottom : public EdgeFunction<L>,
152156
using typename EdgeFunction<L>::EdgeFunctionPtrType;
153157

154158
private:
155-
const L bottomElement;
159+
const L BottomElement;
156160

157161
public:
158-
AllBottom(L bottomElement) : bottomElement(bottomElement) {}
162+
AllBottom(const L BottomElement) : BottomElement(std::move(BottomElement)) {}
159163

160164
~AllBottom() override = default;
161165

162-
L computeTarget(L source) override { return bottomElement; }
166+
L computeTarget(L /*Source*/) override { return BottomElement; }
163167

164-
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType secondFunction) override {
165-
if (auto *ab = dynamic_cast<AllBottom<L> *>(secondFunction.get())) {
168+
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType SecondFunction) override {
169+
if (auto *AB = dynamic_cast<AllBottom<L> *>(SecondFunction.get())) {
166170
return this->shared_from_this();
167171
}
168-
if (auto *ei = dynamic_cast<EdgeIdentity<L> *>(secondFunction.get())) {
172+
if (auto *EI = dynamic_cast<EdgeIdentity<L> *>(SecondFunction.get())) {
169173
return this->shared_from_this();
170174
}
171-
return secondFunction->composeWith(this->shared_from_this());
175+
return SecondFunction->composeWith(this->shared_from_this());
172176
}
173177

174-
EdgeFunctionPtrType joinWith(EdgeFunctionPtrType otherFunction) override {
175-
if (otherFunction.get() == this ||
176-
otherFunction->equal_to(this->shared_from_this())) {
178+
EdgeFunctionPtrType joinWith(EdgeFunctionPtrType OtherFunction) override {
179+
if (OtherFunction.get() == this ||
180+
OtherFunction->equal_to(this->shared_from_this())) {
177181
return this->shared_from_this();
178182
}
179-
if (auto *alltop = dynamic_cast<AllTop<L> *>(otherFunction.get())) {
183+
if (auto *Alltop = dynamic_cast<AllTop<L> *>(OtherFunction.get())) {
180184
return this->shared_from_this();
181185
}
182-
if (auto *ei = dynamic_cast<EdgeIdentity<L> *>(otherFunction.get())) {
186+
if (auto *EI = dynamic_cast<EdgeIdentity<L> *>(OtherFunction.get())) {
183187
return this->shared_from_this();
184188
}
185189
return this->shared_from_this();
186190
}
187191

188-
bool equal_to(EdgeFunctionPtrType other) const override {
189-
if (auto *allbottom = dynamic_cast<AllBottom<L> *>(other.get())) {
190-
return (allbottom->bottomElement == bottomElement);
192+
[[nodiscard]] bool equal_to // NOLINT - would break too many client analyses
193+
(EdgeFunctionPtrType Other) const override {
194+
if (auto *AB = dynamic_cast<AllBottom<L> *>(Other.get())) {
195+
return (AB->BottomElement == BottomElement);
191196
}
192197
return false;
193198
}
194199

195-
void print(std::ostream &OS, bool isForDebug = false) const override {
200+
void print(std::ostream &OS, bool /*IsForDebug = false*/) const override {
196201
OS << "AllBottom";
197202
}
198203
};
@@ -207,44 +212,45 @@ class EdgeIdentity : public EdgeFunction<L>,
207212
EdgeIdentity() = default;
208213

209214
public:
210-
EdgeIdentity(const EdgeIdentity &ei) = delete;
215+
EdgeIdentity(const EdgeIdentity &EI) = delete;
211216

212-
EdgeIdentity &operator=(const EdgeIdentity &ei) = delete;
217+
EdgeIdentity &operator=(const EdgeIdentity &EI) = delete;
213218

214219
~EdgeIdentity() override = default;
215220

216-
L computeTarget(L source) override { return source; }
221+
L computeTarget(L Source) override { return Source; }
217222

218-
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType secondFunction) override {
219-
return secondFunction;
223+
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType SecondFunction) override {
224+
return SecondFunction;
220225
}
221226

222-
EdgeFunctionPtrType joinWith(EdgeFunctionPtrType otherFunction) override {
223-
if ((otherFunction.get() == this) ||
224-
otherFunction->equal_to(this->shared_from_this())) {
227+
EdgeFunctionPtrType joinWith(EdgeFunctionPtrType OtherFunction) override {
228+
if ((OtherFunction.get() == this) ||
229+
OtherFunction->equal_to(this->shared_from_this())) {
225230
return this->shared_from_this();
226231
}
227-
if (auto *ab = dynamic_cast<AllBottom<L> *>(otherFunction.get())) {
228-
return otherFunction;
232+
if (auto *AB = dynamic_cast<AllBottom<L> *>(OtherFunction.get())) {
233+
return OtherFunction;
229234
}
230-
if (auto *at = dynamic_cast<AllTop<L> *>(otherFunction.get())) {
235+
if (auto *AT = dynamic_cast<AllTop<L> *>(OtherFunction.get())) {
231236
return this->shared_from_this();
232237
}
233238
// do not know how to join; hence ask other function to decide on this
234-
return otherFunction->joinWith(this->shared_from_this());
239+
return OtherFunction->joinWith(this->shared_from_this());
235240
}
236241

237-
bool equal_to(EdgeFunctionPtrType other) const override {
238-
return this == other.get();
242+
[[nodiscard]] bool equal_to // NOLINT - would break too many client analyses
243+
(EdgeFunctionPtrType Other) const override {
244+
return this == Other.get();
239245
}
240246

241247
static EdgeFunctionPtrType getInstance() {
242248
// implement singleton C++11 thread-safe (see Scott Meyers)
243-
static EdgeFunctionPtrType instance(new EdgeIdentity<L>());
244-
return instance;
249+
static EdgeFunctionPtrType Instance(new EdgeIdentity<L>());
250+
return Instance;
245251
}
246252

247-
void print(std::ostream &OS, bool isForDebug = false) const override {
253+
void print(std::ostream &OS, bool /*IsForDebug = false*/) const override {
248254
OS << "EdgeIdentity";
249255
}
250256
};
@@ -523,11 +529,10 @@ class EdgeFunctionSingletonFactory {
523529
auto SearchVal = Storage.find(K);
524530
if (SearchVal != Storage.end() && !SearchVal->second.expired()) {
525531
return SearchVal->second.lock();
526-
} else {
527-
auto NewEdgeFunc = std::make_shared<EdgeFunctionType>(K);
528-
Storage[K] = NewEdgeFunc;
529-
return NewEdgeFunc;
530532
}
533+
auto NewEdgeFunc = std::make_shared<EdgeFunctionType>(K);
534+
Storage[K] = NewEdgeFunc;
535+
return NewEdgeFunc;
531536
}
532537

533538
// Initialize a cleaner thread to automatically remove unused/expired

0 commit comments

Comments
 (0)