Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8ce1f4d
Simple proof of concept
fabianbs96 Mar 30, 2025
bc5da78
Extended POC
fabianbs96 Mar 31, 2025
c9fdfe1
Merge branch 'development' into f-ModulesLight
fabianbs96 Apr 6, 2025
745df7b
add hello-modules example tool + modules for phasar.db and phasar.con…
fabianbs96 Apr 6, 2025
3486571
made hello_modules tool work
mxHuber May 2, 2025
abe8e8a
some meeting changes + rest of files
mxHuber May 6, 2025
25abba9
completed all cppm files
mxHuber May 11, 2025
4b90e51
added missing folders
mxHuber May 27, 2025
b5e7cec
Seperated namespaces + bugfixes
mxHuber May 28, 2025
cdb19cf
added missing macro + removed internal
mxHuber May 28, 2025
d7b951b
Simple proof of concept
fabianbs96 Mar 30, 2025
5da3424
Extended POC
fabianbs96 Mar 31, 2025
9efcd3b
add hello-modules example tool + modules for phasar.db and phasar.con…
fabianbs96 Apr 6, 2025
808ab14
made hello_modules tool work
mxHuber May 2, 2025
3bb7466
some meeting changes + rest of files
mxHuber May 6, 2025
110ec1d
completed all cppm files
mxHuber May 11, 2025
162742a
added missing folders
mxHuber May 27, 2025
61f3983
Seperated namespaces + bugfixes
mxHuber May 28, 2025
7f5c004
added missing macro + removed internal
mxHuber May 28, 2025
eea40b7
Merge branch 'f-ModulesLight' of https://github.com/fabianbs96/phasar…
mxHuber May 28, 2025
b4f9301
Fix compilation in C++17 mode and fix some modules
fabianbs96 May 29, 2025
ef7082e
Add phasar-svf to module phasar.llvm.pointer
fabianbs96 May 29, 2025
f0f98db
Fix cyclic dependency between phasar_llvm and phasar_llvm_ifdside
fabianbs96 May 29, 2025
f8a5328
Merge branch 'development' into f-ModulesLight
fabianbs96 Jun 21, 2025
38497ff
Update README.md
fabianbs96 Jun 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ string(APPEND CMAKE_CXX_FLAGS_RELEASE "")

option(CMAKE_VISIBILITY_INLINES_HIDDEN "Hide inlined functions from the DSO table (default ON)" ON)

option(PHASAR_BUILD_MODULES "Build C++20 modules for phasar" OFF)

include(CheckCXXCompilerFlag)

# Handle memory issues with linking
Expand Down
1 change: 1 addition & 0 deletions Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(PHASAR_USE_LLVM_FAT_LIB @USE_LLVM_FAT_LIB@)
set(PHASAR_BUILD_DYNLIB @PHASAR_BUILD_DYNLIB@)
set(PHASAR_USE_Z3 @PHASAR_USE_Z3@)
set(PHASAR_HAS_SQLITE @PHASAR_HAS_SQLITE@)
set(PHASAR_BUILD_MODULES @PHASAR_BUILD_MODULES@)

