Skip to content

Commit 3cbabd0

Browse files
authored
Merge branch 'development' into f-ClangTidyIdentifierRenameControlFlow
2 parents 1a62b42 + 8bcfd08 commit 3cbabd0

104 files changed

Lines changed: 1514 additions & 1440 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.

include/phasar/Config/Configuration.h

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,51 +35,59 @@ namespace psr {
3535
class PhasarConfig {
3636
public:
3737
/// Current Phasar version
38+
// NOLINTNEXTLINE(readability-identifier-naming)
3839
static std::string PhasarVersion() { return XSTR(PHASAR_VERSION); }
3940

4041
/// Stores the label/ tag with which we annotate the LLVM IR.
42+
// NOLINTNEXTLINE(readability-identifier-naming)
4143
static std::string MetaDataKind() { return "psr.id"; }
4244

43-
static std::string ConfigurationDirectory() {
44-
return configuration_directory;
45-
}
45+
// NOLINTNEXTLINE(readability-identifier-naming)
46+
static std::string ConfigurationDirectory() { return ConfigDir; }
4647

4748
/// Specifies the directory in which Phasar is located.
49+
// NOLINTNEXTLINE(readability-identifier-naming)
4850
static std::string PhasarDirectory() { return PhasarDir; }
4951

5052
/// Name of the file storing all standard header search paths used for
5153
/// compilation.
54+
// NOLINTNEXTLINE(readability-identifier-naming)
5255
static std::string HeaderSearchPathsFileName() {
5356
return "standard_header_paths.conf";
5457
}
5558

5659
/// Name of the compile_commands.json file (in case we wish to rename)
60+
// NOLINTNEXTLINE(readability-identifier-naming)
5761
static std::string CompileCommandsJson() { return "compile_commands.json"; }
5862

5963
/// Default Source- and Sink-Functions path
64+
// NOLINTNEXTLINE(readability-identifier-naming)
6065
static std::string DefaultSourceSinkFunctionsPath() {
6166
return std::string(PhasarDirectory() +
6267
"config/phasar-source-sink-function.json");
6368
}
6469

6570
// Variables to be used in JSON export format
6671
/// Identifier for call graph export
72+
// NOLINTNEXTLINE(readability-identifier-naming)
6773
static std::string JsonCallGraphID() { return "psr.cg"; }
6874

6975
/// Identifier for type hierarchy graph export
76+
// NOLINTNEXTLINE(readability-identifier-naming)
7077
static std::string JsonTypeHierarchyID() { return "psr.th"; }
7178

7279
/// Identifier for points-to graph export
80+
// NOLINTNEXTLINE(readability-identifier-naming)
7381
static std::string JsonPointsToGraphID() { return "psr.pt"; }
7482

7583
/// Identifier for data-flow results export
84+
// NOLINTNEXTLINE(readability-identifier-naming)
7685
static std::string JsonDataFlowID() { return "psr.df"; }
7786

7887
static PhasarConfig &getPhasarConfig();
7988

8089
llvm::iterator_range<std::set<std::string>::iterator> specialFunctionNames() {
81-
return llvm::make_range(special_function_names.begin(),
82-
special_function_names.end());
90+
return llvm::make_range(SpecialFuncNames.begin(), SpecialFuncNames.end());
8391
}
8492

8593
/// Add a function name to the special functions list.
@@ -89,41 +97,44 @@ class PhasarConfig {
8997
/// Remark: Manually added special functions need to be added before creating
9098
/// the analysis.
9199
void addSpecialFunctionName(std::string SFName) {
92-
special_function_names.insert(std::move(SFName));
100+
SpecialFuncNames.insert(std::move(SFName));
93101
}
94102

95103
/// Variables map of the parsed command-line parameters
104+
// NOLINTNEXTLINE(readability-identifier-naming)
96105
static boost::program_options::variables_map &VariablesMap() {
97-
static boost::program_options::variables_map variables_map;
98-
return variables_map;
106+
static boost::program_options::variables_map VMap;
107+
return VMap;
99108
}
100109

101110
~PhasarConfig() = default;
102111
PhasarConfig(const PhasarConfig &) = delete;
112+
PhasarConfig operator=(const PhasarConfig &) = delete;
103113
PhasarConfig(PhasarConfig &&) = delete;
114+
PhasarConfig operator=(PhasarConfig &&) = delete;
104115

105116
private:
106117
PhasarConfig();
107118

108-
static std::string readConfigFile(const std::string &path);
119+
static std::string readConfigFile(const std::string &Path);
109120
void loadGlibcSpecialFunctionNames();
110121
void loadLLVMSpecialFunctionNames();
111122

112-
std::set<std::string> special_function_names;
123+
std::set<std::string> SpecialFuncNames;
113124

114125
/// Specifies the directory in which important configuration files are
115126
/// located.
116-
inline static const std::string configuration_directory = []() {
117-
auto *env_home = std::getenv("HOME");
118-
std::string config_folder = "config/";
119-
if (env_home) { // Check if HOME was defined in the environment
120-
std::string phasar_config = std::string(env_home) + "/.config/phasar/";
121-
if (boost::filesystem::exists(phasar_config) &&
122-
boost::filesystem::is_directory(phasar_config)) {
123-
config_folder = phasar_config;
127+
inline static const std::string ConfigDir = []() {
128+
auto *EnvHome = std::getenv("HOME");
129+
std::string ConfigFolder = "config/";
130+
if (EnvHome) { // Check if HOME was defined in the environment
131+
std::string PhasarConfDir = std::string(EnvHome) + "/.config/phasar/";
132+
if (boost::filesystem::exists(PhasarConfDir) &&
133+
boost::filesystem::is_directory(PhasarConfDir)) {
134+
ConfigFolder = PhasarConfDir;
124135
}
125136
}
126-
return config_folder;
137+
return ConfigFolder;
127138
}();
128139

129140
/// Specifies the directory in which Phasar is located.

include/phasar/Controller/AnalysisController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ class AnalysisController {
128128
~AnalysisController() = default;
129129

130130
AnalysisController(const AnalysisController &) = delete;
131-
132131
AnalysisController(AnalysisController &&) = delete;
132+
AnalysisController &operator=(const AnalysisController &) = delete;
133+
AnalysisController &operator=(const AnalysisController &&) = delete;
133134

134135
void executeAs(AnalysisStrategy Strategy);
135136
};

include/phasar/DB/Hexastore.h

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,29 @@ namespace psr {
2525
/**
2626
* @brief Holds the results of a query to the Hexastore.
2727
*/
28-
struct hs_result {
28+
struct HSResult {
2929
/// Used for the source node.
30-
std::string subject;
30+
std::string Subject;
3131
/// Used for the edge.
32-
std::string predicate;
32+
std::string Predicate;
3333
/// Used for the destination node.
34-
std::string object;
35-
hs_result() = default;
36-
hs_result(std::string s, std::string p, std::string o)
37-
: subject(s), predicate(p), object(o) {}
34+
std::string Object;
35+
HSResult() = default;
36+
HSResult(const std::string Subject, // NOLINT
37+
std::string Predicate, // NOLINT
38+
std::string Object) // NOLINT
39+
: Subject(Subject), Predicate(std::move(Predicate)),
40+
Object(std::move(Object)) {}
3841
/// Prints an entry of the results to the command-line
39-
friend std::ostream &operator<<(std::ostream &os, const hs_result &hsr) {
40-
return os << "[ subject: " << hsr.subject
41-
<< " | predicate: " << hsr.predicate
42-
<< " | object: " << hsr.object << " ]";
42+
friend std::ostream &operator<<(std::ostream &OS, const HSResult &Result) {
43+
return OS << "[ subject: " << Result.Subject
44+
<< " | predicate: " << Result.Predicate
45+
<< " | object: " << Result.Object << " ]";
4346
}
4447

45-
friend bool operator==(const hs_result LHS, const hs_result RHS) {
46-
return LHS.subject == RHS.subject && LHS.predicate == RHS.predicate &&
47-
LHS.object == RHS.object;
48+
friend bool operator==(const HSResult &LHS, const HSResult &RHS) {
49+
return LHS.Subject == RHS.Subject && LHS.Predicate == RHS.Predicate &&
50+
LHS.Object == RHS.Object;
4851
}
4952
};
5053
/**
@@ -67,9 +70,10 @@ struct hs_result {
6770
*/
6871
class Hexastore {
6972
private:
70-
sqlite3 *hs_internal_db{};
71-
static int callback(void *NotUsed, int argc, char **argv, char **azColName);
72-
void doPut(const std::string &query, std::array<std::string, 3> edge);
73+
sqlite3 *HSInternalDB{};
74+
static int callback(void * /*NotUsed*/, int Argc, char **Argv,
75+
char **AzColName);
76+
void doPut(const std::string &Query, std::array<std::string, 3> Edge);
7377

7478
public:
7579
/**
@@ -80,7 +84,9 @@ class Hexastore {
8084
* @brief Constructs a Hexastore under the given filename.
8185
* @param filename Filename of the Hexastore.
8286
*/
83-
Hexastore(const std::string &filename);
87+
Hexastore(const std::string &FileName);
88+
Hexastore(const Hexastore &) = delete;
89+
Hexastore &operator=(const Hexastore &) = delete;
8490

8591
/**
8692
* Destructor.
@@ -98,7 +104,7 @@ class Hexastore {
98104
* hexastore.put({{"subject", "predicate", "object"}});
99105
* @param edge New entry in the form of a 3-tuple.
100106
*/
101-
void put(const std::array<std::string, 3> &edge);
107+
void put(const std::array<std::string, 3> &Edge);
102108

103109
/**
104110
* A query is always in the form of a 3-tuple (source, edge, destination)
@@ -115,8 +121,8 @@ class Hexastore {
115121
* @param result_size_hint Used for possible optimization.
116122
* @return An object of hs_result, holding the queried information.
117123
*/
118-
std::vector<hs_result> get(std::array<std::string, 3> EdgeQuery,
119-
size_t ResultSizeHint = 0);
124+
std::vector<HSResult> get(std::array<std::string, 3> EdgeQuery,
125+
size_t ResultSizeHint = 0);
120126
};
121127

122128
} // namespace psr

include/phasar/PhasarLLVM/AnalysisStrategy/WholeProgramAnalysis.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ class WholeProgramAnalysis {
124124
DataFlowSolver(ProblemDesc) {}
125125

126126
WholeProgramAnalysis(const WholeProgramAnalysis &) = delete;
127-
128127
WholeProgramAnalysis(WholeProgramAnalysis &&) = delete;
128+
WholeProgramAnalysis &operator=(WholeProgramAnalysis &) = delete;
129+
WholeProgramAnalysis &operator=(WholeProgramAnalysis &&) = delete;
129130

130131
~WholeProgramAnalysis() {
131132
if (OwnsConfig) {

include/phasar/PhasarLLVM/ControlFlow/ICFG.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,33 @@ template <typename N, typename F> class ICFG : public virtual CFG<N, F> {
5959
public:
6060
~ICFG() override = default;
6161

62-
virtual std::set<F> getAllFunctions() const = 0;
62+
[[nodiscard]] virtual std::set<F> getAllFunctions() const = 0;
6363

64-
virtual F getFunction(const std::string &Fun) const = 0;
64+
[[nodiscard]] virtual F getFunction(const std::string &Fun) const = 0;
6565

66-
virtual bool isIndirectFunctionCall(N Stmt) const = 0;
66+
[[nodiscard]] virtual bool isIndirectFunctionCall(N Stmt) const = 0;
6767

68-
virtual bool isVirtualFunctionCall(N Stmt) const = 0;
68+
[[nodiscard]] virtual bool isVirtualFunctionCall(N Stmt) const = 0;
6969

70-
virtual std::set<N> allNonCallStartNodes() const = 0;
70+
[[nodiscard]] virtual std::set<N> allNonCallStartNodes() const = 0;
7171

72-
virtual std::set<F> getCalleesOfCallAt(N Stmt) const = 0;
72+
[[nodiscard]] virtual std::set<F> getCalleesOfCallAt(N Stmt) const = 0;
7373

74-
virtual std::set<N> getCallersOf(F Fun) const = 0;
74+
[[nodiscard]] virtual std::set<N> getCallersOf(F Fun) const = 0;
7575

76-
virtual std::set<N> getCallsFromWithin(F Fun) const = 0;
76+
[[nodiscard]] virtual std::set<N> getCallsFromWithin(F Fun) const = 0;
7777

78-
virtual std::set<N> getReturnSitesOfCallAt(N Stmt) const = 0;
78+
[[nodiscard]] virtual std::set<N> getReturnSitesOfCallAt(N Stmt) const = 0;
7979

80-
const std::vector<F> &getGlobalInitializers() const {
80+
[[nodiscard]] const std::vector<F> &getGlobalInitializers() const {
8181
return GlobalInitializers;
8282
}
8383

8484
using CFG<N, F>::print; // tell the compiler we wish to have both prints
8585
virtual void print(std::ostream &OS = std::cout) const = 0;
8686

8787
using CFG<N, F>::getAsJson; // tell the compiler we wish to have both prints
88-
virtual nlohmann::json getAsJson() const = 0;
88+
[[nodiscard]] virtual nlohmann::json getAsJson() const = 0;
8989
};
9090

9191
} // namespace psr

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class LLVMBasedICFG
183183
Soundness S = Soundness::Soundy, bool IncludeGlobals = true);
184184

185185
LLVMBasedICFG(const LLVMBasedICFG &ICF);
186+
186187
LLVMBasedICFG &operator=(const LLVMBasedICFG &) = delete;
187188

188189
~LLVMBasedICFG() override;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ namespace psr {
2525

2626
template <typename N, typename D> class DefaultSeeds {
2727
public:
28-
static std::map<N, std::set<D>> make(std::vector<N> node, D zeroNode) {
29-
std::map<N, std::set<D>> res;
30-
for (N n : node) {
31-
res.insert(n, std::set<D>{zeroNode});
28+
static std::map<N, std::set<D>> make(std::vector<N> Nodes, D ZeroNode) {
29+
std::map<N, std::set<D>> Result;
30+
for (N Node : Nodes) {
31+
Result.insert(std::move(Node), {ZeroNode});
3232
}
33-
return res;
33+
return Result;
3434
}
3535
};
3636

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace psr {
1919
class EdgeFact {
2020
public:
2121
virtual ~EdgeFact() = default;
22-
virtual void print(std::ostream &os) const = 0;
22+
virtual void print(std::ostream &OS) const = 0;
2323
};
2424

2525
static inline std::ostream &operator<<(std::ostream &OS, const EdgeFact &E) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ template <typename T> class EdgeFactWrapper : public EdgeFact {
3333
using l_t = T;
3434
EdgeFactWrapper(const T &F) : Fact(F) {}
3535
EdgeFactWrapper(T &&F) : Fact(std::move(F)) {}
36-
virtual ~EdgeFactWrapper() = default;
37-
const T &get() const { return Fact; }
36+
~EdgeFactWrapper() override = default;
37+
[[nodiscard]] const T &get() const { return Fact; }
3838
void print(std::ostream &OS) const override { OS << Fact << '\n'; }
3939
};
4040

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class EdgeFunctionComposer
3939

4040
private:
4141
// For debug purpose only
42-
const unsigned EFComposer_Id;
43-
static inline unsigned CurrEFComposer_Id = 0;
42+
const unsigned EFComposerId;
43+
static inline unsigned CurrEFComposerId = 0; // NOLINT
4444

4545
protected:
4646
/// First edge function
@@ -49,17 +49,17 @@ class EdgeFunctionComposer
4949
EdgeFunctionPtrType G;
5050

5151
public:
52-
EdgeFunctionComposer(EdgeFunctionPtrType F, EdgeFunctionPtrType G)
53-
: EFComposer_Id(++CurrEFComposer_Id), F(F), G(G) {}
52+
EdgeFunctionComposer(EdgeFunctionPtrType &F, EdgeFunctionPtrType &G)
53+
: EFComposerId(++CurrEFComposerId), F(F), G(G) {}
5454

5555
~EdgeFunctionComposer() override = default;
5656

5757
/**
5858
* Target value computation is implemented as
5959
* G(F(source))
6060
*/
61-
L computeTarget(L source) override {
62-
return G->computeTarget(F->computeTarget(source));
61+
L computeTarget(L Source) override {
62+
return G->computeTarget(F->computeTarget(Source));
6363
}
6464

6565
/**
@@ -69,29 +69,30 @@ class EdgeFunctionComposer
6969
* However, it is advised to immediately reduce the resulting edge function
7070
* by providing an own implementation of this function.
7171
*/
72-
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType secondFunction) override {
73-
if (auto *EI = dynamic_cast<EdgeIdentity<L> *>(secondFunction.get())) {
72+
EdgeFunctionPtrType composeWith(EdgeFunctionPtrType SecondFunction) override {
73+
if (auto *EI = dynamic_cast<EdgeIdentity<L> *>(SecondFunction.get())) {
7474
return this->shared_from_this();
7575
}
76-
if (auto *AB = dynamic_cast<AllBottom<L> *>(secondFunction.get())) {
76+
if (auto *AB = dynamic_cast<AllBottom<L> *>(SecondFunction.get())) {
7777
return this->shared_from_this();
7878
}
79-
return F->composeWith(G->composeWith(secondFunction));
79+
return F->composeWith(G->composeWith(SecondFunction));
8080
}
8181

8282
// virtual EdgeFunctionPtrType
8383
// joinWith(EdgeFunctionPtrType otherFunction) = 0;
8484

85-
bool equal_to(EdgeFunctionPtrType other) const override {
86-
if (auto EFC = dynamic_cast<EdgeFunctionComposer<L> *>(other.get())) {
85+
bool equal_to // NOLINT - would break too many client analyses
86+
(EdgeFunctionPtrType Other) const override {
87+
if (auto EFC = dynamic_cast<EdgeFunctionComposer<L> *>(Other.get())) {
8788
return F->equal_to(EFC->F) && G->equal_to(EFC->G);
8889
}
8990
return false;
9091
}
9192

92-
void print(std::ostream &OS, bool isForDebug = false) const override {
93+
void print(std::ostream &OS, bool /*IsForDebug = false*/) const override {
9394
OS << "COMP[ " << F.get()->str() << " , " << G.get()->str()
94-
<< " ] (EF:" << EFComposer_Id << ')';
95+
<< " ] (EF:" << EFComposerId << ')';
9596
}
9697
};
9798

0 commit comments

Comments
 (0)