Skip to content

Commit 73d8f8b

Browse files
authored
Merge branch 'development' into f-LLVM13Support
2 parents fd711a5 + 6ac85b2 commit 73d8f8b

325 files changed

Lines changed: 6950 additions & 6581 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ Checks: '-*,
55
-misc-non-private-member-variables-in-classes,
66
-misc-no-recursion,
77
readability-*,
8+
-readability-function-cognitive-complexity,
89
-readability-else-after*,
910
-readability-simplify-boolean-expr,
1011
-readability-implicit-bool-cast,
1112
-readability-static-definition-in-anonymous-namespace,
1213
-readability-implicit-bool-conversion,
1314
-readability-magic-numbers,
15+
-readability-function-cognitive-complexity,
16+
-readability-convert-member-functions-to-static,
17+
-readability-isolate-declaration,
1418
cppcoreguidelines-*,
19+
-cppcoreguidelines-avoid-non-const-global-variables,
1520
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
1621
-cppcoreguidelines-owning-memory,
1722
-cppcoreguidelines-pro-type-reinterpret-cast,
@@ -20,8 +25,10 @@ Checks: '-*,
2025
-cppcoreguidelines-init-variables,
2126
-cppcoreguidelines-macro-usage,
2227
bugprone-*,
28+
-bugprone-easily-swappable-parameters,
2329
modernize-*,
2430
-modernize-use-trailing-return-type,
31+
-modernize-pass-by-value,
2532
performance-*,
2633
clang-analyzer-*,
2734
'
@@ -43,6 +50,12 @@ CheckOptions:
4350
value: CamelCase
4451
- key: readability-identifier-naming.VariableCase
4552
value: CamelCase
53+
- key: readability-identifier-naming.VariableIgnoredRegexp
54+
value: (c|d|d1|d2|d3|d4|d5|d5_restoredCtx|eP|f|f3|f4|f5|fCalleeSummary|g|n|dPrime|fPrime)
55+
- key: readability-identifier-naming.ParameterIgnoredRegexp
56+
value: (d|d1|d2|d3|d4|d5|eP|f|n)
57+
- key: readability-identifier-naming.FunctionIgnoredRegexp
58+
value: (try_emplace|from_json|to_json)
4659
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
4760
value: 1
4861
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions

CMakeLists.txt

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ include(GNUInstallDirs)
2020
set_property(GLOBAL PROPERTY TARGET_MESSAGES OFF)
2121

2222
if (NOT CMAKE_BUILD_TYPE)
23-
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('Debug' or 'Release', default is 'Debug')" FORCE)
23+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('DebugSan' or 'Debug' or 'Release', default is 'Debug')" FORCE)
2424
endif ()
25-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
25+
26+
if(CMAKE_BUILD_TYPE STREQUAL "DebugSan")
27+
message(STATUS "Selected Debug Build with sanitizers")
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -g -fno-omit-frame-pointer -fsanitize=address,undefined")
29+
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
30+
message(STATUS "Selected Debug Build")
2631
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -g")
2732
else()
33+
message(STATUS "Selected Release Build")
2834
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -march=native")
2935
endif()
3036

