Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Mory committed Mar 30, 2023
2 parents 9b8810b + 2a941ee commit 956972a
Show file tree
Hide file tree
Showing 532 changed files with 12,996 additions and 10,696 deletions.
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
BasedOnStyle: LLVM
SortIncludes: true
IncludeBlocks: Regroup
BreakStringLiterals: true
IncludeCategories:
- Regex: '^"phasar/'
Priority: 1
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '".*"'
Priority: 3
- Regex: '<[[:alnum:]_]+>'
Priority: 4
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CheckOptions:
- key: readability-identifier-naming.ParameterIgnoredRegexp
value: (d|d1|d2|d3|d4|d5|eP|f|n)
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: (try_emplace|from_json|to_json|equal_to)
value: (try_emplace|from_json|to_json|equal_to|to_string)
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: 1
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
Expand Down
12 changes: 7 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
/include/phasar/PhasarLLVM/DataflowSolver/IfdsIde/Solver/IDESolver.h @pdschubert

/include/phasar/PhasarLLVM/DataflowSolver/IfdsIde/FlowEdgeFunctionCache.h @vulder
/include/phasar/PhasarLLVM/DataflowSolver/IfdsIde/EdgeFunctionSingletonFactory.h @vulder
/unittests/PhasarLLVM/DataFlowSolver/IfdsIde/EdgeFunctionSingletonFactoryTest.cpp @vulder

/include/phasar/PhasarLLVM/DataflowSolver/Mono @pdschubert

/img @pdschubert

/include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEInstInteractionAnalysis.h @pdschubert @vulder
/include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/ @fabianbs96
/include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEExtendedTaintAnalysis.h @fabianbs96
/lib/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDEExtendedTaintAnalysis.cpp @fabianbs96
/lib/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/ @fabianbs96
/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.h @pdschubert @vulder
/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/ @fabianbs96
/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h @fabianbs96
/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.cpp @fabianbs96
/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/ @fabianbs96

/include/phasar/PhasarLLVM/AnalysisStrategy/ @pdschubert

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ jobs:
libclang-common-14-dev \
libclang-14-dev \
libclang-cpp14-dev \
clang-tidy-14
clang-tidy-14 \
libclang-rt-14-dev
- uses: swift-actions/setup-swift@v1
- name: Building Phasar in ${{ matrix.build }} with ${{ matrix.compiler[0] }}
env:
BUILD_TYPE: ${{ matrix.build }}
Expand All @@ -65,6 +67,7 @@ jobs:
cmake .. \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_CXX_COMPILER=$CXX \
-DBUILD_SWIFT_TESTS=1 \
-G Ninja
cmake --build .
Expand Down
43 changes: 43 additions & 0 deletions BreakingChanges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Breaking Changes

## v0323

