Skip to content

Commit 67264b3

Browse files
authored
Merge pull request #458 from secure-software-engineering/f-ClangTidyFixIDELCA
clang-tidy: Fix IDE LCA
2 parents e08348f + de2fd5c commit 67264b3

4 files changed

Lines changed: 165 additions & 159 deletions

File tree

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

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class IDELinearConstantAnalysis
4242
: public IDETabulationProblem<IDELinearConstantAnalysisDomain> {
4343
private:
4444
// For debug purpose only
45-
static unsigned CurrGenConstantId;
46-
static unsigned CurrLCAIDId;
47-
static unsigned CurrBinaryId;
45+
static unsigned CurrGenConstantId; // NOLINT
46+
static unsigned CurrLCAIDId; // NOLINT
47+
static unsigned CurrBinaryId; // NOLINT
4848

4949
public:
5050
using IDETabProblemType =
@@ -66,34 +66,37 @@ class IDELinearConstantAnalysis
6666
std::set<std::string> EntryPoints = {"main"});
6767

6868
~IDELinearConstantAnalysis() override;
69+
IDELinearConstantAnalysis(const IDELinearConstantAnalysis &) = delete;
70+
IDELinearConstantAnalysis &
71+
operator=(const IDELinearConstantAnalysis &) = delete;
6972

