Skip to content

Commit 8192175

Browse files
authored
Merge branch 'development' into f-SolverConfigParams
2 parents a4d3798 + 61a8aad commit 8192175

89 files changed

Lines changed: 2373 additions & 2281 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Checks: '-*,
1616
-readability-convert-member-functions-to-static,
1717
-readability-isolate-declaration,
1818
cppcoreguidelines-*,
19+
-cppcoreguidelines-avoid-non-const-global-variables,
1920
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
2021
-cppcoreguidelines-owning-memory,
2122
-cppcoreguidelines-pro-type-reinterpret-cast,
@@ -53,6 +54,8 @@ CheckOptions:
5354
value: (c|d|d1|d2|d3|d4|d5|d5_restoredCtx|eP|f|f3|f4|f5|fCalleeSummary|g|n|dPrime|fPrime)
5455
- key: readability-identifier-naming.ParameterIgnoredRegexp
5556
value: (d|d1|d2|d3|d4|d5|eP|f|n)
57+
- key: readability-identifier-naming.FunctionIgnoredRegexp
58+
value: (try_emplace|from_json|to_json)
5659
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
5760
value: 1
5861
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions

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: 1 addition & 1 deletion
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

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)!
Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,125 @@
1-
/******************************************************************************
2-
* Copyright (c) 2020 Fabian Schiebel.
3-
* All rights reserved. This program and the accompanying materials are made
4-
* available under the terms of LICENSE.txt.
5-
*
6-
* Contributors:
7-
* Fabian Schiebel, Alexander Meinhold and others
8-
*****************************************************************************/
9-
10-
#ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H_
11-
#define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H_
12-
13-
#include <iostream>
14-
#include <memory>
15-
#include <unordered_set>
16-
#include <variant>
17-
18-
#include "llvm/ADT/APSInt.h"
19-
#include "llvm/ADT/Twine.h"
20-
#include "llvm/IR/Constant.h"
21-
#include "llvm/IR/Instructions.h"
22-
23-
namespace psr {
24-
25-
enum class Ordering { Less, Greater, Equal, Incomparable };
26-
27-
class EdgeValue {
28-
public:
29-
enum Type { Top, Integer, String, FloatingPoint };
30-
31-
private:
32-
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t>
33-
ValVariant = nullptr;
34-
Type VariantType;
35-
36-
public:
37-
EdgeValue(const llvm::Value *Val);
38-
EdgeValue(const EdgeValue &EV);
39-
EdgeValue(llvm::APInt &&VI);
40-
EdgeValue(const llvm::APInt &VI);
41-
EdgeValue(llvm::APFloat &&VF);
42-
EdgeValue(long long VI);
43-
EdgeValue(int VI);
44-
EdgeValue(double Double);
45-
EdgeValue(float Float);
46-
EdgeValue(std::string &&VS);
47-
EdgeValue(std::nullptr_t);
48-
~EdgeValue();
49-
const static EdgeValue TopValue;
50-
[[nodiscard]] bool tryGetInt(uint64_t &Res) const;
51-
[[nodiscard]] bool tryGetFP(double &Res) const;
52-
[[nodiscard]] bool tryGetString(std::string &Res) const;
53-
[[nodiscard]] bool isTop() const;
54-
[[nodiscard]] bool isNumeric() const;
55-
[[nodiscard]] bool isString() const;
56-
[[nodiscard]] Type getKind() const;
57-
// std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const;
58-
[[nodiscard]] bool sqSubsetEq(const EdgeValue &Other) const;
59-
[[nodiscard]] EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps Op,
60-
const EdgeValue &Other) const;
61-
[[nodiscard]] EdgeValue typecast(Type Dest, unsigned Bits) const;
62-
EdgeValue &operator=(const EdgeValue &EV);
63-
64-
operator bool();
65-
friend bool operator==(const EdgeValue &Lhs, const EdgeValue &Rhs);
66-
67-
// binary operators
68-
friend EdgeValue operator+(const EdgeValue &Lhs, const EdgeValue &Rhs);
69-
friend EdgeValue operator-(const EdgeValue &Lhs, const EdgeValue &Rhs);
70-
friend EdgeValue operator*(const EdgeValue &Lhs, const EdgeValue &Rhs);
71-
friend EdgeValue operator/(const EdgeValue &Lhs, const EdgeValue &Rhs);
72-
friend EdgeValue operator%(const EdgeValue &Lhs, const EdgeValue &Rhs);
73-
friend EdgeValue operator&(const EdgeValue &Lhs, const EdgeValue &Rhs);
74-
friend EdgeValue operator|(const EdgeValue &Lhs, const EdgeValue &Rhs);
75-
friend EdgeValue operator^(const EdgeValue &Lhs, const EdgeValue &Rhs);
76-
friend EdgeValue operator<<(const EdgeValue &Lhs, const EdgeValue &Rhs);
77-
friend EdgeValue operator>>(const EdgeValue &Lhs, const EdgeValue &Rhs);
78-
static int compare(const EdgeValue &Lhs, const EdgeValue &Rhs);
79-
80-
// unary operators
81-
EdgeValue operator-() const;
82-
EdgeValue operator~() const;
83-
friend std::ostream &operator<<(std::ostream &Os, const EdgeValue &EV);
84-
static std::string typeToString(Type Ty);
85-
};
86-
class EdgeValueSet;
87-
typedef EdgeValueSet ev_t;
88-
89-
ev_t performBinOp(llvm::BinaryOperator::BinaryOps Op, const ev_t &Lhs,
90-
const ev_t &Rhs, size_t MaxSize);
91-
ev_t performTypecast(const ev_t &Ev, EdgeValue::Type Dest, unsigned Bits);
92-
Ordering compare(const ev_t &Lhs, const ev_t &Rhs);
93-
ev_t join(const ev_t &Lhs, const ev_t &Rhs, size_t MaxSize);
94-
/// \brief implements square subset equal
95-
bool operator<(const ev_t &Lhs, const ev_t &Rhs);
96-
bool isTopValue(const ev_t &Val);
97-
std::ostream &operator<<(std::ostream &Os, const ev_t &Val);
98-
99-
} // namespace psr
100-
101-
namespace std {
102-
103-
template <> struct hash<psr::EdgeValue> {
104-
hash() = default;
105-
size_t operator()(const psr::EdgeValue &Val) const {
106-
auto Hash = hash<int>()(Val.getKind());
107-
uint64_t AsInt;
108-
double AsFloat;
109-
string AsString;
110-
if (Val.tryGetInt(AsInt)) {
111-
return hash<uint64_t>()(AsInt) * 31 + Hash;
112-
}
113-
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;
118-
}
119-
return Hash;
120-
}
121-
};
122-
123-
} // namespace std
124-
125-
#endif
1+
/******************************************************************************
2+
* Copyright (c) 2020 Fabian Schiebel.
3+
* All rights reserved. This program and the accompanying materials are made
4+
* available under the terms of LICENSE.txt.
5+
*
6+
* Contributors:
7+
* Fabian Schiebel, Alexander Meinhold and others
8+
*****************************************************************************/
9+
10+
#ifndef PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H
11+
#define PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_PROBLEMS_IDEGENERALIZEDLCA_EDGEVALUE_H
12+
13+
#include <iostream>
14+
#include <memory>
15+
#include <unordered_set>
16+
#include <variant>
17+
18+
#include "llvm/ADT/APSInt.h"
19+
#include "llvm/ADT/Twine.h"
20+
#include "llvm/IR/Constant.h"
21+
#include "llvm/IR/Instructions.h"
22+
23+
namespace psr {
24+
25+
enum class Ordering { Less, Greater, Equal, Incomparable };
26+
27+
class EdgeValue {
28+
public:
29+
enum Type { Top, Integer, String, FloatingPoint };
30+
31+
private:
32+
std::variant<llvm::APInt, llvm::APFloat, std::string, std::nullptr_t>
33+
ValVariant = nullptr;
34+
Type VariantType;
35+
36+
public:
37+
EdgeValue(const llvm::Value *Val);
38+
EdgeValue(const EdgeValue &EV);
39+
EdgeValue(llvm::APInt &&VI);
40+
EdgeValue(const llvm::APInt &VI);
41+
EdgeValue(llvm::APFloat &&VF);
42+
EdgeValue(long long VI);
43+
EdgeValue(int VI);
44+
EdgeValue(double Double);
45+
EdgeValue(float Float);
46+
EdgeValue(std::string &&VS);
47+
EdgeValue(std::nullptr_t);
48+
~EdgeValue();
49+
const static EdgeValue TopValue;
50+
[[nodiscard]] bool tryGetInt(uint64_t &Res) const;
51+
[[nodiscard]] bool tryGetFP(double &Res) const;
52+
[[nodiscard]] bool tryGetString(std::string &Res) const;
53+
[[nodiscard]] bool isTop() const;
54+
[[nodiscard]] bool isNumeric() const;
55+
[[nodiscard]] bool isString() const;
56+
[[nodiscard]] Type getKind() const;
57+
// std::unique_ptr<ObjectLLVM> asObjLLVM(llvm::LLVMContext &ctx) const;
58+
[[nodiscard]] bool sqSubsetEq(const EdgeValue &Other) const;
59+
[[nodiscard]] EdgeValue performBinOp(llvm::BinaryOperator::BinaryOps Op,
60+
const EdgeValue &Other) const;
61+
[[nodiscard]] EdgeValue typecast(Type Dest, unsigned Bits) const;
62+
EdgeValue &operator=(const EdgeValue &EV);
63+
64+
operator bool();
65+
friend bool operator==(const EdgeValue &Lhs, const EdgeValue &Rhs);
66+
67+
// binary operators
68+
friend EdgeValue operator+(const EdgeValue &Lhs, const EdgeValue &Rhs);
69+
friend EdgeValue operator-(const EdgeValue &Lhs, const EdgeValue &Rhs);
70+
friend EdgeValue operator*(const EdgeValue &Lhs, const EdgeValue &Rhs);
71+
friend EdgeValue operator/(const EdgeValue &Lhs, const EdgeValue &Rhs);
72+
friend EdgeValue operator%(const EdgeValue &Lhs, const EdgeValue &Rhs);
73+
friend EdgeValue operator&(const EdgeValue &Lhs, const EdgeValue &Rhs);
74+
friend EdgeValue operator|(const EdgeValue &Lhs, const EdgeValue &Rhs);
75+
friend EdgeValue operator^(const EdgeValue &Lhs, const EdgeValue &Rhs);
76+
friend EdgeValue operator<<(const EdgeValue &Lhs, const EdgeValue &Rhs);
77+
friend EdgeValue operator>>(const EdgeValue &Lhs, const EdgeValue &Rhs);
78+
static int compare(const EdgeValue &Lhs, const EdgeValue &Rhs);
79+
80+
// unary operators
81+
EdgeValue operator-() const;
82+
EdgeValue operator~() const;
83+
friend std::ostream &operator<<(std::ostream &Os, const EdgeValue &EV);
84+
static std::string typeToString(Type Ty);
85+
};
86+
class EdgeValueSet;
87+
using ev_t = EdgeValueSet;
88+
89+
ev_t performBinOp(llvm::BinaryOperator::BinaryOps Op, const ev_t &Lhs,
90+
const ev_t &Rhs, size_t MaxSize);
91+
ev_t performTypecast(const ev_t &Ev, EdgeValue::Type Dest, unsigned Bits);
92+
Ordering compare(const ev_t &Lhs, const ev_t &Rhs);
93+
ev_t join(const ev_t &Lhs, const ev_t &Rhs, size_t MaxSize);
94+
/// \brief implements square subset equal
95+
bool operator<(const ev_t &Lhs, const ev_t &Rhs);
96+
bool isTopValue(const ev_t &Val);
97+
std::ostream &operator<<(std::ostream &Os, const ev_t &Val);
98+
99+
} // namespace psr
100+
101+
namespace std {
102+
103+
template <> struct hash<psr::EdgeValue> {
104+
hash() = default;
105+
size_t operator()(const psr::EdgeValue &Val) const {
106+
auto Hash = hash<int>()(Val.getKind());
107+
uint64_t AsInt;
108+
double AsFloat;
109+
string AsString;
110+
if (Val.tryGetInt(AsInt)) {
111+
return hash<uint64_t>()(AsInt) * 31 + Hash;
112+
}
113+
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;
118+
}
119+
return Hash;
120+
}
121+
};
122+
123+
} // namespace std
124+
125+
#endif

0 commit comments

Comments
 (0)