Skip to content

Commit 1486785

Browse files
committed
Merge development into f-SolverConfigParams
2 parents 0ea815c + 45dde51 commit 1486785

300 files changed

Lines changed: 6540 additions & 5850 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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ 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-*,
1519
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
1620
-cppcoreguidelines-owning-memory,
@@ -20,8 +24,10 @@ Checks: '-*,
2024
-cppcoreguidelines-init-variables,
2125
-cppcoreguidelines-macro-usage,
2226
bugprone-*,
27+
-bugprone-easily-swappable-parameters,
2328
modernize-*,
2429
-modernize-use-trailing-return-type,
30+
-modernize-pass-by-value,
2531
performance-*,
2632
clang-analyzer-*,
2733
'
@@ -43,6 +49,10 @@ CheckOptions:
4349
value: CamelCase
4450
- key: readability-identifier-naming.VariableCase
4551
value: CamelCase
52+
- key: readability-identifier-naming.VariableIgnoredRegexp
53+
value: (c|d|d1|d2|d3|d4|d5|d5_restoredCtx|eP|f|f3|f4|f5|fCalleeSummary|g|n|dPrime|fPrime)
54+
- key: readability-identifier-naming.ParameterIgnoredRegexp
55+
value: (d|d1|d2|d3|d4|d5|eP|f|n)
4656
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
4757
value: 1
4858
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Phasar CI
2+
3+
on:
4+
push:
5+
branches: [ master, development ]
6+
pull_request:
7+
branches: [ master, development ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-20.04
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
compiler: [ [clang++-12, clang-12] ]
16+
build: [ Debug, Release ]
17+
18+
continue-on-error: false
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
submodules: recursive
25+
26+
- name: Install Basic Dependencies
27+
shell: bash
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get -y install --no-install-recommends \
31+
cmake \
32+
ninja-build \
33+
libstdc++6 \
34+
libboost-all-dev
35+
36+
- name: Install Phasar Dependencies
37+
shell: bash
38+
run: |
39+
./utils/InstallAptDependencies.sh
40+
41+
- name: Install Strategy Dependencies
42+
shell: bash
43+
run: |
44+
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
45+
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main'
46+
sudo apt-get update
47+
sudo apt-get -y install --no-install-recommends \
48+
${{ matrix.compiler[1] }} \
49+
llvm-12-dev \
50+
libllvm12 \
51+
libclang-common-12-dev \
52+
libclang-12-dev \
53+
libclang-cpp12-dev \
54+
clang-tidy-12
55+
56+
- name: Building Phasar in ${{ matrix.build }} with ${{ matrix.compiler[0] }}
57+
env:
58+
BUILD_TYPE: ${{ matrix.build }}
59+
CXX: ${{ matrix.compiler[0] }}
60+
CC: ${{ matrix.compiler[1] }}
61+
shell: bash
62+
run: |
63+
mkdir build
64+
cd build
65+
cmake .. \
66+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
67+
-DCMAKE_CXX_COMPILER=$CXX \
68+
-G Ninja
69+
cmake --build .
70+
71+
- name: Run Unittests
72+
shell: bash
73+
run: |
74+
cd build
75+
cmake --build . --target check-phasar-unittests

.github/workflows/pre-commit.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- uses: actions/checkout@v2
11+
with:
12+
fetch-depth: 0
13+
14+
- uses: actions/setup-python@v2
15+
16+
- uses: pre-commit/action@v2.0.0
17+
with:
18+
extra_args: --from-ref origin/development --to-ref HEAD
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Phasar clang-format review runner
2+
3+
on:
4+
pull_request:
5+
branches: [ master, development ]
6+
7+
jobs:
8+
format:
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
tool: [ clang-format ]
14+
include:
15+
- tool: clang-format
16+
install: |
17+
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
18+
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main'
19+
sudo apt-get update
20+
sudo apt-get -y install --no-install-recommends clang-format-12
21+
regex: \.(h|c|hpp|cpp)$
22+
command: clang-format-12 --style=file -i
23+
24+
continue-on-error: false
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
with:
29+
submodules: recursive
30+
31+
- name: Install Dependencies
32+
shell: bash
33+
run: ${{ matrix.install }}
34+
35+
- name: Fetch Base Branch
36+
shell: bash
37+
run: |
38+
git fetch --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
39+
40+
- name: Run Tool
41+
shell: bash
42+
run: |
43+
FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} HEAD | egrep "${{ matrix.regex }}" || true)
44+
[ -z "$FILES" ] || (${{ matrix.command }} $FILES && git diff --diff-filter=M $FILES)
45+
46+
- name: Add Suggestions
47+
uses: reviewdog/action-suggester@v1
48+
with:
49+
tool_name: ${{ matrix.tool }}
50+
filter_mode: diff_context
51+
level: warning

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v2.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- id: requirements-txt-fixer
12+
- repo: https://github.com/pre-commit/mirrors-clang-format
13+
rev: 'v12.0.1'
14+
hooks:
15+
- id: clang-format

