Skip to content

Commit de0f815

Browse files
authored
Merge pull request #463 from secure-software-engineering/f-ClangTidyFixPointer
clang-tidy: Fix Pointer
2 parents 7f3549c + f287875 commit de0f815

17 files changed

Lines changed: 245 additions & 241 deletions

File tree

include/phasar/PhasarLLVM/Pointer/LLVMPointsToGraph.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class LLVMPointsToGraph : public LLVMPointsToInfo {
6161
*/
6262
const llvm::Value *V = nullptr;
6363
VertexProperties() = default;
64-
VertexProperties(const llvm::Value *v);
64+
VertexProperties(const llvm::Value *V);
6565
std::string getValueAsString() const;
6666

6767
// Fetching the users for V is expensive, so we cache the result.
68-
mutable std::vector<const llvm::User *> users;
68+
mutable std::vector<const llvm::User *> Users;
6969
std::vector<const llvm::User *> getUsers() const;
7070
};
7171

@@ -76,7 +76,7 @@ class LLVMPointsToGraph : public LLVMPointsToInfo {
7676
/// This may contain a call or invoke instruction.
7777
const llvm::Value *V = nullptr;
7878
EdgeProperties() = default;
79-
EdgeProperties(const llvm::Value *v);
79+
EdgeProperties(const llvm::Value *V);
8080
[[nodiscard]] std::string getValueAsString() const;
8181
};
8282

