Skip to content

Commit c6625c4

Browse files
author
Martin Mory
committed
Merge branch 'f-ClangTidyFixIDETSA' into f-ClangTidyFixIDEMiscAnalyses
2 parents 757fa7c + 6c90deb commit c6625c4

16 files changed

Lines changed: 173 additions & 177 deletions

File tree

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ class LLVMBasedICFG
321321

322322
template <typename Fn> void forEachGlobalCtor(Fn &&F) const {
323323
for (auto [Prio, Fun] : GlobalCtors) {
324-
F(static_cast<const llvm::Function *>(Fun));
324+
std::invoke(F, static_cast<const llvm::Function *>(Fun));
325325
}
326326
}
327327

328328
template <typename Fn> void forEachGlobalDtor(Fn &&F) const {
329329
for (auto [Prio, Fun] : GlobalDtors) {
330-
F(static_cast<const llvm::Function *>(Fun));
330+
std::invoke(F, static_cast<const llvm::Function *>(Fun));
331331
}
332332
}
333333

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class GenIf : public FlowFunction<D, Container> {
185185
: GenValues({GenValue}), Predicate(std::move(Predicate)) {}
186186

187187
GenIf(container_type GenValues, std::function<bool(D)> Predicate)
188-
: GenValues(std::move(GenValues)), Predicate(Predicate) {}
188+
: GenValues(std::move(GenValues)), Predicate(std::move(Predicate)) {}
189189

190190
~GenIf() override = default;
191191

@@ -274,7 +274,7 @@ class KillMultiple : public FlowFunction<D, Container> {
274274
KillMultiple(std::set<D> KillValues) : KillValues(std::move(KillValues)) {}
275275
~KillMultiple() override = default;
276276
container_type computeTargets(D Source) override {
277-
if (KillValues.find(Source) != KillValues.end()) {
277+
if (KillValues.count(Source)) {
278278
return {};
279279
}
280280
return {Source};

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSFieldSensTaintAnalysis/FlowFunctions/MapTaintedValuesToCaller.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class MapTaintedValuesToCaller : public FlowFunction<ExtendedValue> {
2020
MapTaintedValuesToCaller(const llvm::CallInst *CallInst,
2121
const llvm::ReturnInst *RetInst,
2222
TraceStats &TraceStats, const ExtendedValue &ZV)
23-
: CallInst(CallInst), RetInst(RetInst), TraceStats(TraceStats),
24-
ZV(ZV) {}
23+
: CallInst(CallInst), RetInst(RetInst), TraceStats(TraceStats), ZV(ZV) {}
2524
~MapTaintedValuesToCaller() override = default;
2625

2726
std::set<ExtendedValue> computeTargets(ExtendedValue Fact) override;

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSFieldSensTaintAnalysis/Utils/Log.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
#define LOG_INFO(x) \
1111
do { \
1212
llvm::outs() << "[ENV_TRACE] " << x << "\n"; /*NOLINT*/ \
13-
\
14-
llvm::outs() \
15-
.flush(); \
13+
\
14+
llvm::outs().flush(); \
1615
} while (0)
1716

1817
#ifdef DEBUG_BUILD

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,8 @@ class LLVMZeroValue : public llvm::GlobalVariable {
6868
return LLVMZeroValueInternalName;
6969
}
7070

71-
bool isLLVMZeroValue(const llvm::Value *V) const {
72-
if (V && V->hasName()) {
73-
// checks if V's name start with "zero_value"
74-
return V->getName().find(LLVMZeroValueInternalName) !=
75-
llvm::StringRef::npos;
76-
}
77-
return false;
71+
static bool isLLVMZeroValue(const llvm::Value *V) {
72+
return V == getInstance();
7873
}
7974

8075
// Do not specify a destructor (at all)!

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEGeneralizedLCA/EdgeValue.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class EdgeValue {
2929
enum Type { Top, Integer, String, FloatingPoint };
3030

3131
private:
32-
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t>
32+
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t>
3333
ValVariant = nullptr;
3434
Type VariantType;
3535

@@ -56,7 +56,7 @@ class EdgeValue {
5656
[[nodiscard]] Type getKind() const;
5757
// std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const;
5858
[[nodiscard]] bool sqSubsetEq(const EdgeValue &Other) const;
59-
[[nodiscard]] EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps Op,
59+
[[nodiscard]] EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps Op,
6060
const EdgeValue &Other) const;
6161
[[nodiscard]] EdgeValue typecast(Type Dest, unsigned Bits) const;
6262
EdgeValue &operator=(const EdgeValue &EV);
@@ -89,7 +89,7 @@ using ev_t = EdgeValueSet;
8989
ev_t performBinOp(llvm::BinaryOperator::BinaryOps Op, const ev_t &Lhs,
9090
const ev_t &Rhs, size_t MaxSize);
9191
ev_t performTypecast(const ev_t &Ev, EdgeValue::Type Dest, unsigned Bits);
92-
Ordering compare(const ev_t &Lhs, const ev_t &Rhs);
92+
Ordering compare(const ev_t &Lhs, const ev_t &Rhs);
9393
ev_t join(const ev_t &Lhs, const ev_t &Rhs, size_t MaxSize);
9494
/// \brief implements square subset equal
9595
bool operator<(const ev_t &Lhs, const ev_t &Rhs);
@@ -108,13 +108,13 @@ template <> struct hash<psr::EdgeValue> {
108108
double AsFloat;
109109
string AsString;
110110
if (Val.tryGetInt(AsInt)) {
111-
return hash<uint64_t>()(AsInt) * 31 + Hash;
112-
}
111+
return hash<uint64_t>()(AsInt) * 31 + Hash;
112+
}
113113
if (Val.tryGetFP(AsFloat)) {
114-
return hash<double>()(round(AsFloat)) * 31 + Hash;
115-
}
116-
if (Val.tryGetString(AsString)) {
117-
return hash<string>()(AsString) * 31 + Hash;
114+
return hash<double>()(round(AsFloat)) * 31 + Hash;
115+
}
116+
if (Val.tryGetString(AsString)) {
117+
return hash<string>()(AsString) * 31 + Hash;
118118
}
119119
return Hash;
120120
}

include/phasar/PhasarLLVM/DataFlowSolver/Mono/Contexts/CallStringCTX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ template <typename N, unsigned K> struct hash<psr::CallStringCTX<N, K>> {
9999

100100
} // namespace std
101101

102-
#endif
102+
#endif

lib/PhasarLLVM/ControlFlow/LLVMBasedICFG.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,13 @@ const llvm::Function *LLVMBasedICFG::getFunction(const string &Fun) const {
444444
}
445445

446446
const llvm::Function *LLVMBasedICFG::getFirstGlobalCtorOrNull() const {
447-
auto It = GlobalCtors.begin();
448-
if (It != GlobalCtors.end()) {
447+
if (auto It = GlobalCtors.begin(); It != GlobalCtors.end()) {
449448
return It->second;
450449
}
451450
return nullptr;
452451
}
453452
const llvm::Function *LLVMBasedICFG::getLastGlobalDtorOrNull() const {
454-
auto It = GlobalDtors.rbegin();
455-
if (It != GlobalDtors.rend()) {
453+
if (auto It = GlobalDtors.rbegin(); It != GlobalDtors.rend()) {
456454
return It->second;
457455
}
458456
return nullptr;
@@ -1273,8 +1271,8 @@ unsigned LLVMBasedICFG::getNumOfEdges() const {
12731271

12741272
const llvm::Function *
12751273
LLVMBasedICFG::getRegisteredDtorsCallerOrNull(const llvm::Module *Mod) {
1276-
auto It = GlobalRegisteredDtorsCaller.find(Mod);
1277-
if (It != GlobalRegisteredDtorsCaller.end()) {
1274+
if (auto It = GlobalRegisteredDtorsCaller.find(Mod);
1275+
It != GlobalRegisteredDtorsCaller.end()) {
12781276
return It->second;
12791277
}
12801278

lib/PhasarLLVM/ControlFlow/Resolver/Resolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Resolver::Resolver(ProjectIRDB &IRDB, LLVMTypeHierarchy &TH)
7777

7878
const llvm::Function *
7979
Resolver::getNonPureVirtualVFTEntry(const llvm::StructType *T, unsigned Idx,
80-
const llvm::CallBase */*CallSite*/) {
80+
const llvm::CallBase * /*CallSite*/) {
8181
if (TH && TH->hasVFTable(T)) {
8282
const auto *Target = TH->getVFTable(T)->getFunction(Idx);
8383
if (Target && Target->getName() != "__cxa_pure_virtual") {

lib/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/ComposeEdgeFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ namespace psr::XTaint {
1818
ComposeEdgeFunction::ComposeEdgeFunction(BasicBlockOrdering &BBO,
1919
EdgeFunctionPtrType F,
2020
EdgeFunctionPtrType G)
21-
: EdgeFunctionBase(EFKind::Compose, BBO), F(std::move(F)), G(std::move(G)) {}
21+
: EdgeFunctionBase(EFKind::Compose, BBO), F(std::move(F)), G(std::move(G)) {
22+
}
2223

2324
auto ComposeEdgeFunction::computeTarget(l_t Source) -> l_t {
2425
return G->computeTarget(F->computeTarget(Source));

0 commit comments

Comments
 (0)