CMakeLists.txt

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@ set(CMAKE_CXX_STANDARD 17)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616
set(CMAKE_CXX_EXTENSIONS OFF)
1717

18+
include(GNUInstallDirs)
19+
1820
set_property(GLOBAL PROPERTY TARGET_MESSAGES OFF)
1921

2022
if (NOT CMAKE_BUILD_TYPE)
21-
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)
2224
endif ()
23-
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")
2431
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -g")
2532
else()
33+
message(STATUS "Selected Release Build")
2634
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -march=native")
2735
endif()
2836

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

44-
4552
include("phasar_macros")
4653

4754
option(PHASAR_BUILD_UNITTESTS "Build all tests (default is ON)" ON)
@@ -50,6 +57,8 @@ option(PHASAR_BUILD_OPENSSL_TS_UNITTESTS "Build OPENSSL typestate tests (require
5057

5158
option(PHASAR_BUILD_IR "Build IR test code (default is ON)" ON)
5259

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

5564
option(PHASAR_DEBUG_LIBDEPS "Debug internal library dependencies (private linkage)" OFF)
@@ -94,12 +103,13 @@ endif()
94103
configure_file(config.h.in config.h @ONLY)
95104
include_directories(${CMAKE_CURRENT_BINARY_DIR})
96105

97-
98106
include_directories(
99107
${PHASAR_SRC_DIR}/include
100108
)
101109

102-
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
110+
set(PHASAR_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/phasar)
111+
112+
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${PHASAR_INSTALL_LIBDIR})
103113
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
104114

105115
if (LLVM_ENABLE_LIBCXX)
@@ -117,17 +127,38 @@ find_package(Boost 1.65.1 COMPONENTS filesystem graph system program_options log
117127
#find_package(Boost 1.72.0 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
118128
include_directories(${Boost_INCLUDE_DIRS})
119129

120-
# JSON library
121-
option(JSON_BuildTests OFF)
122-
set(JSON_Install ON)
123-
add_subdirectory(external/json EXCLUDE_FROM_ALL)
130+
# Disable clang-tidy for the external projects
131+
set(CMAKE_CXX_CLANG_TIDY "")
132+
133+
# We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here
134+
# The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator
135+
# is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as
136+
# in the installed state the nlohmann_json_schema_validator needs the nlohmann_json package which needs
137+
# to be installed.
138+
# The following workaround may collapse or become unnecessary once the issue is
139+
# changed or fixed in nlohmann_json_schema_validator.
140+
141+
#Override option of nlohmann_json_schema_validator to not build its tests
142+
set(BUILD_TESTS OFF CACHE BOOL "Build json-schema-validator-tests")
143+
144+
# Make nlohmann_json_schema_validator happy by telling it how to find the single include of nlohmann_json
124145
include_directories(external/json/single_include/)
125146

126-
# JSON Schema Validator
127-
set(BUILD_TESTS OFF)
128-
set(BUILD_EXAMPLES OFF)
129-
add_subdirectory(external/json-schema-validator EXCLUDE_FROM_ALL)
130-
include_directories(external/json-schema-validator/src)
147+
if (PHASAR_IN_TREE)
148+
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json_schema_validator)
149+
endif()
150+
151+
set(nlohmann_json_DIR ${PHASAR_SRC_DIR}/external/json/single_include/)
152+
153+
# Json Schema Validator
154+
set(JSON_VALIDATOR_INSTALL ON)
155+
add_subdirectory(external/json-schema-validator)
156+
include_directories(external/json-schema-validator/src/)
157+
158+
# now we finally add the subdirectory
159+
set(JSON_BuildTests OFF)
160+
set(JSON_Install ON)
161+
add_subdirectory(external/json)
131162

132163
# Googletest
133164
if (NOT PHASAR_IN_TREE)
@@ -166,7 +197,7 @@ endif()
166197
# Clang
167198
# The clang-cpp shared library is now the preferred way to link dynamically against libclang if we build out of tree.
168199
if(NOT PHASAR_IN_TREE)
169-
find_library(CLANG_LIBRARY NAMES clang-cpp REQUIRED HINTS ${LLVM_LIBRARY_DIRS})
200+
find_library(CLANG_LIBRARY NAMES clang-cpp libclang-cpp REQUIRED HINTS ${LLVM_LIBRARY_DIRS})
170201
if(${CLANG_LIBRARY} STREQUAL "CLANG_LIBRARY-NOTFOUND")
171202
set(NEED_LIBCLANG_COMPONENT_LIBS on)
172203
endif()
@@ -214,8 +245,17 @@ endif()
214245
add_subdirectory(external/WALi-OpenNWA)
215246
include_directories(external/WALi-OpenNWA/Source/wali/include)
216247

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 ()
217257

218-
# Add the Phasar subdirectories
258+
# Add PhASAR's subdirectories
219259
add_subdirectory(include)
220260
add_subdirectory(lib)
221261

0 commit comments

Comments
 (0)