@@ -220,8 +220,8 @@ class LLVMPointsToGraph : public LLVMPointsToInfo {
220220
public:
221221
PointerVertexOrEdgePrinter(const graph_t &PAG) : PAG(PAG) {}
222222
template <class VertexOrEdge>
223-
void operator()(std::ostream &out, const VertexOrEdge &v) const {
224-
out << "[label=\"" << PAG[v].getValueAsString() << "\"]";
223+
void operator()(std::ostream &Out, const VertexOrEdge &V) const {
224+
Out << "[label=\"" << PAG[V].getValueAsString() << "\"]";
225225
}
226226

227227
private:
@@ -230,7 +230,7 @@ class LLVMPointsToGraph : public LLVMPointsToInfo {
230230

231231
static inline PointerVertexOrEdgePrinter
232232
makePointerVertexOrEdgePrinter(const graph_t &PAG) {
233-
return PointerVertexOrEdgePrinter(PAG);
233+
return {PAG};
234234
}
235235

236236
/**

include/phasar/PhasarLLVM/Pointer/PointsToInfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::string toString(const PointerAnalysisType &PA);
3838

3939
PointerAnalysisType toPointerAnalysisType(const std::string &S);
4040

41-
std::ostream &operator<<(std::ostream &os, const PointerAnalysisType &PA);
41+
std::ostream &operator<<(std::ostream &OS, const PointerAnalysisType &PA);
4242

4343
template <typename V, typename N> class PointsToInfo {
4444
public:
@@ -60,9 +60,9 @@ template <typename V, typename N> class PointsToInfo {
6060
getReachableAllocationSites(V V1, bool IntraProcOnly = false, N I = N{}) = 0;
6161

6262
// Checks if V2 is a reachable allocation in the points to set of V1.
63-
virtual bool isInReachableAllocationSites(V V1, V V2,
64-
bool IntraProcOnly = false,
65-
N I = N{}) = 0;
63+
[[nodiscard]] virtual bool
64+
isInReachableAllocationSites(V V1, V V2, bool IntraProcOnly = false,
65+
N I = N{}) = 0;
6666

6767
virtual void print(std::ostream &OS = std::cout) const = 0;
6868

include/phasar/PhasarLLVM/Pointer/PointsToSetOwner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ template <typename PointsToSetTy> class PointsToSetOwner {
2222

2323
PointsToSetTy *acquire() {
2424
auto Ptr = std::make_unique<PointsToSetTy>();
25-
auto Ret = Ptr.get();
25+
auto *Ret = Ptr.get();
2626
OwnedPTS.try_emplace(Ret, std::move(Ptr));
2727
return Ret;
2828
}
@@ -38,4 +38,4 @@ template <typename PointsToSetTy> class PointsToSetOwner {
3838
};
3939
} // namespace psr
4040

41-
#endif
41+
#endif // PHASAR_PHASARLLVM_POINTER_POINTSTOSETOWNER_H

include/phasar/PhasarLLVM/Pointer/TypeGraphs/CachedTypeGraph.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ namespace psr {
3737
class CachedTypeGraph : public TypeGraph<CachedTypeGraph> {
3838
protected:
3939
struct VertexProperties {
40-
std::string name;
41-
std::set<const llvm::StructType *> types;
42-
const llvm::StructType *base_type;
40+
std::string Name;
41+
std::set<const llvm::StructType *> Types;
42+
const llvm::StructType *BaseType = nullptr;
4343
};
4444

4545
struct EdgeProperties {
@@ -69,9 +69,9 @@ class CachedTypeGraph : public TypeGraph<CachedTypeGraph> {
6969
struct dfs_visitor;
7070
struct reverse_type_propagation_dfs_visitor;
7171

72-
std::unordered_map<std::string, vertex_t> type_vertex_map;
73-
graph_t g;
74-
bool already_visited = false;
72+
std::unordered_map<std::string, vertex_t> TypeVertexMap;
73+
graph_t G;
74+
bool AlreadyVisited = false;
7575

7676
FRIEND_TEST(TypeGraphTest, AddType);
7777
FRIEND_TEST(TypeGraphTest, AddLinkSimple);
@@ -84,8 +84,8 @@ class CachedTypeGraph : public TypeGraph<CachedTypeGraph> {
8484
vertex_t addType(const llvm::StructType *NewType);
8585
void reverseTypePropagation(const llvm::StructType *BaseStruct);
8686
void aggregateTypes();
87-
bool addLinkWithoutReversePropagation(const llvm::StructType *from,
88-
const llvm::StructType *to);
87+
bool addLinkWithoutReversePropagation(const llvm::StructType *From,
88+
const llvm::StructType *To);
8989

9090
public:
9191
CachedTypeGraph() = default;
@@ -96,11 +96,10 @@ class CachedTypeGraph : public TypeGraph<CachedTypeGraph> {
9696
// CachedTypeGraph(CachedTypeGraph &&move) = delete;
9797
// CachedTypeGraph& operator=(CachedTypeGraph &&move) = delete;
9898

99-
virtual bool addLink(const llvm::StructType *from,
100-
const llvm::StructType *to) override;
101-
virtual void
102-
printAsDot(const std::string &path = "typegraph.dot") const override;
103-
virtual std::set<const llvm::StructType *>
99+
bool addLink(const llvm::StructType *From,
100+
const llvm::StructType *To) override;
101+
void printAsDot(const std::string &Path = "typegraph.dot") const override;
102+
std::set<const llvm::StructType *>
104103
getTypes(const llvm::StructType *StructType) override;
105104
};
106105
} // namespace psr

include/phasar/PhasarLLVM/Pointer/TypeGraphs/LazyTypeGraph.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* Author: nicolas bellec
1515
*/
1616

17-
#ifndef PHASAR_PHASARLLVM_POINTER_TYPEGRAPHS_LAZYTYPEGRAPH_H_
18-
#define PHASAR_PHASARLLVM_POINTER_TYPEGRAPHS_LAZYTYPEGRAPH_H_
17+
#ifndef PHASAR_PHASARLLVM_POINTER_TYPEGRAPHS_LAZYTYPEGRAPH_H
18+
#define PHASAR_PHASARLLVM_POINTER_TYPEGRAPHS_LAZYTYPEGRAPH_H
1919

2020
#include <set>
2121
#include <string>
@@ -37,8 +37,8 @@ namespace psr {
3737
class LazyTypeGraph : public TypeGraph<LazyTypeGraph> {
3838
protected:
3939
struct VertexProperties {
40-
std::string name;
41-
const llvm::StructType *type;
40+
std::string Name;
41+
const llvm::StructType *SType = nullptr;
4242
};
4343

4444
struct EdgeProperties {
@@ -67,9 +67,9 @@ class LazyTypeGraph : public TypeGraph<LazyTypeGraph> {
6767

6868
struct dfs_visitor;
6969

70-
std::unordered_map<std::string, vertex_t> type_vertex_map;
71-
graph_t g;
72-
bool already_visited = false;
70+
std::unordered_map<std::string, vertex_t> TypeToVertexMap;
71+
graph_t Graph;
72+
bool AlreadyVisited = false;
7373

7474
vertex_t addType(const llvm::StructType *NewType);
7575
void aggregateTypes();
@@ -83,10 +83,9 @@ class LazyTypeGraph : public TypeGraph<LazyTypeGraph> {
8383
// LazyTypeGraph(LazyTypeGraph &&move) = delete;
8484
// LazyTypeGraph& operator=(LazyTypeGraph &&move) = delete;
8585

86-
virtual bool addLink(const llvm::StructType *from,
87-
const llvm::StructType *to) override;
88-
virtual void
89-
printAsDot(const std::string &path = "typegraph.dot") const override;
86+
[[nodiscard]] bool addLink(const llvm::StructType *From,
87+
const llvm::StructType *To) override;
88+
void printAsDot(const std::string &Path = "typegraph.dot") const override;
9089
[[nodiscard]] std::set<const llvm::StructType *>
9190
getTypes(const llvm::StructType *StructType) override;
9291
};

include/phasar/PhasarLLVM/Pointer/TypeGraphs/TypeGraph.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ template <class ConcreteTypeGraph> class TypeGraph {
3939
/* Add a link if not already in the graph
4040
* Return true if the node has been added, false otherwise
4141
*/
42-
virtual bool addLink(const llvm::StructType *from,
43-
const llvm::StructType *to) = 0;
44-
virtual void printAsDot(const std::string &path = "typegraph.dot") const = 0;
42+
virtual bool addLink(const llvm::StructType *From,
43+
const llvm::StructType *To) = 0;
44+
virtual void printAsDot(const std::string &Path = "typegraph.dot") const = 0;
4545
virtual std::set<const llvm::StructType *>
46-
getTypes(const llvm::StructType *struct_type) = 0;
46+
getTypes(const llvm::StructType *ST) = 0;
4747
};
4848
} // namespace psr
4949

include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class LLVMTypeHierarchy
187187
[[nodiscard]] inline bool
188188
isSuperType(const llvm::StructType *Type,
189189
const llvm::StructType *SuperType) override {
190-
return isSubType(SuperType, Type);
190+
return isSubType(SuperType, Type); // NOLINT
191191
}
192192

193193
std::set<const llvm::StructType *>
@@ -228,8 +228,8 @@ class LLVMTypeHierarchy
228228
public:
229229
TypeHierarchyVertexWriter(const bidigraph_t &TyGraph) : TyGraph(TyGraph) {}
230230
template <class VertexOrEdge>
231-
void operator()(std::ostream &out, const VertexOrEdge &v) const {
232-
out << "[label=\"" << TyGraph[v].getTypeName() << "\"]";
231+
void operator()(std::ostream &Out, const VertexOrEdge &V) const {
232+
Out << "[label=\"" << TyGraph[V].getTypeName() << "\"]";
233233
}
234234

235235
private:
@@ -239,7 +239,7 @@ class LLVMTypeHierarchy
239239
// a function to conveniently create this writer
240240
[[nodiscard]] TypeHierarchyVertexWriter
241241
makeTypeHierarchyVertexWriter(const bidigraph_t &TyGraph) const {
242-
return TypeHierarchyVertexWriter(TyGraph);
242+
return {TyGraph};
243243
}
244244

245245
/**

include/phasar/PhasarLLVM/TypeHierarchy/VFTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ template <typename F> class VFTable {
2525

2626
[[nodiscard]] virtual std::vector<F> getAllFunctions() const = 0;
2727

28-
virtual int getIndex(F f) const = 0;
28+
[[nodiscard]] virtual int getIndex(F Func) const = 0;
2929

3030
[[nodiscard]] virtual bool empty() const = 0;
3131

0 commit comments

Comments
 (0)