Skip to content

Commit 6fae0d5

Browse files
authored
Merge pull request #823 from secure-software-engineering/development
Release 2604
2 parents 846b279 + b15ecd6 commit 6fae0d5

437 files changed

Lines changed: 25333 additions & 6344 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.

.github/workflows/ci.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
fail-fast: true
1616
matrix:
1717
os: [ubuntu-24.04, ubuntu-24.04-arm]
18-
compiler: [ [clang++-19, clang-19, "clang-19 libclang-rt-19-dev"] ]
19-
build: [ Debug, Release, DebugLibdeps ]
18+
compiler: [ [clang++-19, clang-19, "clang-19 libclang-rt-19-dev clang-tools-19"] ]
19+
build: [ Debug, Release, DebugLibdeps, DebugCov ]
20+
llvm-version: [ 16, 17 ]
2021
include:
2122
- build: Debug
2223
cmake_build_type: Debug
@@ -27,11 +28,17 @@ jobs:
2728
- build: DebugLibdeps
2829
cmake_build_type: Debug
2930
flags: -DPHASAR_DEBUG_LIBDEPS=ON -DBUILD_SHARED_LIBS=ON
31+
- build: DebugCov
32+
cmake_build_type: Debug
33+
flags: -DCODE_COVERAGE=ON
34+
extra_dependencies: llvm-19 # For coverage
3035
exclude:
3136
- os: ubuntu-24.04-arm
3237
build: Debug
3338
- os: ubuntu-24.04-arm
3439
build: DebugLibdeps
40+
- os: ubuntu-24.04-arm
41+
build: DebugCov
3542

3643
continue-on-error: false
3744
steps:
@@ -41,10 +48,15 @@ jobs:
4148
fetch-depth: 0
4249
submodules: recursive
4350

51+
- name: ccache # This should always come after the actions/checkout step.
52+
uses: hendrikmuhs/ccache-action@v1.2
53+
with:
54+
key: ${{ github.job }}-${{ matrix.os }}-llvm${{ matrix.llvm-version }}-${{ matrix.build }}
55+
4456
- name: Install Phasar Dependencies
4557
shell: bash
4658
run: |
47-
./utils/InstallAptDependencies.sh --noninteractive tzdata ${{ matrix.compiler[2] }}
59+
./utils/InstallAptDependencies.sh --llvm-version ${{ matrix.llvm-version }} --noninteractive tzdata ccache ${{ matrix.compiler[2] }} ${{ matrix.extra_dependencies }}
4860
4961
- name: Building Phasar in ${{ matrix.build }} with ${{ matrix.compiler[0] }}
5062
env:
@@ -54,8 +66,12 @@ jobs:
5466
run: |
5567
cmake -S . -B build \
5668
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
69+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
70+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
5771
-DBUILD_PHASAR_CLANG=OFF \
5872
-DPHASAR_USE_Z3=ON \
73+
-DPHASAR_BUILD_MODULES=ON \
74+
-DPHASAR_LLVM_VERSION=${{ matrix.llvm-version }} \
5975
${{ matrix.flags }} \
6076
-G Ninja
6177
ninja -C build
@@ -77,3 +93,18 @@ jobs:
7793
cd ./examples/how-to
7894
cmake -S . -B build -Dphasar_ROOT="$PHASAR_ROOT_DIR/INSTALL"
7995
cmake --build ./build --target run_sample_programs
96+
97+
- name: Check test coverage and generate HTML report
98+
if: matrix.build == 'DebugCov'
99+
shell: bash
100+
run: |
101+
cmake --build ./build --target ccov-all
102+
103+
- name: Upload coverage HTML report artifact
104+
if: matrix.build == 'DebugCov'
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: phasar-coverage-report-llvm-${{ matrix.llvm-version }}
108+
path: ./build/ccov/all-merged/
109+
if-no-files-found: error
110+
retention-days: 7