7073
IDELinearConstantAnalysis &
7174
operator=(const IDELinearConstantAnalysis &) = delete;
7275
struct LCAResult {
7376
LCAResult() = default;
74-
unsigned line_nr = 0;
75-
std::string src_code;
76-
std::map<std::string, l_t> variableToValue;
77-
std::vector<n_t> ir_trace;
78-
void print(std::ostream &os);
79-
inline bool operator==(const LCAResult &rhs) const {
80-
return src_code == rhs.src_code &&
81-
variableToValue == rhs.variableToValue && ir_trace == rhs.ir_trace;
77+
unsigned LineNr = 0;
78+
std::string SrcNode;
79+
std::map<std::string, l_t> VariableToValue;
80+
std::vector<n_t> IRTrace;
81+
void print(std::ostream &OS);
82+
inline bool operator==(const LCAResult &Rhs) const {
83+
return SrcNode == Rhs.SrcNode && VariableToValue == Rhs.VariableToValue &&
84+
IRTrace == Rhs.IRTrace;
8285
}
8386

8487
operator std::string() const {
8588
std::stringstream OS;
86-
OS << "Line " << line_nr << ": " << src_code << '\n';
89+
OS << "Line " << LineNr << ": " << SrcNode << '\n';
8790
OS << "Var(s): ";
88-
for (auto It = variableToValue.begin(); It != variableToValue.end();
91+
for (auto It = VariableToValue.begin(); It != VariableToValue.end();
8992
++It) {
90-
if (It != variableToValue.begin()) {
93+
if (It != VariableToValue.begin()) {
9194
OS << ", ";
9295
}
9396
OS << It->first << " = " << It->second;
9497
}
9598
OS << "\nCorresponding IR Instructions:\n";
96-
for (const auto *Ir : ir_trace) {
99+
for (const auto *Ir : IRTrace) {
97100
OS << " " << llvmIRToString(Ir) << '\n';
98101
}
99102
return OS.str();
@@ -106,52 +109,52 @@ class IDELinearConstantAnalysis
106109

107110
// start formulating our analysis by specifying the parts required for IFDS
108111

109-
FlowFunctionPtrType getNormalFlowFunction(n_t curr, n_t succ) override;
112+
FlowFunctionPtrType getNormalFlowFunction(n_t Curr, n_t Succ) override;
110113

111-
FlowFunctionPtrType getCallFlowFunction(n_t callSite, f_t destFun) override;
114+
FlowFunctionPtrType getCallFlowFunction(n_t CallSite, f_t DestFun) override;
112115

113-
FlowFunctionPtrType getRetFlowFunction(n_t callSite, f_t calleeFun,
114-
n_t exitInst, n_t retSite) override;
116+
FlowFunctionPtrType getRetFlowFunction(n_t CallSite, f_t CalleeFun,
117+
n_t ExitInst, n_t RetSite) override;
115118

116-
FlowFunctionPtrType getCallToRetFlowFunction(n_t callSite, n_t retSite,
117-
std::set<f_t> callees) override;
119+
FlowFunctionPtrType getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
120+
std::set<f_t> Callees) override;
118121

119-
FlowFunctionPtrType getSummaryFlowFunction(n_t callSite,
120-
f_t destFun) override;
122+
FlowFunctionPtrType getSummaryFlowFunction(n_t CallSite,
123+
f_t DestFun) override;
121124

122125
[[nodiscard]] InitialSeeds<n_t, d_t, l_t> initialSeeds() override;
123126

124127
[[nodiscard]] d_t createZeroValue() const override;
125128

126-
bool isZeroValue(d_t d) const override;
129+
[[nodiscard]] bool isZeroValue(d_t Fact) const override;
127130

128131
// in addition provide specifications for the IDE parts
129132

130133
std::shared_ptr<EdgeFunction<l_t>>
131-
getNormalEdgeFunction(n_t curr, d_t currNode, n_t succ,
132-
d_t succNode) override;
134+
getNormalEdgeFunction(n_t Curr, d_t CurrNode, n_t Succ,
135+
d_t SuccNode) override;
133136

134137
std::shared_ptr<EdgeFunction<l_t>>
135-
getCallEdgeFunction(n_t callSite, d_t srcNode, f_t destinationFunction,
136-
d_t destNode) override;
138+
getCallEdgeFunction(n_t CallSite, d_t SrcNode, f_t DestinationFunction,
139+
d_t DestNode) override;
137140

138141
std::shared_ptr<EdgeFunction<l_t>>
139-
getReturnEdgeFunction(n_t callSite, f_t calleeFunction, n_t exitInst,
140-
d_t exitNode, n_t reSite, d_t retNode) override;
142+
getReturnEdgeFunction(n_t CallSite, f_t CalleeFunction, n_t ExitStmt,
143+
d_t ExitNode, n_t RetSite, d_t RetNode) override;
141144

142145
std::shared_ptr<EdgeFunction<l_t>>
143-
getCallToRetEdgeFunction(n_t callSite, d_t callNode, n_t retSite,
144-
d_t retSiteNode, std::set<f_t> callees) override;
146+
getCallToRetEdgeFunction(n_t CallSite, d_t CallNode, n_t RetSite,
147+
d_t RetSiteNode, std::set<f_t> Callees) override;
145148

146149
std::shared_ptr<EdgeFunction<l_t>>
147-
getSummaryEdgeFunction(n_t callSite, d_t callNode, n_t retSite,
148-
d_t retSiteNode) override;
150+
getSummaryEdgeFunction(n_t CallSite, d_t CallNode, n_t RetSite,
151+
d_t RetSiteNode) override;
149152

150153
l_t topElement() override;
151154

152155
l_t bottomElement() override;
153156

154-
l_t join(l_t lhs, l_t rhs) override;
157+
l_t join(l_t Lhs, l_t Rhs) override;
155158

156159
std::shared_ptr<EdgeFunction<l_t>> allTopFunction() override;
157160

@@ -164,75 +167,75 @@ class IDELinearConstantAnalysis
164167
: EdgeFunctionComposer<l_t>(F, G){};
165168

166169
std::shared_ptr<EdgeFunction<l_t>>
167-
composeWith(std::shared_ptr<EdgeFunction<l_t>> secondFunction) override;
170+
composeWith(std::shared_ptr<EdgeFunction<l_t>> SecondFunction) override;
168171

169172
std::shared_ptr<EdgeFunction<l_t>>
170-
joinWith(std::shared_ptr<EdgeFunction<l_t>> otherFunction) override;
173+
joinWith(std::shared_ptr<EdgeFunction<l_t>> OtherFunction) override;
171174
};
172175

173176
class GenConstant : public EdgeFunction<l_t>,
174177
public std::enable_shared_from_this<GenConstant> {
175178
private:
176-
const unsigned GenConstant_Id;
179+
const unsigned GenConstantId;
177180
const l_t IntConst;
178181

179182
public:
180183
explicit GenConstant(l_t IntConst);
181184

182-
l_t computeTarget(l_t source) override;
185+
l_t computeTarget(l_t Source) override;
183186

184187
std::shared_ptr<EdgeFunction<l_t>>
185-
composeWith(std::shared_ptr<EdgeFunction<l_t>> secondFunction) override;
188+
composeWith(std::shared_ptr<EdgeFunction<l_t>> SecondFunction) override;
186189

187190
std::shared_ptr<EdgeFunction<l_t>>
188-
joinWith(std::shared_ptr<EdgeFunction<l_t>> otherFunction) override;
191+
joinWith(std::shared_ptr<EdgeFunction<l_t>> OtherFunction) override;
189192

190-
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> other) const override;
193+
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> Other) const override;
191194

192-
void print(std::ostream &OS, bool isForDebug = false) const override;
195+
void print(std::ostream &OS, bool IsForDebug = false) const override;
193196
};
194197

195198
class LCAIdentity : public EdgeFunction<l_t>,
196199
public std::enable_shared_from_this<LCAIdentity> {
197200
private:
198-
const unsigned LCAID_Id;
201+
const unsigned LCAIDId;
199202

200203
public:
201204
explicit LCAIdentity();
202205

203-
l_t computeTarget(l_t source) override;
206+
l_t computeTarget(l_t Source) override;
204207

205208
std::shared_ptr<EdgeFunction<l_t>>
206-
composeWith(std::shared_ptr<EdgeFunction<l_t>> secondFunction) override;
209+
composeWith(std::shared_ptr<EdgeFunction<l_t>> SecondFunction) override;
207210

208211
std::shared_ptr<EdgeFunction<l_t>>
209-
joinWith(std::shared_ptr<EdgeFunction<l_t>> otherFunction) override;
212+
joinWith(std::shared_ptr<EdgeFunction<l_t>> OtherFunction) override;
210213

211-
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> other) const override;
214+
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> Other) const override;
212215

213-
void print(std::ostream &OS, bool isForDebug = false) const override;
216+
void print(std::ostream &OS, bool IsForDebug = false) const override;
214217
};
215218

