Skip to content

Commit 2a0c164

Browse files
author
Martin Mory
committed
clang-tidy fixes in IfdsIde helpers - identifier renames, constness, etc
1 parent 6cc684f commit 2a0c164

8 files changed

Lines changed: 68 additions & 68 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum class SolverConfigOptions : uint32_t {
3535
EmitESG = 16,
3636
ComputePersistedSummaries = 32,
3737

38-
All = ~0u
38+
All = ~0U
3939
};
4040

4141
struct IFDSIDESolverConfig {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ template <typename D, typename N> class IFDSSummary : FlowFunction<D> {
3737
: StartNode(Start), EndNode(End), Context(std::move(C)), Outputs(Gen),
3838
ZeroValue(ZV) {}
3939
virtual ~IFDSSummary() = default;
40-
std::set<D> computeTargets(D source) override {
41-
if (source == ZeroValue) {
42-
Outputs.insert(source);
40+
std::set<D> computeTargets(D Source) override {
41+
if (Source == ZeroValue) {
42+
Outputs.insert(Source);
4343
return Outputs;
44-
} else {
45-
return {source};
4644
}
45+
return {Source};
4746
}
4847

4948
N getStartNode() const { return StartNode; }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class IFDSTabulationProblem
143143

144144
/// Sets the level of soundness to be used by the analysis. Returns false if
145145
/// the level of soundness is ignored. Otherwise, true.
146-
virtual bool setSoundness(Soundness S) { return false; }
146+
virtual bool setSoundness(Soundness /*S*/) { return false; }
147147
};
148148
} // namespace psr
149149

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ template <typename N, typename D, typename L> class InitialSeeds {
7575

7676
void dump(std::ostream &OS = std::cerr) {
7777

78-
auto printNode = [&](auto &&Node) {
78+
auto printNode = [&](auto &&Node) { // NOLINT
7979
if constexpr (std::is_same_v<const llvm::Instruction *, N>) {
8080
OS << llvmIRToString(Node);
8181
} else {
8282
OS << Node;
8383
}
8484
};
8585

86-
auto printFact = [&](auto &&Node) {
86+
auto printFact = [&](auto &&Node) { // NOLINT
8787
if constexpr (std::is_same_v<const llvm::Value *, D>) {
8888
OS << llvmIRToString(Node);
8989
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ template <typename AnalysisDomainTy> class JoinLattice {
2626
virtual ~JoinLattice() = default;
2727
virtual l_t topElement() = 0;
2828
virtual l_t bottomElement() = 0;
29-
virtual l_t join(l_t lhs, l_t rhs) = 0;
29+
virtual l_t join(l_t Lhs, l_t Rhs) = 0;
3030
};
3131
} // namespace psr
3232

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ namespace psr {
3939
/// \brief Automatically kills temporary loads that are no longer in use.
4040
class AutoKillTMPs : public FlowFunction<const llvm::Value *> {
4141
protected:
42-
FlowFunctionPtrType delegate;
43-
const llvm::Instruction *inst;
42+
FlowFunctionPtrType Delegate;
43+
const llvm::Instruction *Inst;
4444

4545
public:
4646
AutoKillTMPs(FlowFunctionPtrType FF, const llvm::Instruction *In)
47-
: delegate(std::move(FF)), inst(In) {}
47+
: Delegate(std::move(FF)), Inst(In) {}
4848
~AutoKillTMPs() override = default;
4949

5050
container_type computeTargets(const llvm::Value *Source) override {
51-
container_type Result = delegate->computeTargets(Source);
52-
for (const llvm::Use &U : inst->operands()) {
51+
container_type Result = Delegate->computeTargets(Source);
52+
for (const llvm::Use &U : Inst->operands()) {
5353
if (llvm::isa<llvm::LoadInst>(U)) {
5454
Result.erase(U);
5555
}
@@ -368,11 +368,11 @@ template <typename D> class PropagateLoad : public FlowFunction<D> {
368368
PropagateLoad(const llvm::LoadInst *L) : Load(L) {}
369369
virtual ~PropagateLoad() = default;
370370

371-
std::set<D> computeTargets(D source) override {
372-
if (source == Load->getPointerOperand()) {
373-
return {source, Load};
371+
std::set<D> computeTargets(D Source) override {
372+
if (Source == Load->getPointerOperand()) {
373+
return {Source, Load};
374374
}
375-
return {source};
375+
return {Source};
376376
}
377377
};
378378

@@ -384,11 +384,11 @@ template <typename D> class PropagateStore : public FlowFunction<D> {
384384
PropagateStore(const llvm::StoreInst *S) : Store(S) {}
385385
virtual ~PropagateStore() = default;
386386

387-
std::set<D> computeTargets(D source) override {
388-
if (Store->getValueOperand() == source) {
389-
return {source, Store->getPointerOperand()};
387+
std::set<D> computeTargets(D Source) override {
388+
if (Store->getValueOperand() == Source) {
389+
return {Source, Store->getPointerOperand()};
390390
}
391-
return {source};
391+
return {Source};
392392
}
393393
};
394394

@@ -402,17 +402,17 @@ template <typename D> class StrongUpdateStore : public FlowFunction<D> {
402402

403403
public:
404404
StrongUpdateStore(const llvm::StoreInst *S, std::function<bool(D)> P)
405-
: Store(S), Predicate(P) {}
405+
: Store(S), Predicate(std::move(P)) {}
406406
~StrongUpdateStore() override = default;
407407

408-
std::set<D> computeTargets(D source) override {
409-
if (source == Store->getPointerOperand()) {
408+
std::set<D> computeTargets(D Source) override {
409+
if (Source == Store->getPointerOperand()) {
410410
return {};
411-
} else if (Predicate(source)) {
412-
return {source, Store->getPointerOperand()};
413-
} else {
414-
return {source};
415411
}
412+
if (Predicate(Source)) {
413+
return {Source, Store->getPointerOperand()};
414+
}
415+
return {Source};
416416
}
417417
};
418418

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class LLVMZeroValue : public llvm::GlobalVariable {
5555
LLVMZeroValueInternalName) {
5656
setAlignment(llvm::MaybeAlign(4));
5757
}
58-
static constexpr char LLVMZeroValueInternalName[] = "zero_value";
58+
~LLVMZeroValue() = default;
59+
static constexpr auto LLVMZeroValueInternalName = "zero_value";
5960

6061
public:
6162
LLVMZeroValue(const LLVMZeroValue &Z) = delete;
@@ -67,7 +68,7 @@ class LLVMZeroValue : public llvm::GlobalVariable {
6768
return LLVMZeroValueInternalName;
6869
}
6970

70-
bool isLLVMZeroValue(const llvm::Value *V) {
71+
bool isLLVMZeroValue(const llvm::Value *V) const {
7172
if (V && V->hasName()) {
7273
// checks if V's name start with "zero_value"
7374
return V->getName().find(LLVMZeroValueInternalName) !=
@@ -77,9 +78,9 @@ class LLVMZeroValue : public llvm::GlobalVariable {
7778
}
7879

7980
// Do not specify a destructor (at all)!
80-
static LLVMZeroValue *getInstance() {
81-
static LLVMZeroValue *zv = new LLVMZeroValue;
82-
return zv;
81+
static const LLVMZeroValue *getInstance() {
82+
static const auto *ZV = new LLVMZeroValue;
83+
return ZV;
8384
}
8485
};
8586
} // namespace psr

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

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ template <typename D, typename V = BinaryDomain> class SpecialSummaries {
4747
// flow functions.
4848
SpecialSummaries() {
4949
// insert default flow and edge functions
50-
for (auto function_name :
50+
for (const auto &FunctionName :
5151
PhasarConfig::getPhasarConfig().specialFunctionNames()) {
5252
SpecialFlowFunctions.insert(
53-
std::make_pair(function_name, Identity<D>::getInstance()));
53+
std::make_pair(FunctionName, Identity<D>::getInstance()));
5454
SpecialEdgeFunctions.insert(
55-
std::make_pair(function_name, EdgeIdentity<V>::getInstance()));
55+
std::make_pair(FunctionName, EdgeIdentity<V>::getInstance()));
5656
}
5757
}
5858

@@ -64,62 +64,62 @@ template <typename D, typename V = BinaryDomain> class SpecialSummaries {
6464
~SpecialSummaries() = default;
6565

6666
static SpecialSummaries<D, V> &getInstance() {
67-
static SpecialSummaries<D, V> instance;
68-
return instance;
67+
static SpecialSummaries<D, V> Instance;
68+
return Instance;
6969
}
7070

7171
// Returns true, when an existing function is overwritten, false otherwise.
72-
bool provideSpecialSummary(const std::string &name,
73-
FlowFunctionPtrType flowfunction) {
74-
bool Override = containsSpecialSummary(name);
75-
SpecialFlowFunctions[name] = flowfunction;
72+
bool provideSpecialSummary(const std::string &Name,
73+
FlowFunctionPtrType FlowFunc) {
74+
bool Override = containsSpecialSummary(Name);
75+
SpecialFlowFunctions[Name] = FlowFunc;
7676
return Override;
7777
}
7878

7979
// Returns true, when an existing function is overwritten, false otherwise.
80-
bool provideSpecialSummary(const std::string &name,
81-
FlowFunctionPtrType flowfunction,
82-
std::shared_ptr<EdgeFunction<V>> edgefunction) {
83-
bool Override = containsSpecialSummary(name);
84-
SpecialFlowFunctions[name] = flowfunction;
85-
SpecialEdgeFunctions[name] = edgefunction;
80+
bool provideSpecialSummary(const std::string &Name,
81+
FlowFunctionPtrType FlowFunc,
82+
std::shared_ptr<EdgeFunction<V>> EdgeFunc) {
83+
bool Override = containsSpecialSummary(Name);
84+
SpecialFlowFunctions[Name] = FlowFunc;
85+
SpecialEdgeFunctions[Name] = EdgeFunc;
8686
return Override;
8787
}
8888

89-
bool containsSpecialSummary(const llvm::Function *function) {
90-
return containsSpecialSummary(function->getName().str());
89+
bool containsSpecialSummary(const llvm::Function *Func) {
90+
return containsSpecialSummary(Func->getName().str());
9191
}
9292

93-
bool containsSpecialSummary(const std::string &name) {
94-
return SpecialFlowFunctions.count(name);
93+
bool containsSpecialSummary(const std::string &Name) {
94+
return SpecialFlowFunctions.count(Name);
9595
}
9696

9797
FlowFunctionPtrType
98-
getSpecialFlowFunctionSummary(const llvm::Function *function) {
99-
return getSpecialFlowFunctionSummary(function->getName().str());
98+
getSpecialFlowFunctionSummary(const llvm::Function *Func) {
99+
return getSpecialFlowFunctionSummary(Func->getName().str());
100100
}
101101

102-
FlowFunctionPtrType getSpecialFlowFunctionSummary(const std::string &name) {
103-
return SpecialFlowFunctions[name];
102+
FlowFunctionPtrType getSpecialFlowFunctionSummary(const std::string &Name) {
103+
return SpecialFlowFunctions[Name];
104104
}
105105

106106
std::shared_ptr<EdgeFunction<V>>
107-
getSpecialEdgeFunctionSummary(const llvm::Function *function) {
108-
return getSpecialEdgeFunctionSummary(function->getName().str());
107+
getSpecialEdgeFunctionSummary(const llvm::Function *Func) {
108+
return getSpecialEdgeFunctionSummary(Func->getName().str());
109109
}
110110

111111
std::shared_ptr<EdgeFunction<V>>
112-
getSpecialEdgeFunctionSummary(const std::string &name) {
113-
return SpecialEdgeFunctions[name];
112+
getSpecialEdgeFunctionSummary(const std::string &Name) {
113+
return SpecialEdgeFunctions[Name];
114114
}
115115

116-
friend std::ostream &operator<<(std::ostream &os,
117-
const SpecialSummaries<D> &ss) {
118-
os << "SpecialSummaries:\n";
119-
for (auto &entry : ss.SpecialFunctionNames) {
120-
os << entry.first << " ";
116+
friend std::ostream &operator<<(std::ostream &OS,
117+
const SpecialSummaries<D> &SpecialSumms) {
118+
OS << "SpecialSummaries:\n";
119+
for (auto &Entry : SpecialSumms.SpecialFunctionNames) {
120+
OS << Entry.first << " ";
121121
}
122-
return os;
122+
return OS;
123123
}
124124
};
125125
} // namespace psr

0 commit comments

Comments
 (0)