.github/workflows/deploy-docs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ permissions:
88
contents: write
99
jobs:
1010
build-and-deploy:
11+
if: github.repository == 'secure-software-engineering/phasar'
1112
runs-on: ubuntu-24.04
1213
strategy:
1314
fail-fast: true
@@ -28,8 +29,8 @@ jobs:
2829
- name: Build Doxygen Docs
2930
shell: bash
3031
env:
31-
CXX: clang++-15
32-
CC: clang-15
32+
CXX: clang++-16
33+
CC: clang-16
3334
run: |
3435
cmake -S . -B build -DPHASAR_BUILD_DOC=ON
3536
cmake --build ./build --target doc_doxygen

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ log/*
3333
# MS VS Code
3434
.vscode/
3535

36+
.devcontainer/
37+
3638
# Eclipse
3739
.cproject
3840
.project

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.3.0
5+
rev: v6.0.0
66
hooks:
77
- id: trailing-whitespace
88
exclude: "^.*\\.patch$"

BUILD.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ When using CMake to compile PhASAR the following optional parameters can be used
7979
| **PHASAR_ENABLE_PAMM** : STRING | Enable the performance measurement mechanism ('Off', 'Core' or 'Full', default is Off) |
8080
| **PHASAR_ENABLE_PIC** : BOOL | Build Position-Independed Code (default is ON) |
8181
| **PHASAR_ENABLE_WARNINGS** : BOOL | Enable compiler warnings (default is ON) |
82-
| **CMAKE_CXX_STANDARD** : INT|Build phasar in C++17 or C++20 mode (default is 17)|
82+
| **CMAKE_CXX_STANDARD** : INT|Adapt the used C++ standard (minimum required is 20)|
83+
| **PHASAR_LLVM_VERSION** : INT|The LLVM major-version to use. Can be 16 or 17 (default is 16)|
8384

8485
You can use these parameters either directly or modify the installer-script `bootstrap.sh`
8586

BreakingChanges.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@
44

55
*None*
66

7+
## v2604
8+
9+
- The function `HelperAnalyses::getAliasInfo()` no longer returns a `LLVMAliasSet &`, but a `LLVMAliasInfoRef`.
10+
- The location of the library summary `FunctionDataFlowFacts` and `LLVMFunctionDataFlowFacts` has moved to `phasar/Utils/` and `phasar/PhasarLLVM/Utils`, respectively.
11+
- `IDESolver::initialize()` does no longer return a `bool`. Now, you are always allowed to call `next()` at least once.
12+
- `IntraMonoProblem` and `InterMonoProblem`, and all reference-implementations of these problems do not receive a TypeHierarchy-pointer anymore in the ctor.
13+
- Requiring C++20 instead of C++17
14+
- Type-traits and other templates that are specialized now use `requires` instead of `enable_if`, wherever possible. This may reduce the number of (defaulted) template parameters in some cases.
15+
- The `AdjacencyList` struct now now has one more template argument to denote the intege-like `vertex_t` type. It is the second template argument (which previously was the EdgeType). The edge-type is now denoted by the *third* template argument.
16+
- The `AdjacencyList` switches from using `llvm::NoneType` as empty-node marker to `psr::EmptyType` for forward-compatibility with LLVM-16 that removes `llvm::NoneType`.
17+
18+
- Removed `SpecialSummaries`.
19+
- Removed `Hexastore` and the corresponding database queries.
20+
- Removed `LLVMTypeHierarchy` (and `LLVMTypeHierarchyData`), which is superceeded by `DIBasedTypeHierarchy`.
21+
- Removed `Resolver::preCall()`, `Resolver::postCall()`, and `Resolver::otherInst()`.
22+
- Removed `TypestateDescription::start()`. Instead apply `TypestateDescription::getNextState()` on `TypestateDescription::uninit()`.
23+
- Removed `LLVMProjectIRDB::getParsedIRModuleOrNull()`. Use `LLVMProjectIRDB::getParsedIRModuleOrErr()` instead.
24+
- Removed `DIBasedTypeHierarchy::isVTable()` and `DIBasedTypeHierarchy::removeVTablePrefix()`. Use the corresponding functions from `LLVMVFTableProvider` instead.
25+
- Removed the CMake variable `PHASAR_HAS_SQLITE` as we removed the dependency on sqlite3.
26+
- The CMake Option `BUILD_PHASAR_CLANG` is no longer `ON` by default.
27+
- Removed the dependency to boost:
28+
- Removed the boost-related command-line options in `bootstrap.sh`
29+
- `InstallAptDependencies.sh` no longer installs boost (so, boost is also no longer built into PhASAR's Docker containers)
30+
731
## v2510
832

933
- Removed some old APIs from `PhasarConfig`

CMakeLists.txt

Lines changed: 72 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ if (DEFINED LLVM_MAIN_SRC_DIR)
2323
set(PHASAR_IN_TREE 1)
2424
endif()
2525

26+
set(PHASAR_VERSION 2604)
2627
if (NOT PHASAR_IN_TREE)
2728
project (phasar
2829
LANGUAGES C CXX
2930
DESCRIPTION "A LLVM-based static analysis framework."
30-
VERSION 2510
31+
VERSION ${PHASAR_VERSION}
3132
)
3233
endif ()
33-
set(PHASAR_VERSION ${PROJECT_VERSION})
3434

3535
# NOTE: When we require cmake >= 3.21, we can use PROJECT_IS_TOP_LEVEL instead
3636
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@@ -245,10 +245,18 @@ endif()
245245
set(PHASAR_DEPS_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/phasar/deps)
246246

247247
# Filesystem
248-
if (LLVM_ENABLE_LIBCXX)
249-
set(PHASAR_STD_FILESYSTEM c++fs)
250-
else()
251-
set(PHASAR_STD_FILESYSTEM stdc++fs)
248+
249+
# Check if the underlying toolchain has a default std filesystem header
250+
include(CheckIncludeFileCXX)
251+
check_include_file_cxx(filesystem HAS_FILESYSTEM_HEADER)
252+
253+
if (NOT HAS_FILESYSTEM_HEADER)
254+
# If no file system exists, link a filesystem explicitly
255+
if (LLVM_ENABLE_LIBCXX)
256+
set(PHASAR_STD_FILESYSTEM c++fs)
257+
else()
258+
set(PHASAR_STD_FILESYSTEM stdc++fs)
259+
endif()
252260
endif()
253261

254262
# Config
@@ -264,18 +272,47 @@ endif()
264272
# Threads
265273
find_package(Threads)
266274

267-
# Boost
268-
find_package(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG)
269-
270275
# Disable clang-tidy for the external projects
271276
set(CMAKE_CXX_CLANG_TIDY "")
272277

273278
# Nlohmann JSON
274-
275279
include(add_nlohmann_json)
276280
add_nlohmann_json()
277281
add_json_schema_validator()
278282

283+
# Coverage
284+
if (CODE_COVERAGE)
285+
set(CODE_COVERAGE_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/code-coverage.cmake")
286+
file(DOWNLOAD "https://raw.githubusercontent.com/StableCoder/cmake-scripts/refs/tags/25.08/code-coverage.cmake" "${CODE_COVERAGE_SCRIPT}"
287+
EXPECTED_HASH SHA256=cad4dd2bdf944f77627687e0298debc8341bfdeffaf949937f319c7c4ff3fdaf
288+
TLS_VERIFY ON
289+
STATUS CODE_COVERAGE_SCRIPT_DOWNLOAD_STATUS
290+
)
291+
message(STATUS "Download code-coverage.cmake: ${CODE_COVERAGE_SCRIPT_DOWNLOAD_STATUS}")
292+
293+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
294+
string(REGEX MATCH "^[0-9]+" COMPILER_VERSION_MAJOR "${CMAKE_CXX_COMPILER_VERSION}")
295+
message(STATUS "Clang major version: ${COMPILER_VERSION_MAJOR}")
296+
set(LLVM_TOOL_VERSION_SUFFIX "-${COMPILER_VERSION_MAJOR}")
297+
endif()
298+
299+
# pre-populate these cmake variables as we require specific versions:
300+
find_program(LLVM_COV_PATH "llvm-cov${LLVM_TOOL_VERSION_SUFFIX}" REQUIRED)
301+
find_program(LLVM_PROFDATA_PATH "llvm-profdata${LLVM_TOOL_VERSION_SUFFIX}" REQUIRED)
302+
message(STATUS "Found llvm-cov: ${LLVM_COV_PATH}")
303+
message(STATUS "Found llvm-profdata: ${LLVM_PROFDATA_PATH}")
304+
305+
include("${CODE_COVERAGE_SCRIPT}")
306+
307+
find_program(cxxfilt "c++filt" QUIET)
308+
if (cxxfilt)
309+
set(DEMANGLER_OPTIONS LLVM_COV_HTML_OPTIONS "-Xdemangler=${cxxfilt}")
310+
endif()
311+
312+
set(COV_FILEPATH_FILTER "(usr/*|external/|unittests/)")
313+
add_code_coverage_all_targets(EXCLUDE ${COV_FILEPATH_FILTER} ${DEMANGLER_OPTIONS})
314+
endif()
315+
279316
# Googletest
280317
if (NOT PHASAR_IN_TREE)
281318
if(PHASAR_BUILD_UNITTESTS AND NOT TARGET gtest)
@@ -294,20 +331,11 @@ else()
294331
set(GTEST_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include")
295332
endif()
296333

297-
# SQL
298-
find_package(SQLite3)
299-
if(SQLite3_FOUND)
300-
set(PHASAR_HAS_SQLITE ON)
301-
else()
302-
set(PHASAR_HAS_SQLITE OFF)
303-
endif()
304-
305334
option(USE_LLVM_FAT_LIB "Link against libLLVM.so instead of the individual LLVM libraries if possible (default is OFF; always on if BUILD_SHARED_LIBS is ON)" OFF)
306335

307336
# LLVM
308-
if (NOT PHASAR_LLVM_VERSION)
309-
set(PHASAR_LLVM_VERSION 15)
310-
endif()
337+
set(PHASAR_LLVM_VERSION 16 CACHE STRING "The LLVM major-version that PhASAR should use")
338+
311339
include(add_llvm)
312340
add_llvm()
313341

@@ -328,29 +356,34 @@ if(PHASAR_IN_TREE)
328356
set (PHASAR_USE_Z3 OFF)
329357
else()
330358
if(PHASAR_USE_Z3)
331-
# This z3-version is the same version LLVM requires; however, we cannot just use Z3 via the LLVM interface
332-
# as it lacks some functionality (such as z3::expr::simplify()) that we require
333-
334-
# FindZ3.cmake by llvm tries to compile a snippet with Z3 which crashes on arm with sanitizers enabled
335-
set(SAFE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
336-
set(CMAKE_CXX_FLAGS "")
337-
find_package(Z3 4.7.1 REQUIRED)
338-
set(CMAKE_CXX_FLAGS "${SAFE_CMAKE_CXX_FLAGS}")
339-
340-
if(Z3_FOUND)
341-
if (NOT TARGET z3)
342-
add_library(z3 IMPORTED SHARED)
343-
set_property(TARGET z3 PROPERTY
344-
IMPORTED_LOCATION ${Z3_LIBRARIES})
345-
set_property(TARGET z3 PROPERTY
346-
INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR})
359+
if (TARGET z3::libz3)
360+
# When including SVF, it also tries to find z3, but in addition to LLVM's search it already creates a target: z3::libz3.
361+
# Reuse it here:
362+
if(NOT TARGET z3)
363+
add_library(z3 ALIAS z3::libz3)
364+
endif()
365+
else()
366+
# FindZ3.cmake by llvm tries to compile a snippet with Z3 which crashes on arm with sanitizers enabled
367+
set(SAFE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
368+
set(CMAKE_CXX_FLAGS "")
369+
find_package(Z3 REQUIRED)
370+
set(CMAKE_CXX_FLAGS "${SAFE_CMAKE_CXX_FLAGS}")
371+
372+
if(Z3_FOUND)
373+
if (NOT TARGET z3)
374+
add_library(z3 IMPORTED SHARED)
375+
set_target_properties(z3 PROPERTIES
376+
IMPORTED_LOCATION ${Z3_LIBRARIES}
377+
INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR}
378+
)
379+
endif()
347380
endif()
348381
endif()
349382
endif()
350383
endif()
351384

352385
# Clang
353-
option(BUILD_PHASAR_CLANG "Build the phasar_clang library (default is ON)" ON)
386+
option(BUILD_PHASAR_CLANG "Build the phasar_clang library (default is OFF)" OFF)
354387
if(BUILD_PHASAR_CLANG)
355388
add_clang()
356389
endif()
@@ -377,7 +410,7 @@ if (PHASAR_ENABLE_WARNINGS)
377410
if (MSVC)
378411
string(APPEND CMAKE_CXX_FLAGS " /W4")
379412
else()
380-
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wno-unused-parameter")
413+
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wno-unused-parameter -Werror=return-type")
381414
endif()
382415
endif (PHASAR_ENABLE_WARNINGS)
383416

Config.cmake.in

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@ include (CMakeFindDependencyMacro)
99
set(PHASAR_LLVM_VERSION @PHASAR_LLVM_VERSION@)
1010

1111
include("${CMAKE_CURRENT_LIST_DIR}/PhasarDepsExports.cmake")
12-
find_dependency(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG)
1312
find_dependency(LLVM ${PHASAR_LLVM_VERSION} REQUIRED CONFIG)
1413

1514
set(PHASAR_USE_LLVM_FAT_LIB @USE_LLVM_FAT_LIB@)
1615
set(PHASAR_BUILD_DYNLIB @PHASAR_BUILD_DYNLIB@)
1716
set(PHASAR_USE_Z3 @PHASAR_USE_Z3@)
18-
set(PHASAR_HAS_SQLITE @PHASAR_HAS_SQLITE@)
1917
set(PHASAR_BUILD_MODULES @PHASAR_BUILD_MODULES@)
2018

2119
if (PHASAR_USE_Z3)
2220
find_dependency(Z3 REQUIRED)
2321
endif()
24-
if(PHASAR_HAS_SQLITE)
25-
find_dependency(SQLite3 REQUIRED)
26-
endif()
2722

2823
set(PHASAR_COMPONENTS
2924
utils

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ARG baseimage="ubuntu:24.04"
2-
FROM "$baseimage" as build
2+
FROM "$baseimage" AS build
33

44
RUN --mount=type=bind,source=./utils/InstallAptDependencies.sh,target=/InstallAptDependencies.sh \
55
set -eux; \
6-
./InstallAptDependencies.sh --noninteractive tzdata clang-19 libclang-rt-19-dev
6+
./InstallAptDependencies.sh --noninteractive tzdata clang-19 libclang-rt-19-dev clang-tools-19
77

88
ENV CC=/usr/bin/clang-19 \
99
CXX=/usr/bin/clang++-19

0 commit comments

Comments
 (0)