216219
class BinOp : public EdgeFunction<l_t>,
217220
public std::enable_shared_from_this<BinOp> {
218221
private:
219222
const unsigned EdgeFunctionID, Op;
220-
d_t lop, rop, currNode;
223+
d_t Lop, Rop, CurrNode;
221224

222225
public:
223-
BinOp(const unsigned Op, d_t lop, d_t rop, d_t currNode);
226+
BinOp(unsigned Op, d_t Lop, d_t Rop, d_t CurrNode);
224227

225-
l_t computeTarget(l_t source) override;
228+
l_t computeTarget(l_t Source) override;
226229

227230
std::shared_ptr<EdgeFunction<l_t>>
228-
composeWith(std::shared_ptr<EdgeFunction<l_t>> secondFunction) override;
231+
composeWith(std::shared_ptr<EdgeFunction<l_t>> SecondFunction) override;
229232

230233
std::shared_ptr<EdgeFunction<l_t>>
231-
joinWith(std::shared_ptr<EdgeFunction<l_t>> otherFunction) override;
234+
joinWith(std::shared_ptr<EdgeFunction<l_t>> OtherFunction) override;
232235

233-
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> other) const override;
236+
bool equal_to(std::shared_ptr<EdgeFunction<l_t>> Other) const override;
234237

235-
void print(std::ostream &OS, bool isForDebug = false) const override;
238+
void print(std::ostream &OS, bool IsForDebug = false) const override;
236239
};
237240

238241
// Helper functions
@@ -251,19 +254,19 @@ class IDELinearConstantAnalysis
251254
* @param rop right operand
252255
* @return Result of binary operation
253256
*/
254-
static l_t executeBinOperation(const unsigned op, l_t lop, l_t rop);
257+
static l_t executeBinOperation(unsigned Op, l_t Lop, l_t Rop);
255258

256-
static char opToChar(const unsigned op);
259+
static char opToChar(unsigned Op);
257260

258261
[[nodiscard]] bool isEntryPoint(const std::string &FunctionName) const;
259262

260-
void printNode(std::ostream &os, n_t n) const override;
263+
void printNode(std::ostream &OS, n_t Stmt) const override;
261264

262-
void printDataFlowFact(std::ostream &os, d_t d) const override;
265+
void printDataFlowFact(std::ostream &OS, d_t Fact) const override;
263266

264-
void printFunction(std::ostream &os, f_t m) const override;
267+
void printFunction(std::ostream &OS, f_t Func) const override;
265268

266-
void printEdgeFact(std::ostream &os, l_t l) const override;
269+
void printEdgeFact(std::ostream &OS, l_t L) const override;
267270

268271
[[nodiscard]] lca_results_t getLCAResults(SolverResults<n_t, d_t, l_t> SR);
269272

0 commit comments

Comments
 (0)