- `EdgeFunctionPtrType` is no longer a `std::shared_ptr`. Instead `EdgeFunction<l_t>` should be used directly. `EdgeFunction` is now a *value-type* that encapsulates its memory management by itself.
- Concrete `EdgeFunction` types no longer derive from any base-class. Instead they just need to implement the required API functions. `EdgeFunction` implementations should me move-constructible and can be implicitly cast to `EdgeFunction`. To verify that your type implements the edge function interface use the `IsEdgeFunction` type trait. The API functions have been changed as follows:
- All API functions of `EdgeFunction` must be `const` qualified.
- `EdgeFunctionPtrType composeWith(EdgeFunctionPtrType SecondFunction)` and `EdgeFunctionPtrType joinWith(EdgeFunctionPtrType OtherFunction)` have been changed to `static EdgeFunction<l_t> compose(EdgeFunctionRef<T> This, const EdgeFunction<l_t>& SecondFunction)` and `static EdgeFunction<l_t> join(EdgeFunctionRef<T> This, const EdgeFunction<l_t>& OtherFunction)` respectively. Here, the `This` parameter models the former `shared_from_this()`.
- `bool equal_to(EdgeFunctionPtrType Other)const` has been changed to `bool operator==(const T &Other)const noexcept`, where `T` is your concrete edge function type.
- `void print(llvm::raw_ostream &OS, bool IsForDebug)` has been changed to `friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const T& EF)`.
- `EdgeFunction` is tagged with `[[clang::trivial_abi]]`. Hence, you should not rely on any destruction order within a top-level statement that uses temporary `EdgeFunction` objects.
- `EdgeFunctionSingletonFactory` has been removed. Use `EdgeFunctionSingletonCache` instead.
- `TaintConfig` has been renamed to `LLVMTaintConfig`. For generic code you may want to use the LLVM-independent `TaintConfigBase` CRTP interface instead.
- Renamed `phasar/PhasarLLVM/DataFlowSolver/` to either `phasar/DataFlow/` or `phasar/PhasarLLVM/DataFlow/` depending on whether the components need LLVMCore. Analoguous changes in `lib/` and `unittests/`.
An incomplete list of moved/renamed files:
- `phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver/*` => `phasar/DataFlow/IfdsIde/Solver/*`
- `phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IDETabulationProblem.h` => `phasar/DataFlow/IfdsIde/IDETabulationProblem.h`
- `phasar/DB/LLVMProjectIRDB.h` => `phasar/PhasarLLVM/DB/LLVMProjectIRDB.h`
- ...
- Renamed and split up some libraries:
- `phasar_phasarllvm_utils` => `phasar_llvm_utils`
- `phasar_typehierarchy` => `phasar_llvm_typehierarchy`
- `phasar_ifdside` => `phasar_llvm_ifdside`
- `phasar_controlflow` has its LLVM dependent stuff moved to `phasar_llvm_controlflow`
- `phasar_db` has its LLVM dependent stuff moved to `phasar_llvm_db`
- `phasar_pointer` has its LLVM dependent stuff moved to `phasar_llvm_pointer`
- Renamed the phasar tool `phasar-llvm` to `phasar-cli`
- `LLVMPointsTo[.*]` has been renamed to `LLVMAlias[.*]`
- The ctor of `LLVMAliasSet` now takes the `LLVMProjectIRDB` as pointer instead of a reference to better document that it may capture the IRDB by reference.
- The `PointsToInfo` interface has been replaced by the CRTP interface `AliasInfoBase`. Introduced two type-erased implementations of that interface: `AliasInfo` and `AliasInfoRef`. In most cases you should replace `PointsToInfo *` and `LLVMPointsToInfo *` by `AliasInfoRef`, bzw. `LLVMAliasInfoRef`.
- Introduced a new interface `PointsToInfoBase` and type-erased implementations `PointstoInfo` and `PointsToInfoRef`. Don't confuse them with the old `PointsToInfo`!!! (However, they have different APIs, so you should encounter compilation errors then)

## v1222

- Removed virtual interfaces `CFG<N,F>` and `ICFG<N,F>` and replaced by CRTP interfaces `CFGBase` and `ICFGBase`. Use the concrete types `LLVMBasedICFG` and `LLVMBasedCFG` instead. In template code you can use the type traits `is_crtp_base_of_v` and `is_icfg_v` to check for conformance to the interfaces.
- The `LLVMBasedICFG` now takes the IRDB as pointer instead of a reference to better document that it may capture the IRDB by reference.
- Renamed `ProjectIRDB` to `LLVMProjectIRDB` and added a generic CRTP interface `ProjectIRDBBase` that does not depend on LLVM
- Changed the API of `LLVMProjectIRDB`: The IRDB does no longer link multiple LLVM modules together, i.e. the ctor that reads a module from a file now takes a single filename instead of a vector. If you still want to link multiple LLVM modules together, use LLVM's Linker functionality instead. `ProjecIRDB::getAllModules()` has been removed and `ProjectIRDB::getWPAModule()` has been renamed to `LLVMProjectIRDB::getModule()`.
- The `LLVMProjectIRDB` ctor that takes a raw-pointer to `llvm::Module` does no longer preprocess the module (i.e. attaching metadata IDs to it). You can still explicitly use the `ValueAnnotationPass` to do so manually.
- The type `WholeProgramAnalysis` has been removed. Use `AnalysisController` instead.
- The IFDS and IDE TabulationProblems no longer take all of `LLVMProjectIRDB*`, `LLVMTypeHierarchy*`, `LLVMPointsToInfo*` and `LLVMBasedICFG*` as an argument. Instead, they only get what they need.
- The `IFDSSolver` and `IDESolver` now take an instance of the `ICFGBase` interface as additional argument to their ctor (because the analysis problems now not necessarily store a reference to it anymore).
- The `IDETabulationProblem` is now a base class of `IFDSTabulationProblem` (and not vice versa as it was previously). In their ctors they only take the bare minimum of arguments: The IRDB, the entrypoints and optionally the special zero-value. If the zero-value is not passed in the ctor (as it was previously), it has to be set from within the client analysis' ctor. You may use the new function `initializeZeroValue(d_t)` for this.
40 changes: 32 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ include("phasar_macros")