@@ -43,7 +49,6 @@ file(STRINGS ${PHASAR_SRC_DIR}/include/phasar/Config/Version.h VERSION_NUMBER_FI
4349
string(REPLACE " " ";" VERSION_NUMBER_FILE ${VERSION_NUMBER_FILE})
4450
list(GET VERSION_NUMBER_FILE 2 VERSION_NUMBER_PHASAR)
4551

46-
4752
include("phasar_macros")
4853

4954
option(PHASAR_BUILD_UNITTESTS "Build all tests (default is ON)" ON)
@@ -52,6 +57,8 @@ option(PHASAR_BUILD_OPENSSL_TS_UNITTESTS "Build OPENSSL typestate tests (require
5257

5358
option(PHASAR_BUILD_IR "Build IR test code (default is ON)" ON)
5459

60+
option(PHASAR_ENABLE_CLANG_TIDY_DURING_BUILD "Run clang-tidy during build (default is OFF)" OFF)
61+
5562
option(PHASAR_BUILD_DOC "Build documentation" OFF)
5663

5764
option(PHASAR_DEBUG_LIBDEPS "Debug internal library dependencies (private linkage)" OFF)
@@ -96,12 +103,10 @@ endif()
96103
configure_file(config.h.in config.h @ONLY)
97104
include_directories(${CMAKE_CURRENT_BINARY_DIR})
98105

99-
100106
include_directories(
101107
${PHASAR_SRC_DIR}/include
102108
)
103109

104-
105110
set(PHASAR_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/phasar)
106111

107112
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${PHASAR_INSTALL_LIBDIR})
@@ -122,6 +127,9 @@ find_package(Boost 1.65.1 COMPONENTS filesystem graph system program_options log
122127
#find_package(Boost 1.72.0 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
123128
include_directories(${Boost_INCLUDE_DIRS})
124129

130+
# Disable clang-tidy for the external projects
131+
set(CMAKE_CXX_CLANG_TIDY "")
132+
125133
# We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here
126134
# The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator
127135
# is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as
@@ -237,8 +245,17 @@ endif()
237245
add_subdirectory(external/WALi-OpenNWA)
238246
include_directories(external/WALi-OpenNWA/Source/wali/include)
239247

248+
# Set up clang-tidy to run during PhASAR's compilation to indicate code smells
249+
if (PHASAR_ENABLE_CLANG_TIDY_DURING_BUILD)
250+
message(STATUS "Enabled clang-tidy during build")
251+
set(CMAKE_CXX_CLANG_TIDY
252+
clang-tidy;
253+
-header-filter=include/phasar.*h$;
254+
# -warnings-as-errors=*;
255+
)
256+
endif ()
240257

241-
# Add the Phasar subdirectories
258+
# Add PhASAR's subdirectories
242259
add_subdirectory(include)
243260
add_subdirectory(lib)
244261

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/Config/Version.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
#define PHASAR_VERSION v0521
1+
#ifndef PHASAR_CONFIG_VERSION_H
2+
#define PHASAR_CONFIG_VERSION_H
3+
4+
#define PHASAR_VERSION v0521
5+
6+
#endif

include/phasar/Controller/AnalysisController.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Philipp Schubert and others
88
*****************************************************************************/
99

10-
#ifndef PHASAR_CONTROLLER_ANALYSIS_CONTROLLER_H_
11-
#define PHASAR_CONTROLLER_ANALYSIS_CONTROLLER_H_
10+
#ifndef PHASAR_CONTROLLER_ANALYSISCONTROLLER_H
11+
#define PHASAR_CONTROLLER_ANALYSISCONTROLLER_H
1212

1313
#include <iostream>
1414
#include <set>
@@ -20,6 +20,7 @@
2020
#include "phasar/DB/ProjectIRDB.h"
2121
#include "phasar/PhasarLLVM/AnalysisStrategy/Strategies.h"
2222
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h"
23+
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSIDESolverConfig.h"
2324
#include "phasar/PhasarLLVM/Pointer/LLVMBasedPointsToAnalysis.h"
2425
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToSet.h"
2526
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
@@ -62,6 +63,7 @@ class AnalysisController {
6263
std::string ProjectID;
6364
std::string OutDirectory;
6465
boost::filesystem::path ResultDirectory;
66+
IFDSIDESolverConfig SolverConfig;
6567
[[maybe_unused]] Soundness SoundnessLevel;
6668
[[maybe_unused]] bool AutoGlobalSupport;
6769

@@ -122,14 +124,16 @@ class AnalysisController {
122124
const std::set<std::string> &EntryPoints,
123125
AnalysisStrategy Strategy,
124126
AnalysisControllerEmitterOptions EmitterOptions,
127+
IFDSIDESolverConfig SolverConfig,
125128
const std::string &ProjectID = "default-phasar-project",
126129
const std::string &OutDirectory = "");
127130

128131
~AnalysisController() = default;
129132

130133
AnalysisController(const AnalysisController &) = delete;
131-
132134
AnalysisController(AnalysisController &&) = delete;
135+
AnalysisController &operator=(const AnalysisController &) = delete;
136+
AnalysisController &operator=(const AnalysisController &&) = delete;
133137

134138
void executeAs(AnalysisStrategy Strategy);
135139
};

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

0 commit comments

Comments
 (0)