Skip to content

Commit d2fde0d

Browse files
author
Martin Mory
committed
clang-tidy fixes in Utils - mostly renames
1 parent 74296bc commit d2fde0d

28 files changed

Lines changed: 460 additions & 407 deletions

include/phasar/PhasarLLVM/Domain/ExtendedValue.h

Lines changed: 100 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -19,159 +19,179 @@ namespace psr {
1919

2020
class ExtendedValue {
2121
public:
22-
ExtendedValue() {}
23-
explicit ExtendedValue(const llvm::Value *_value) : value(_value) {
24-
assert(value && "ExtendedValue requires an llvm::Value* object");
22+
ExtendedValue() = default;
23+
explicit ExtendedValue(const llvm::Value *Val) : Val(Val) {
24+
assert(Val && "ExtendedValue requires an llvm::Value* object");
2525
}
2626
~ExtendedValue() = default;
2727

28-
bool operator==(const ExtendedValue &rhs) const {
29-
bool isValueEqual = value == rhs.value;
30-
if (!isValueEqual)
28+
bool operator==(const ExtendedValue &Rhs) const {
29+
bool IsValueEqual = Val == Rhs.Val;
30+
if (!IsValueEqual) {
3131
return false;
32+
}
3233

33-
bool isMemLocationSeqEqual = memLocationSeq == rhs.memLocationSeq;
34-
if (!isMemLocationSeqEqual)
34+
bool IsMemLocationSeqEqual = MemLocationSeq == Rhs.MemLocationSeq;
35+
if (!IsMemLocationSeqEqual) {
3536
return false;
37+
}
3638

37-
bool isEndOfTaintedBlockLabelEqual =
38-
endOfTaintedBlockLabel == rhs.endOfTaintedBlockLabel;
39-
if (!isEndOfTaintedBlockLabelEqual)
39+
bool IsEndOfTaintedBlockLabelEqual =
40+
EndOfTaintedBlockLabel == Rhs.EndOfTaintedBlockLabel;
41+
if (!IsEndOfTaintedBlockLabelEqual) {
4042
return false;
43+
}
4144

42-
bool isVaListMemLocationSeqEqual =
43-
vaListMemLocationSeq == rhs.vaListMemLocationSeq;
44-
if (!isVaListMemLocationSeqEqual)
45+
bool IsVaListMemLocationSeqEqual =
46+
VaListMemLocationSeq == Rhs.VaListMemLocationSeq;
47+
if (!IsVaListMemLocationSeqEqual) {
4548
return false;
49+
}
4650

47-
bool isVarArgIndexEqual = varArgIndex == rhs.varArgIndex;
48-
if (!isVarArgIndexEqual)
51+
bool IsVarArgIndexEqual = VarArgIndex == Rhs.VarArgIndex;
52+
if (!IsVarArgIndexEqual) {
4953
return false;
54+
}
5055

51-
bool isCurrentVarArgIndexEqual =
52-
currentVarArgIndex == rhs.currentVarArgIndex;
53-
if (!isCurrentVarArgIndexEqual)
56+
bool IsCurrentVarArgIndexEqual =
57+
CurrentVarArgIndex == Rhs.CurrentVarArgIndex;
58+
if (!IsCurrentVarArgIndexEqual) {
5459
return false;
60+
}
5561

5662
return true;
5763
}
5864

59-
bool operator<(const ExtendedValue &rhs) const {
60-
if (std::less<const llvm::Value *>{}(value, rhs.value))
65+
bool operator<(const ExtendedValue &Rhs) const {
66+
if (std::less<const llvm::Value *>{}(Val, Rhs.Val)) {
6167
return true;
62-
if (std::less<const llvm::Value *>{}(rhs.value, value))
68+
}
69+
if (std::less<const llvm::Value *>{}(Rhs.Val, Val)) {
6370
return false;
71+
}
6472

65-
if (memLocationSeq < rhs.memLocationSeq)
73+
if (MemLocationSeq < Rhs.MemLocationSeq) {
6674
return true;
67-
if (rhs.memLocationSeq < memLocationSeq)
75+
}
76+
if (Rhs.MemLocationSeq < MemLocationSeq) {
6877
return false;
78+
}
6979

70-
if (std::less<std::string>{}(endOfTaintedBlockLabel,
71-
rhs.endOfTaintedBlockLabel))
80+
if (std::less<std::string>{}(EndOfTaintedBlockLabel,
81+
Rhs.EndOfTaintedBlockLabel)) {
7282
return true;
73-
if (std::less<std::string>{}(rhs.endOfTaintedBlockLabel,
74-
endOfTaintedBlockLabel))
83+
}
84+
if (std::less<std::string>{}(Rhs.EndOfTaintedBlockLabel,
85+
EndOfTaintedBlockLabel)) {
7586
return false;
87+
}
7688

77-
if (vaListMemLocationSeq < rhs.vaListMemLocationSeq)
89+
if (VaListMemLocationSeq < Rhs.VaListMemLocationSeq) {
7890
return true;
79-
if (rhs.vaListMemLocationSeq < vaListMemLocationSeq)
91+
}
92+
if (Rhs.VaListMemLocationSeq < VaListMemLocationSeq) {
8093
return false;
94+
}
8195

82-
if (std::less<long>{}(varArgIndex, rhs.varArgIndex))
96+
if (std::less<long>{}(VarArgIndex, Rhs.VarArgIndex)) {
8397
return true;
84-
if (std::less<long>{}(rhs.varArgIndex, varArgIndex))
98+
}
99+
if (std::less<long>{}(Rhs.VarArgIndex, VarArgIndex)) {
85100
return false;
101+
}
86102

87-
return std::less<long>{}(currentVarArgIndex, rhs.currentVarArgIndex);
103+
return std::less<long>{}(CurrentVarArgIndex, Rhs.CurrentVarArgIndex);
88104
}
89105

90-
const llvm::Value *getValue() const { return value; }
106+
[[nodiscard]] const llvm::Value *getValue() const { return Val; }
91107

92-
const std::vector<const llvm::Value *> getMemLocationSeq() const {
93-
return memLocationSeq;
108+
[[nodiscard]] std::vector<const llvm::Value *> getMemLocationSeq() const {
109+
return MemLocationSeq;
94110
}
95-
void setMemLocationSeq(std::vector<const llvm::Value *> _memLocationSeq) {
96-
memLocationSeq = _memLocationSeq;
111+
void setMemLocationSeq(const std::vector<const llvm::Value *> &MemLocationSeq) {
112+
this->MemLocationSeq = MemLocationSeq;
97113
}
98114

99-
const std::string getEndOfTaintedBlockLabel() const {
100-
return endOfTaintedBlockLabel;
115+
[[nodiscard]] std::string getEndOfTaintedBlockLabel() const {
116+
return EndOfTaintedBlockLabel;
101117
}
102-
void setEndOfTaintedBlockLabel(std::string _endOfTaintedBlockLabel) {
103-
endOfTaintedBlockLabel = _endOfTaintedBlockLabel;
118+
void setEndOfTaintedBlockLabel(const std::string &EndOfTaintedBlockLabel) {
119+
this->EndOfTaintedBlockLabel = EndOfTaintedBlockLabel;
104120
}
105121

106-
const std::vector<const llvm::Value *> getVaListMemLocationSeq() const {
107-
return vaListMemLocationSeq;
122+
[[nodiscard]] std::vector<const llvm::Value *>
123+
getVaListMemLocationSeq() const {
124+
return VaListMemLocationSeq;
108125
}
109126
void setVaListMemLocationSeq(
110-
std::vector<const llvm::Value *> _vaListMemLocationSeq) {
111-
vaListMemLocationSeq = _vaListMemLocationSeq;
127+
const std::vector<const llvm::Value *> &VaListMemLocationSeq) {
128+
this->VaListMemLocationSeq = VaListMemLocationSeq;
112129
}
113130

114-
long getVarArgIndex() const { return varArgIndex; }
115-
void setVarArgIndex(long _varArgIndex) { varArgIndex = _varArgIndex; }
131+
[[nodiscard]] long getVarArgIndex() const { return VarArgIndex; }
132+
void setVarArgIndex(long VarArgIndex) { this->VarArgIndex = VarArgIndex; }
116133

117134
void resetVarArgIndex() {
118-
if (!isVarArgTemplate())
119-
varArgIndex = -1L;
135+
if (!isVarArgTemplate()) {
136+
VarArgIndex = -1L;
137+
}
120138
}
121139

122-
long getCurrentVarArgIndex() const { return currentVarArgIndex; }
140+
[[nodiscard]] long getCurrentVarArgIndex() const {
141+
return CurrentVarArgIndex;
142+
}
123143
void incrementCurrentVarArgIndex() {
124-
if (!isVarArgTemplate())
125-
++currentVarArgIndex;
144+
if (!isVarArgTemplate()) {
145+
++CurrentVarArgIndex;
146+
}
126147
}
127148

128-
bool isVarArgTemplate() const {
129-
return vaListMemLocationSeq.empty() && isVarArg();
149+
[[nodiscard]] bool isVarArg() const { return VarArgIndex > -1L; }
150+
[[nodiscard]] bool isVarArgTemplate() const {
151+
return VaListMemLocationSeq.empty() && isVarArg();
130152
}
131153

132-
[[nodiscard]] bool isVarArg() const { return varArgIndex > -1L; }
133-
134154
private:
135-
const llvm::Value *value = nullptr;
136-
std::vector<const llvm::Value *> memLocationSeq;
137-
std::string endOfTaintedBlockLabel;
155+
const llvm::Value *Val = nullptr;
156+
std::vector<const llvm::Value *> MemLocationSeq;
157+
std::string EndOfTaintedBlockLabel;
138158

139-
std::vector<const llvm::Value *> vaListMemLocationSeq;
140-
long varArgIndex = -1L;
141-
long currentVarArgIndex = -1L;
159+
std::vector<const llvm::Value *> VaListMemLocationSeq;
160+
long VarArgIndex = -1L;
161+
long CurrentVarArgIndex = -1L;
142162
};
143163

144164
} // namespace psr
145165

146166
namespace std {
147167

148168
template <> struct hash<psr::ExtendedValue> {
149-
std::size_t operator()(const psr::ExtendedValue &ev) const {
150-
std::size_t seed = 0x4711;
169+
std::size_t operator()(const psr::ExtendedValue &Ev) const {
170+
std::size_t Seed = 0x4711;
151171

152-
seed ^= hash<const llvm::Value *>{}(ev.getValue()) + 0x9e3779b9 +
153-
(seed << 6) + (seed >> 2);
172+
Seed ^= hash<const llvm::Value *>{}(Ev.getValue()) + 0x9e3779b9 +
173+
(Seed << 6) + (Seed >> 2);
154174

155-
for (const auto &memLocationPart : ev.getMemLocationSeq()) {
156-
seed ^= hash<const llvm::Value *>{}(memLocationPart) + 0x9e3779b9 +
157-
(seed << 6) + (seed >> 2);
175+
for (const auto &MemLocationPart : Ev.getMemLocationSeq()) {
176+
Seed ^= hash<const llvm::Value *>{}(MemLocationPart) + 0x9e3779b9 +
177+
(Seed << 6) + (Seed >> 2);
158178
}
159179

160-
seed ^= hash<string>{}(ev.getEndOfTaintedBlockLabel()) + 0x9e3779b9 +
161-
(seed << 6) + (seed >> 2);
180+
Seed ^= hash<string>{}(Ev.getEndOfTaintedBlockLabel()) + 0x9e3779b9 +
181+
(Seed << 6) + (Seed >> 2);
162182

163-
for (const auto &vaListMemLocationPart : ev.getVaListMemLocationSeq()) {
164-
seed ^= hash<const llvm::Value *>{}(vaListMemLocationPart) + 0x9e3779b9 +
165-
(seed << 6) + (seed >> 2);
183+
for (const auto &VaListMemLocationPart : Ev.getVaListMemLocationSeq()) {
184+
Seed ^= hash<const llvm::Value *>{}(VaListMemLocationPart) + 0x9e3779b9 +
185+
(Seed << 6) + (Seed >> 2);
166186
}
167187

168-
seed ^= hash<long>{}(ev.getVarArgIndex()) + 0x9e3779b9 + (seed << 6) +
169-
(seed >> 2);
188+
Seed ^= hash<long>{}(Ev.getVarArgIndex()) + 0x9e3779b9 + (Seed << 6) +
189+
(Seed >> 2);
170190

171-
seed ^= hash<long>{}(ev.getCurrentVarArgIndex()) + 0x9e3779b9 +
172-
(seed << 6) + (seed >> 2);
191+
Seed ^= hash<long>{}(Ev.getCurrentVarArgIndex()) + 0x9e3779b9 +
192+
(Seed << 6) + (Seed >> 2);
173193

174-
return seed;
194+
return Seed;
175195
}
176196
};
177197

include/phasar/PhasarLLVM/TaintConfig/TaintConfigUtilities.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ void collectGeneratedFacts(ContainerTy &Dest, const TaintConfig &Config,
3737
Dest.insert(CB);
3838
}
3939

40-
for (unsigned i = 0, end = Callee->arg_size(); i < end; ++i) {
41-
if (Config.isSource(Callee->getArg(i))) {
42-
Dest.insert(CB->getArgOperand(i));
40+
for (unsigned I = 0, End = Callee->arg_size(); I < End; ++I) {
41+
if (Config.isSource(Callee->getArg(I))) {
42+
Dest.insert(CB->getArgOperand(I));
4343
}
4444
}
4545
}
@@ -58,9 +58,9 @@ void collectLeakedFacts(ContainerTy &Dest, const TaintConfig &Config,
5858
std::inserter(Dest, Dest.end()), LeakIf);
5959
}
6060

61-
for (unsigned i = 0, end = Callee->arg_size(); i < end; ++i) {
62-
if (Config.isSink(Callee->getArg(i)) && LeakIf(CB->getArgOperand(i))) {
63-
Dest.insert(CB->getArgOperand(i));
61+
for (unsigned I = 0, End = Callee->arg_size(); I < End; ++I) {
62+
if (Config.isSink(Callee->getArg(I)) && LeakIf(CB->getArgOperand(I))) {
63+
Dest.insert(CB->getArgOperand(I));
6464
}
6565
}
6666
}
@@ -70,7 +70,7 @@ inline void collectLeakedFacts(ContainerTy &Dest, const TaintConfig &Config,
7070
const llvm::CallBase *CB,
7171
const llvm::Function *Callee) {
7272
collectLeakedFacts(Dest, Config, CB, Callee,
73-
[](const llvm::Value *V) { return true; });
73+
[](const llvm::Value * /*V*/) { return true; });
7474
}
7575

7676
template <typename ContainerTy,
@@ -79,9 +79,9 @@ template <typename ContainerTy,
7979
void collectSanitizedFacts(ContainerTy &Dest, const TaintConfig &Config,
8080
const llvm::CallBase *CB,
8181
const llvm::Function *Callee) {
82-
for (unsigned i = 0, end = Callee->arg_size(); i < end; ++i) {
83-
if (Config.isSanitizer(Callee->getArg(i))) {
84-
Dest.insert(CB->getArgOperand(i));
82+
for (unsigned I = 0, End = Callee->arg_size(); I < End; ++I) {
83+
if (Config.isSanitizer(Callee->getArg(I))) {
84+
Dest.insert(CB->getArgOperand(I));
8585
}
8686
}
8787
}

include/phasar/PhasarLLVM/Utils/BasicBlockOrdering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class DefaultDominatorTreeAnalysis {
4040
class BasicBlockOrdering {
4141
/// Note: Cannot use std::function, because we need to support move-only
4242
/// functors(e.g. DefaultDominatorTreeAnalysis)
43-
llvm::unique_function<llvm::DominatorTree &(const llvm::Function *)> getDom;
43+
llvm::unique_function<llvm::DominatorTree &(const llvm::Function *)>
44+
getDom; // NOLINT
4445

4546
public:
4647
template <

include/phasar/PhasarLLVM/Utils/BinaryDomain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern const std::map<std::string, BinaryDomain> StringToBinaryDomain;
2828

2929
extern const std::map<BinaryDomain, std::string> BinaryDomainToString;
3030

31-
std::ostream &operator<<(std::ostream &os, const BinaryDomain &b);
31+
std::ostream &operator<<(std::ostream &OS, const BinaryDomain &B);
3232

3333
} // namespace psr
3434

include/phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ std::string toString(const DataFlowAnalysisType &D);
3737

3838
DataFlowAnalysisType toDataFlowAnalysisType(const std::string &S);
3939

40-
std::ostream &operator<<(std::ostream &os, const DataFlowAnalysisType &D);
40+
std::ostream &operator<<(std::ostream &OS, const DataFlowAnalysisType &D);
4141

4242
} // namespace psr
4343

include/phasar/PhasarLLVM/Utils/IOFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ std::string toString(const IOFormat &D);
2424

2525
IOFormat toIOFormat(const std::string &S);
2626

27-
std::ostream &operator<<(std::ostream &os, const IOFormat &D);
27+
std::ostream &operator<<(std::ostream &Os, const IOFormat &D);
2828

2929
} // namespace psr
3030

include/phasar/PhasarLLVM/Utils/LatticeDomain.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ inline bool operator==(const LatticeDomain<L> &Lhs,
6161
std::holds_alternative<Bottom>(Rhs)) {
6262
return true;
6363
}
64-
if (auto LhsPtr = std::get_if<L>(&Lhs)) {
65-
if (auto RhsPtr = std::get_if<L>(&Rhs)) {
64+
if (auto *LhsPtr = std::get_if<L>(&Lhs)) {
65+
if (auto *RhsPtr = std::get_if<L>(&Rhs)) {
6666
return *LhsPtr == *RhsPtr;
6767
}
6868
}
@@ -86,8 +86,8 @@ inline bool operator<(const LatticeDomain<L> &Lhs,
8686
return true;
8787
}
8888

89-
if (auto LhsPtr = std::get_if<L>(&Lhs)) {
90-
if (auto RhsPtr = std::get_if<L>(&Rhs)) {
89+
if (auto *LhsPtr = std::get_if<L>(&Lhs)) {
90+
if (auto *RhsPtr = std::get_if<L>(&Rhs)) {
9191
return *LhsPtr < *RhsPtr;
9292
}
9393
}

0 commit comments

Comments
 (0)