if (PHASAR_USE_Z3)
find_dependency(Z3 REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ PhASAR requires at least C++-17.
However, building in C++20 mode is supported. You may enable this setting the cmake variable `CMAKE_CXX_STANDARD` to `20`.
Although phasar currently does not make use of C++-20 features (except for some `concept`s behind an #ifdef border), your client application that just *uses* phasar as a library may want to use C++20 earlier.

**NEW**: PhASAR supports C++20 modules as an experimental feature.

## Currently Supported Version of LLVM

PhASAR is currently set up to support LLVM-15.0.*
Expand Down
28 changes: 26 additions & 2 deletions cmake/phasar_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ endmacro(add_phasar_executable)

function(add_phasar_library name)
set(PHASAR_LIB_OPTIONS SHARED STATIC MODULE INTERFACE)
set(PHASAR_LIB_MULTIVAL LLVM_LINK_COMPONENTS LINKS LINK_PUBLIC LINK_PRIVATE FILES)
set(PHASAR_LIB_MULTIVAL LLVM_LINK_COMPONENTS LINKS LINK_PUBLIC LINK_PRIVATE FILES MODULE_FILES)
cmake_parse_arguments(PHASAR_LIB "${PHASAR_LIB_OPTIONS}" "" "${PHASAR_LIB_MULTIVAL}" ${ARGN})
set(srcs ${PHASAR_LIB_UNPARSED_ARGUMENTS})
list(APPEND srcs ${PHASAR_LIB_FILES})
Expand Down Expand Up @@ -277,6 +277,28 @@ function(add_phasar_library name)

target_compile_features(${name} PUBLIC cxx_std_17)

set(install_module)
if(PHASAR_LIB_MODULE_FILES)
if(PHASAR_BUILD_MODULES)
target_sources(${name} PUBLIC
FILE_SET cxx_modules
TYPE CXX_MODULES
FILES ${PHASAR_LIB_MODULE_FILES}
)

target_compile_features(${name} PUBLIC cxx_std_20)

set(install_module FILE_SET cxx_modules DESTINATION ${CMAKE_INSTALL_LIBDIR})
elseif(NOT srcs)
# Add dummy src to prevent cmake error
set(dummy_src "${CMAKE_CURRENT_BINARY_DIR}/${name}_dummysrc.cpp")
if(NOT EXISTS "${dummy_src}")
file(WRITE "${dummy_src}" "")
endif()
target_sources(${name} PRIVATE "${dummy_src}")
endif()
endif()

if(LLVM_COMMON_DEPENDS)
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
endif(LLVM_COMMON_DEPENDS)
Expand Down Expand Up @@ -316,13 +338,15 @@ function(add_phasar_library name)
EXPORT LLVMExports
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
${install_module}
)
else()
install(TARGETS ${name}
EXPORT PhasarExports

# NOTE: Library, archive and runtime destination are automatically set by
# GNUInstallDirs which is included in the top-level CMakeLists.txt

${install_module}
)
endif()

Expand Down
7 changes: 3 additions & 4 deletions include/phasar/AnalysisStrategy/AnalysisSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#ifndef PHASAR_ANALYSISSTRATEGY_ANALYSISSETUP_H
#define PHASAR_ANALYSISSTRATEGY_ANALYSISSETUP_H

#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h"
#include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h"

namespace psr {
class LLVMAliasSet;
class LLVMBasedICFG;
class DIBasedTypeHierarchy;

/// Indicates that an analysis does not need a special configuration (file).
struct HasNoConfigurationType {};
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/ControlFlow/SparseCFGProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct has_getSparseCFG<

template <typename T, typename D>
// NOLINTNEXTLINE
static constexpr bool has_getSparseCFG_v = has_getSparseCFG<T, D>::value;
constexpr bool has_getSparseCFG_v = has_getSparseCFG<T, D>::value;
} // namespace psr

#endif // PHASAR_CONTROLFLOW_SPARSECFGPROVIDER_H
15 changes: 7 additions & 8 deletions include/phasar/DataFlow/IfdsIde/Solver/StaticIDESolverConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ enum class JumpFunctionGCMode {

struct IDESolverConfigBase {
template <typename K, typename V>
static inline constexpr bool
IsSimple1d = sizeof(std::pair<K, V>) <= 32 &&
std::is_nothrow_move_constructible_v<K>
&&std::is_nothrow_move_constructible_v<V>
&&has_llvm_dense_map_info<K>;
static inline constexpr bool IsSimple1d =
sizeof(std::pair<K, V>) <= 32 &&
std::is_nothrow_move_constructible_v<K> &&
std::is_nothrow_move_constructible_v<V> && has_llvm_dense_map_info<K>;

template <typename T>
static inline constexpr bool
IsSimpleVal = sizeof(T) <= 32 && std::is_nothrow_move_constructible_v<T>
&&has_llvm_dense_map_info<T>;
static inline constexpr bool IsSimpleVal =
sizeof(T) <= 32 && std::is_nothrow_move_constructible_v<T> &&
has_llvm_dense_map_info<T>;

template <typename K, typename V>
using map_t = std::conditional_t<IsSimple1d<K, V>, DenseTable1d<K, V>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Fabian Schiebel and others
*****************************************************************************/

#ifndef PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_H
#define PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_H
#ifndef PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_VIEW_H
#define PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_VIEW_H

#include "phasar/ControlFlow/CallGraph.h"
#include "phasar/ControlFlow/ICFGBase.h"
Expand Down Expand Up @@ -75,4 +75,4 @@ class SparseLLVMBasedICFGView
};
} // namespace psr

#endif // PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_H
#endif // PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_VIEW_H
4 changes: 2 additions & 2 deletions include/phasar/TypeHierarchy/TypeHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ template <typename T, typename F> class TypeHierarchy {
};

template <typename T, typename F>
static inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const TypeHierarchy<T, F> &TH) {
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const TypeHierarchy<T, F> &TH) {
TH.print(OS);
return OS;
}
Expand Down
4 changes: 2 additions & 2 deletions include/phasar/TypeHierarchy/VFTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ template <typename F> class VFTable {
};