option(PHASAR_BUILD_UNITTESTS "Build all tests (default is ON)" ON)

option(BUILD_SWIFT_TESTS "Builds the Swift tests (Swift compiler has to be installed manually beforehand!)" OFF)
if (BUILD_SWIFT_TESTS)
set(CMAKE_Swift_FLAGS_RELEASE "-g")
set(CMAKE_Swift_FLAGS_RELWITHDEBINFO "-g")
enable_language(Swift)
endif(BUILD_SWIFT_TESTS)

option(PHASAR_BUILD_OPENSSL_TS_UNITTESTS "Build OPENSSL typestate tests (require OpenSSL, default is OFF)" OFF)

option(PHASAR_BUILD_IR "Build IR test code (default is ON)" ON)
Expand Down Expand Up @@ -107,10 +114,14 @@ include_directories(
${PHASAR_SRC_DIR}/include
)

set(PHASAR_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/phasar)

if (NOT PHASAR_IN_TREE)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${PHASAR_INSTALL_LIBDIR})
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

if (NOT "${CMAKE_INSTALL_LIBDIR}" STREQUAL "lib")
message(STATUS "Detected CMAKE_INSTALL_LIBDIR that deviates from 'lib': ${CMAKE_INSTALL_LIBDIR}. Add ${CMAKE_INSTALL_PREFIX}/lib to the RPATH as json-schema-validator needs it")
list(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
endif()

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

Expand All @@ -120,6 +131,17 @@ else()
set(PHASAR_STD_FILESYSTEM stdc++fs)
endif()

set(PHASAR_CUSTOM_CONFIG_INSTALL_DIR "" CACHE STRING "If set, customizes the directory, where configuration files for PhASAR are installed (default is /usr/local/.phasar-config)")
if ("${PHASAR_CUSTOM_CONFIG_INSTALL_DIR}" STREQUAL "")
set(PHASAR_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/.phasar-config/")
else()
set(PHASAR_CONFIG_INSTALL_DIR "${PHASAR_CUSTOM_CONFIG_INSTALL_DIR}")
endif()

add_compile_definitions(PHASAR_CONFIG_DIR="${PHASAR_CONFIG_INSTALL_DIR}")
add_compile_definitions(PHASAR_DIR="${PHASAR_SRC_DIR}")


### Adding external libraries
# Threads
find_package(Threads)
Expand All @@ -144,7 +166,7 @@ set(CMAKE_CXX_CLANG_TIDY "")
set(BUILD_TESTS OFF CACHE BOOL "Build json-schema-validator-tests")

# Make nlohmann_json_schema_validator happy by telling it how to find the single include of nlohmann_json
include_directories(external/json/single_include/)
include_directories(SYSTEM external/json/single_include/)

if (PHASAR_IN_TREE)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json_schema_validator)
Expand Down Expand Up @@ -301,7 +323,7 @@ endif()

set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Install dir of headers")

# Install targets of phasar-llvm, other executables, and libraries are to be
# Install targets of phasar-cli, other executables, and libraries are to be
# found in the individual subdirectories of tools/

# Install Phasar include directory
Expand All @@ -326,15 +348,17 @@ install(DIRECTORY external/googletest/googletest/include/gtest/
# Install Phasar utils helper scripts
install(DIRECTORY utils/
DESTINATION bin
FILES_MATCHING PATTERN "phasar-*"
FILES_MATCHING
PATTERN "CodeGen" EXCLUDE # CodeGen does not contain files to install
PATTERN "phasar-*"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
)

# Install the Phasar config files into ~/.config/phasar/
# Install the Phasar config files into CMAKE_INSTALL_PREFIX/.phasar-config/
install(DIRECTORY config/
DESTINATION $ENV{HOME}/.config/phasar
DESTINATION ${PHASAR_CONFIG_INSTALL_DIR}
PATTERN "config/*"
PERMISSIONS OWNER_WRITE OWNER_READ
GROUP_WRITE GROUP_READ
Expand Down
17 changes: 13 additions & 4 deletions Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ find_package(Boost 1.65.1 COMPONENTS program_options graph REQUIRED)

set(PHASAR_COMPONENTS
utils
config
phasarllvm_utils
passes
config
db
pointer
typehierarchy
controlflow

llvm_utils
llvm_db
llvm_pointer
llvm_typehierarchy
llvm_controlflow

taintconfig
ifdside
mono
llvm
llvm_ifdside
analysis_strategy
controller
)

foreach(component ${PHASAR_COMPONENTS})
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ RUN apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key && \
libclang-common-14-dev \
libclang-14-dev \
libclang-cpp14-dev \
clang-tidy-14
clang-tidy-14 \
libclang-rt-14-dev

RUN pip3 install Pygments pyyaml

# installing boost
RUN apt install libboost-all-dev -y


# installing wllvm
Expand All @@ -58,4 +57,4 @@ RUN mkdir -p build && cd build && \
-G Ninja && \
cmake --build .

ENTRYPOINT [ "./build/tools/phasar-llvm/phasar-llvm" ]
ENTRYPOINT [ "./build/tools/phasar-cli/phasar-cli" ]
51 changes: 35 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ PhASAR a LLVM-based Static Analysis Framework
[![C++ Standard](https://img.shields.io/badge/C++_Standard-C%2B%2B17-blue.svg?style=flat&logo=c%2B%2B)](https://isocpp.org/)
[![GitHub license](https://img.shields.io/badge/license-MIT-blueviolet.svg)](https://raw.githubusercontent.com/secure-software-engineering/phasar/master/LICENSE.txt)

Version 1222
Version 0323

Secure Software Engineering Group
---------------------------------

+ Philipp Dominik Schubert ([email protected]) and others
+ Fabian Schiebel ([email protected]), Martin Mory ([email protected]), Philipp Dominik Schubert ([email protected]) and others
+ Please also refer to https://phasar.org/

Required version of the C++ standard
Expand All @@ -30,9 +30,13 @@ fully-automated manner on the specified LLVM IR target code. Computing points-to
information, call-graph(s), etc. is done by the framework, thus you can focus on
what matters.

Breaking Changes
----------------
To keep PhASAR in a state that it is well suited for state-of-the-art research in static analysis, as well as for productive use, we have to make breaking changes. Please refer to [Breaking Changes](./BreakingChanges.md) for detailed information on what was broken recently and how to migrate.

How do I get started with PhASAR?
---------------------------------
We have some documentation on PhASAR in our [_**wiki**_](https://github.com/secure-software-engineering/phasar/wiki). You probably would like to read
We have some documentation on PhASAR in our [_**Wiki**_](https://github.com/secure-software-engineering/phasar/wiki). You probably would like to read
this README first and then have a look on the material provided on https://phasar.org/
as well. Please also have a look on PhASAR's project directory and notice the project directory
examples/ as well as the custom tool tools/myphasartool.cpp.
Expand All @@ -45,6 +49,21 @@ prerequisites and compilation. It is recommended to compile PhASAR yourself in
order to get the full C++ experience and to have full control over the build
mode.

As a shortcut for the very first PhASAR build on your system, you can use our [bootstrap](./bootstrap.sh) script:

```bash
$ ./bootstrap.sh
```

Note: If you want to do changes within PhASAR, it is recommended to build it in Debug mode:
```bash
$ ./bootstrap.sh -DCMAKE_BUILD_TYPE=Debug
```

The bootstrap script may ask for superuser permissions (to install the dependencies); however it is not recommended to start the whole script with `sudo`.

For subsequent builds, see [Compiling PhASAR](#compiling-phasar-if-not-already-done-using-the-installation-scripts).

Please help us to improve PhASAR
--------------------------------
You are using PhASAR and would like to help us in the future? Then please
Expand All @@ -65,10 +84,12 @@ PhASAR using an Ubuntu or Unix-like system.

Therefore, we provide an installation script. To install PhASAR, just navigate to the top-level
directory of PhASAR and use the following command:
```
$ sudo ./bootstrap.sh
```bash
$ ./bootstrap.sh --install
```

The bootstrap script may ask for superuser permissions.

Done!


Expand All @@ -86,8 +107,7 @@ $ export CXX=/usr/local/bin/clang++
You may need to adjust the paths according to your system. When you cloned PhASAR from Github you need to initialize PhASAR's submodules before building it:

```
$ git submodule init
$ git submodule update
$ git submodule update --init
```

If you downloaded PhASAR as a compressed release (e.g. .zip or .tar.gz) you can use the `init-submodules-release.sh` script that manually clones the required submodules:
Expand All @@ -101,27 +121,25 @@ Navigate into the PhASAR directory. The following commands will do the job and c
```
$ mkdir build
$ cd build/
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make -j $(nproc) # or use a different number of cores to compile it
$ sudo make install # if you wish to install PhASAR system wide
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
$ ninja -j $(nproc) # or use a different number of cores to compile it
$ sudo ninja install # only if you wish to install PhASAR system wide
```

When you have used the `bootstrap.sh` script to install PhASAR, the above steps are already done.
Use them as a reference if you wish to modify PhASAR and recompile it.

After compilation using cmake the following two binaries can be found in the build/ directory:

+ phasar-llvm - the actual PhASAR command-line tool
+ phasar-cli - the actual PhASAR command-line tool (previously called `phasar-llvm`)
+ myphasartool - an example tool that shows how tools can be build on top of PhASAR

Use the command:

`$ ./phasar-llvm --help`
`$ ./phasar-cli --help`

in order to display the manual and help message.

`$ sudo make install`

Please be careful and check if errors occur during the compilation.

When using CMake to compile PhASAR the following optional parameters can be used:
Expand All @@ -130,7 +148,8 @@ When using CMake to compile PhASAR the following optional parameters can be used
|-----------|--------|
| <b>BUILD_SHARED_LIBS</b> : BOOL | Build shared libraries (default is ON) |
| <b>CMAKE_BUILD_TYPE</b> : STRING | Build PhASAR in 'Debug' or 'Release' mode <br> (default is 'Debug') |
| <b>CMAKE_INSTALL_PREFIX</b> : PATH | Path where PhASAR will be installed if <br> “make install” is invoked or the “install” <br> target is built (default is /usr/local/phasar) |
| <b>CMAKE_INSTALL_PREFIX</b> : PATH | Path where PhASAR will be installed if <br> "ninja install” is invoked or the “install” <br> target is built (default is /usr/local/phasar) |
| <b>PHASAR_CONFIG_INSTALL_PREFIX</b> : PATH | Path where PhASAR's configuration files will be installed if <br> ninja install” is invoked or the “install” <br> target is built. Expression will be evaluated within CMAKE_INSTALL_PREFIX, so prefer absolute paths (default is $(HOME)/.config/) |
| <b>PHASAR_BUILD_DOC</b> : BOOL | Build PhASAR documentation (default is OFF) |
| <b>PHASAR_BUILD_UNITTESTS</b> : BOOL | Build PhASAR unit tests (default is ON) |
| <b>PHASAR_BUILD_IR</b> : BOOL | Build PhASAR IR (required for running the unit tests) (default is ON) |
Expand All @@ -148,7 +167,7 @@ C++'s long compile times are always a pain. As shown in the above, when using cm
### Running a test solver
To test if everything works as expected please run the following command:

`$ phasar-llvm --module test/build_systems_tests/installation_tests/module.ll -D ifds-solvertest`
`$ phasar-cli -m test/build_systems_tests/installation_tests/module.ll -D ifds-solvertest`

If you obtain output other than a segmentation fault or an exception terminating the program abnormally everything works as expected.

Expand Down
Loading

0 comments on commit 956972a

Please sign in to comment.