template <typename T, typename F>
static inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const VFTable<F> &Table) {
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const VFTable<F> &Table) {
Table.print(OS);
return OS;
}
Expand Down
8 changes: 5 additions & 3 deletions include/phasar/Utils/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
namespace psr {

#if __cplusplus < 202002L
template <typename T> struct type_identity { using type = T; };
template <typename T> struct type_identity {
using type = T;
};
#else
template <typename T> using type_identity = std::type_identity<T>;
#endif
Expand Down Expand Up @@ -275,12 +277,12 @@ PSR_CONCEPT has_isInteresting_v = // NOLINT
detail::has_isInteresting<ProblemTy>::value;

template <typename T>
static constexpr bool has_llvm_dense_map_info =
constexpr bool has_llvm_dense_map_info =
detail::has_llvm_dense_map_info<T>::value;
template <typename T> using type_identity_t = typename type_identity<T>::type;

template <typename Var, typename T>
static constexpr size_t variant_idx = detail::variant_idx<Var, T>::value;
constexpr size_t variant_idx = detail::variant_idx<Var, T>::value;

template <typename Container>
using ElementType = typename detail::ElementType<Container>::type;
Expand Down
7 changes: 6 additions & 1 deletion lib/AnalysisStrategy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ file(GLOB_RECURSE ANALYSIS_STRATEGY_SRC *.h *.cpp)

add_phasar_library(phasar_analysis_strategy
${ANALYSIS_STRATEGY_SRC}
LLVM_LINK_COMPONENTS Support

LLVM_LINK_COMPONENTS
Support

MODULE_FILES
Strategies.cppm
)
19 changes: 19 additions & 0 deletions lib/AnalysisStrategy/Strategies.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module;

#include "phasar/AnalysisStrategy.h"

export module phasar.analysisstrategy;

export namespace psr {
using psr::AnalysisSetup;
using psr::AnalysisStrategy;
using psr::DefaultAnalysisSetup;
using psr::DemandDrivenAnalysis;
using psr::HasNoConfigurationType;
using psr::IncrementalUpdateAnalysis;
using psr::ModuleWiseAnalysis;
using psr::toAnalysisStrategy;
using psr::toString;
using psr::VariationalAnalysis;
using psr::operator<<;
} // namespace psr
41 changes: 28 additions & 13 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
add_subdirectory(AnalysisStrategy)
add_subdirectory(Config)
add_subdirectory(ControlFlow)
add_subdirectory(DataFlow)
add_subdirectory(DB)
add_subdirectory(Domain)
add_subdirectory(PhasarLLVM)
add_subdirectory(PhasarPass)
add_subdirectory(DB)
add_subdirectory(Config)
add_subdirectory(Utils)
add_subdirectory(Pointer)
add_subdirectory(ControlFlow)
add_subdirectory(TypeHierarchy)
add_subdirectory(Utils)

if(BUILD_PHASAR_CLANG)
if(PHASAR_IN_TREE)
add_dependencies(phasar_interface intrinsics_gen)
Expand All @@ -18,23 +22,34 @@ if(PHASAR_BUILD_DYNLIB)
endif()

set(PHASAR_LINK_LIBS
phasar_utils
phasar_passes
phasar_analysis_strategy
phasar_config
phasar_pointer
phasar_controlflow
phasar_dataflow
phasar_dataflow_ifdside
phasar_dataflow_mono
phasar_dataflow_pathsensitivity
phasar_db
phasar_domain

phasar_llvm_utils
phasar_llvm
phasar_llvm_controlflow
phasar_llvm_ifdside
phasar_llvm_mono
phasar_llvm_pathsensitivity
phasar_llvm_dataflow
phasar_llvm_db
phasar_llvm_domain
phasar_llvm_pointer
phasar_llvm_typehierarchy
phasar_llvm_controlflow
phasar_llvm_utils

phasar_pass
phasar_passes
phasar_pointer
phasar_taintconfig
phasar_mono
phasar_llvm
phasar_llvm_ifdside
phasar_analysis_strategy
phasar_typehierarchy
phasar_utils
)
if(BUILD_PHASAR_CLANG)
list(APPEND PHASAR_LINK_LIBS phasar_clang)
Expand Down
15 changes: 12 additions & 3 deletions lib/Config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ file(GLOB_RECURSE CONFIG_SRC *.h *.cpp)

add_phasar_library(phasar_config
${CONFIG_SRC}
LINKS phasar_utils
LINK_PRIVATE ${Boost_LIBRARIES}
LLVM_LINK_COMPONENTS Support

LINKS
phasar_utils

LINK_PRIVATE
${Boost_LIBRARIES}

LLVM_LINK_COMPONENTS
Support

MODULE_FILES
Config.cppm
)
9 changes: 9 additions & 0 deletions lib/Config/Config.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module;

#include "phasar/Config.h"

export module phasar.config;

export namespace psr {
using psr::PhasarConfig;
} // namespace psr
12 changes: 10 additions & 2 deletions lib/ControlFlow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ file(GLOB_RECURSE CONTROLFLOW_SRC *.h *.cpp)

add_phasar_library(phasar_controlflow
${CONTROLFLOW_SRC}

LINKS
phasar_utils
LLVM_LINK_COMPONENTS Support
LINK_PRIVATE nlohmann_json::nlohmann_json

LLVM_LINK_COMPONENTS
Support

LINK_PRIVATE
nlohmann_json::nlohmann_json

MODULE_FILES
ControlFlow.cppm
)
32 changes: 32 additions & 0 deletions lib/ControlFlow/ControlFlow.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module;

#include "phasar/ControlFlow.h"
#include "phasar/ControlFlow/SparseCFGBase.h"
#include "phasar/ControlFlow/SparseCFGProvider.h"

export module phasar.controlflow;

export namespace psr {
using psr::CallGraph;
using psr::CallGraphAnalysisType;
using psr::CallGraphBuilder;
using psr::CGTraits;
using psr::toCallGraphAnalysisType;
using psr::toString;
using psr::operator<<;
using psr::CallGraphBase;
using psr::CallGraphData;
using psr::CFGBase;
using psr::CFGTraits;
using psr::has_getSparseCFG;
using psr::has_getSparseCFG_v;
using psr::ICFGBase;
using psr::is_cfg_v;
using psr::is_icfg_v;
using psr::is_sparse_cfg_v;
using psr::SparseCFGBase;
using psr::SparseCFGProvider;
using psr::SpecialMemberFunctionType;
using psr::toSpecialMemberFunctionType;
using psr::valueOf;
} // namespace psr
15 changes: 12 additions & 3 deletions lib/DB/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ if(SQLite3_FOUND)

add_phasar_library(phasar_db
${DB_SRC}
LINKS phasar_passes phasar_utils
LLVM_LINK_COMPONENTS Support
LINK_PRIVATE SQLite::SQLite3

LINKS phasar_passes
phasar_utils

LLVM_LINK_COMPONENTS
Support

LINK_PRIVATE
SQLite::SQLite3

MODULE_FILES
DB.cppm
)
endif()
Loading
Loading