diff --git a/CMakeLists.txt b/CMakeLists.txt index 5370c88ee3..58083e3b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Config.cmake.in b/Config.cmake.in index fce796ba73..ecdb47dbc9 100644 --- a/Config.cmake.in +++ b/Config.cmake.in @@ -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) diff --git a/README.md b/README.md index 17396e5464..d5a5538a7b 100644 --- a/README.md +++ b/README.md @@ -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.* diff --git a/cmake/phasar_macros.cmake b/cmake/phasar_macros.cmake index c991f508db..2bd952852c 100644 --- a/cmake/phasar_macros.cmake +++ b/cmake/phasar_macros.cmake @@ -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}) @@ -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) @@ -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() diff --git a/include/phasar/AnalysisStrategy/AnalysisSetup.h b/include/phasar/AnalysisStrategy/AnalysisSetup.h index 7b40140d4c..42005c36d2 100644 --- a/include/phasar/AnalysisStrategy/AnalysisSetup.h +++ b/include/phasar/AnalysisStrategy/AnalysisSetup.h @@ -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 {}; diff --git a/include/phasar/ControlFlow/SparseCFGProvider.h b/include/phasar/ControlFlow/SparseCFGProvider.h index 1ef2882f6a..e048310310 100644 --- a/include/phasar/ControlFlow/SparseCFGProvider.h +++ b/include/phasar/ControlFlow/SparseCFGProvider.h @@ -48,7 +48,7 @@ struct has_getSparseCFG< template // NOLINTNEXTLINE -static constexpr bool has_getSparseCFG_v = has_getSparseCFG::value; +constexpr bool has_getSparseCFG_v = has_getSparseCFG::value; } // namespace psr #endif // PHASAR_CONTROLFLOW_SPARSECFGPROVIDER_H diff --git a/include/phasar/DataFlow/IfdsIde/Solver/StaticIDESolverConfig.h b/include/phasar/DataFlow/IfdsIde/Solver/StaticIDESolverConfig.h index 1dc2316524..42b882b27e 100644 --- a/include/phasar/DataFlow/IfdsIde/Solver/StaticIDESolverConfig.h +++ b/include/phasar/DataFlow/IfdsIde/Solver/StaticIDESolverConfig.h @@ -25,16 +25,15 @@ enum class JumpFunctionGCMode { struct IDESolverConfigBase { template - static inline constexpr bool - IsSimple1d = sizeof(std::pair) <= 32 && - std::is_nothrow_move_constructible_v - &&std::is_nothrow_move_constructible_v - &&has_llvm_dense_map_info; + static inline constexpr bool IsSimple1d = + sizeof(std::pair) <= 32 && + std::is_nothrow_move_constructible_v && + std::is_nothrow_move_constructible_v && has_llvm_dense_map_info; template - static inline constexpr bool - IsSimpleVal = sizeof(T) <= 32 && std::is_nothrow_move_constructible_v - &&has_llvm_dense_map_info; + static inline constexpr bool IsSimpleVal = + sizeof(T) <= 32 && std::is_nothrow_move_constructible_v && + has_llvm_dense_map_info; template using map_t = std::conditional_t, DenseTable1d, diff --git a/include/phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedICFGView.h b/include/phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedICFGView.h index 7fbbb65a5e..64010f2935 100644 --- a/include/phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedICFGView.h +++ b/include/phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedICFGView.h @@ -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" @@ -75,4 +75,4 @@ class SparseLLVMBasedICFGView }; } // namespace psr -#endif // PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_H +#endif // PHASAR_PHASARLLVM_CONTROLFLOW_SPARSELLVMBASEDICFG_VIEW_H diff --git a/include/phasar/TypeHierarchy/TypeHierarchy.h b/include/phasar/TypeHierarchy/TypeHierarchy.h index 5d06705d1b..6c54407cd8 100644 --- a/include/phasar/TypeHierarchy/TypeHierarchy.h +++ b/include/phasar/TypeHierarchy/TypeHierarchy.h @@ -42,8 +42,8 @@ template class TypeHierarchy { }; template -static inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, - const TypeHierarchy &TH) { +inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, + const TypeHierarchy &TH) { TH.print(OS); return OS; } diff --git a/include/phasar/TypeHierarchy/VFTable.h b/include/phasar/TypeHierarchy/VFTable.h index 4fc331cf53..62eb4432af 100644 --- a/include/phasar/TypeHierarchy/VFTable.h +++ b/include/phasar/TypeHierarchy/VFTable.h @@ -41,8 +41,8 @@ template class VFTable { }; template -static inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, - const VFTable &Table) { +inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, + const VFTable &Table) { Table.print(OS); return OS; } diff --git a/include/phasar/Utils/TypeTraits.h b/include/phasar/Utils/TypeTraits.h index 7f0023af2f..1e2f2524cc 100644 --- a/include/phasar/Utils/TypeTraits.h +++ b/include/phasar/Utils/TypeTraits.h @@ -28,7 +28,9 @@ namespace psr { #if __cplusplus < 202002L -template struct type_identity { using type = T; }; +template struct type_identity { + using type = T; +}; #else template using type_identity = std::type_identity; #endif @@ -275,12 +277,12 @@ PSR_CONCEPT has_isInteresting_v = // NOLINT detail::has_isInteresting::value; template -static constexpr bool has_llvm_dense_map_info = +constexpr bool has_llvm_dense_map_info = detail::has_llvm_dense_map_info::value; template using type_identity_t = typename type_identity::type; template -static constexpr size_t variant_idx = detail::variant_idx::value; +constexpr size_t variant_idx = detail::variant_idx::value; template using ElementType = typename detail::ElementType::type; diff --git a/lib/AnalysisStrategy/CMakeLists.txt b/lib/AnalysisStrategy/CMakeLists.txt index 8a194cc68a..3ecd9f9c15 100644 --- a/lib/AnalysisStrategy/CMakeLists.txt +++ b/lib/AnalysisStrategy/CMakeLists.txt @@ -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 ) diff --git a/lib/AnalysisStrategy/Strategies.cppm b/lib/AnalysisStrategy/Strategies.cppm new file mode 100644 index 0000000000..6b776ede28 --- /dev/null +++ b/lib/AnalysisStrategy/Strategies.cppm @@ -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 diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ffe1291f3b..3351b1c590 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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) @@ -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) diff --git a/lib/Config/CMakeLists.txt b/lib/Config/CMakeLists.txt index 455fa8fbf8..4c125ca131 100644 --- a/lib/Config/CMakeLists.txt +++ b/lib/Config/CMakeLists.txt @@ -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 ) diff --git a/lib/Config/Config.cppm b/lib/Config/Config.cppm new file mode 100644 index 0000000000..be5b46dfca --- /dev/null +++ b/lib/Config/Config.cppm @@ -0,0 +1,9 @@ +module; + +#include "phasar/Config.h" + +export module phasar.config; + +export namespace psr { +using psr::PhasarConfig; +} // namespace psr diff --git a/lib/ControlFlow/CMakeLists.txt b/lib/ControlFlow/CMakeLists.txt index d6f91baa6b..adebfe73ae 100644 --- a/lib/ControlFlow/CMakeLists.txt +++ b/lib/ControlFlow/CMakeLists.txt @@ -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 ) diff --git a/lib/ControlFlow/ControlFlow.cppm b/lib/ControlFlow/ControlFlow.cppm new file mode 100644 index 0000000000..04ae8d675d --- /dev/null +++ b/lib/ControlFlow/ControlFlow.cppm @@ -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 diff --git a/lib/DB/CMakeLists.txt b/lib/DB/CMakeLists.txt index 74fef8d36a..5469d9933d 100644 --- a/lib/DB/CMakeLists.txt +++ b/lib/DB/CMakeLists.txt @@ -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() diff --git a/lib/DB/DB.cppm b/lib/DB/DB.cppm new file mode 100644 index 0000000000..70c396ce87 --- /dev/null +++ b/lib/DB/DB.cppm @@ -0,0 +1,33 @@ +module; + +#include "phasar/DB/Hexastore.h" +#include "phasar/DB/ProjectIRDBBase.h" +#include "phasar/DB/Queries.h" + +export module phasar.db; + +export namespace psr { +using psr::IRDBGetFunctionDef; +using psr::ProjectIRDBBase; +using psr::ProjectIRDBTraits; + +#ifdef PHASAR_HAS_SQLITE +using psr::Hexastore; +using psr::HSResult; +using psr::INIT; +using psr::OPSInsert; +using psr::OSPInsert; +using psr::POSInsert; +using psr::PSOInsert; +using psr::SearchSPO; +using psr::SearchSPX; +using psr::SearchSXO; +using psr::SearchSXX; +using psr::SearchXPO; +using psr::SearchXPX; +using psr::SearchXXO; +using psr::SearchXXX; +using psr::SOPInsert; +using psr::SPOInsert; +#endif +} // namespace psr diff --git a/lib/DataFlow/CMakeLists.txt b/lib/DataFlow/CMakeLists.txt new file mode 100644 index 0000000000..8fbdcb465a --- /dev/null +++ b/lib/DataFlow/CMakeLists.txt @@ -0,0 +1,17 @@ +add_subdirectory(IfdsIde) +add_subdirectory(Mono) +add_subdirectory(PathSensitivity) + +file(GLOB_RECURSE DATAFLOW_SRC *.h *.cpp) + +add_phasar_library(phasar_dataflow + ${DATAFLOW_SRC} + + LINKS + phasar_dataflow_ifdside + phasar_dataflow_mono + phasar_dataflow_pathsensitivity + + MODULE_FILES + DataFlow.cppm +) diff --git a/lib/DataFlow/DataFlow.cppm b/lib/DataFlow/DataFlow.cppm new file mode 100644 index 0000000000..674406d5f4 --- /dev/null +++ b/lib/DataFlow/DataFlow.cppm @@ -0,0 +1,7 @@ +module; + +export module phasar.dataflow; + +export import phasar.dataflow.ifdside; +export import phasar.dataflow.mono; +export import phasar.dataflow.pathsensitivity; diff --git a/lib/DataFlow/IfdsIde/CMakeLists.txt b/lib/DataFlow/IfdsIde/CMakeLists.txt new file mode 100644 index 0000000000..763e5bb437 --- /dev/null +++ b/lib/DataFlow/IfdsIde/CMakeLists.txt @@ -0,0 +1,11 @@ +file(GLOB_RECURSE IFDSIDE_SRC *.h *.cpp) + +add_phasar_library(phasar_dataflow_ifdside + ${IFDSIDE_SRC} + + LINK_PRIVATE + nlohmann_json::nlohmann_json + + MODULE_FILES + IfdsIde.cppm +) diff --git a/lib/DataFlow/IfdsIde/IfdsIde.cppm b/lib/DataFlow/IfdsIde/IfdsIde.cppm new file mode 100644 index 0000000000..58d2744f7f --- /dev/null +++ b/lib/DataFlow/IfdsIde/IfdsIde.cppm @@ -0,0 +1,122 @@ +module; + +#include "phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h" +#include "phasar/DataFlow/IfdsIde/EdgeFunctionStats.h" +#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h" +#include "phasar/DataFlow/IfdsIde/EdgeFunctions.h" +#include "phasar/DataFlow/IfdsIde/EntryPointUtils.h" +#include "phasar/DataFlow/IfdsIde/FlowFunctions.h" +#include "phasar/DataFlow/IfdsIde/GenericFlowFunction.h" +#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" +#include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/DataFlow/IfdsIde/Solver/Compressor.h" +#include "phasar/DataFlow/IfdsIde/Solver/EdgeFunctionCache.h" +#include "phasar/DataFlow/IfdsIde/Solver/FlowEdgeFunctionCacheNG.h" +#include "phasar/DataFlow/IfdsIde/Solver/FlowFunctionCache.h" +#include "phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h" +#include "phasar/DataFlow/IfdsIde/Solver/IdBasedSolverResults.h" +#include "phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h" +#include "phasar/DataFlow/IfdsIde/Solver/PathAwareIDESolver.h" + +export module phasar.dataflow.ifdside; + +export namespace psr { +using psr::AllBottom; +using psr::AllTop; +using psr::CachedEdgeFunction; +using psr::ConstantEdgeFunction; +using psr::defaultComposeOrNull; +using psr::DefaultEdgeFunctionSingletonCache; +using psr::DefaultEdgeFunctionSingletonCacheImpl; +using psr::EdgeFunction; +using psr::EdgeFunctionAllocationPolicy; +using psr::EdgeFunctionBase; +using psr::EdgeFunctionRef; +using psr::EdgeFunctions; +using psr::EdgeFunctionSingletonCache; +using psr::EdgeFunctionStats; +using psr::EdgeIdentity; +using psr::IsEdgeFunction; +using psr::operator==; +using psr::operator<<; +using psr::addSeedsForStartingPoints; +using psr::AllTopFnProvider; +using psr::checkSREquality; +using psr::Compressor; +using psr::ConstantEdgeFunction; +using psr::defaultJoinOrNull; +using psr::DefaultMapKeyCompressor; +using psr::EdgeFunctionCache; +using psr::EdgeFunctionCacheStats; +using psr::EdgeFunctionComposer; +using psr::EdgeFunctionKind; +using psr::ESGEdgeKind; +using psr::FlowEdgeFunctionCache; +using psr::FlowEdgeFunctionCacheNG; +using psr::FlowEdgeFunctionCacheStats; +using psr::FlowFunction; +using psr::FlowFunctionCache; +using psr::FlowFunctionCacheStats; +using psr::FlowFunctionPtrTypeOf; +using psr::FlowFunctions; +using psr::FlowFunctionTemplates; +using psr::forallStartingPoints; +using psr::GenericFlowFunction; +using psr::GenericFlowFunctionView; +using psr::GenericSolverResults; +using psr::getMetaDataID; +using psr::IdBasedSolverResults; +using psr::IDESolver; +using psr::IDETabulationProblem; +using psr::ifdsEqual; +using psr::IFDSIDESolverConfig; +using psr::IFDSSolver; +using psr::IFDSTabulationProblem; +using psr::InitialSeeds; +using psr::IsFlowFunction; +using psr::JoinEdgeFunction; +using psr::LLVMMapKeyCompressor; +using psr::MapKeyCompressorCombinator; +using psr::NodeCompressorTraits; +using psr::NoneCompressor; +using psr::OwningSolverResults; +using psr::SolverConfigOptions; +using psr::SolverResults; +using psr::ValCompressorTraits; +using psr::ZeroedFlowFunction; +using psr::operator<<; +using psr::DefaultIDESolverConfig; +using psr::DequeWorkList; +using psr::IDESolverAPIMixin; +using psr::IDESolverConfigBase; +using psr::IterativeIDESolver; +using psr::IterativeIDESolverBase; +using psr::IterativeIDESolverStats; +using psr::IterIDEPropagationJob; +using psr::JumpFunctionGCMode; +using psr::JumpFunctions; +using psr::OwningSolverResults; +using psr::PathAwareIDESolver; +using psr::PathEdge; +using psr::SmallVectorWorkList; +using psr::solveIDEProblem; +using psr::solveIFDSProblem; +using psr::SolverStatsSelector; +using psr::VectorWorkList; +using psr::WithComputeValues; +using psr::WithEndSummaryTab; +using psr::WithGCMode; +using psr::WithStats; +using psr::WithWorkList; +} // namespace psr + +export namespace llvm { +using llvm::cast_convert_val; +using llvm::cast_or_null; +using llvm::cast_retty_impl; +using llvm::CastInfo; +using llvm::CastIsPossible; +using llvm::DenseMapInfo; +using llvm::dyn_cast_or_null; +using llvm::isa_impl_cl; +} // namespace llvm diff --git a/lib/DataFlow/Mono/CMakeLists.txt b/lib/DataFlow/Mono/CMakeLists.txt new file mode 100644 index 0000000000..abf6f6397a --- /dev/null +++ b/lib/DataFlow/Mono/CMakeLists.txt @@ -0,0 +1,11 @@ +file(GLOB_RECURSE MONO_SRC *.h *.cpp) + +add_phasar_library(phasar_dataflow_mono + ${MONO_SRC} + + LINK_PRIVATE + nlohmann_json::nlohmann_json + + MODULE_FILES + Mono.cppm +) diff --git a/lib/DataFlow/Mono/Mono.cppm b/lib/DataFlow/Mono/Mono.cppm new file mode 100644 index 0000000000..8d0f77d825 --- /dev/null +++ b/lib/DataFlow/Mono/Mono.cppm @@ -0,0 +1,20 @@ +module; + +#include "phasar/DataFlow/Mono/Contexts/CallStringCTX.h" +#include "phasar/DataFlow/Mono/InterMonoProblem.h" +#include "phasar/DataFlow/Mono/Solver/InterMonoSolver.h" +#include "phasar/DataFlow/Mono/Solver/IntraMonoSolver.h" + +export module phasar.dataflow.mono; + +export namespace psr { +using psr::CallStringCTX; +using psr::InterMonoProblem; +using psr::InterMonoSolver; +using psr::IntraMonoProblem; +using psr::IntraMonoSolver; +} // namespace psr + +export namespace std { +using std::hash; +} // namespace std diff --git a/lib/DataFlow/PathSensitivity/CMakeLists.txt b/lib/DataFlow/PathSensitivity/CMakeLists.txt new file mode 100644 index 0000000000..6ed81a3225 --- /dev/null +++ b/lib/DataFlow/PathSensitivity/CMakeLists.txt @@ -0,0 +1,11 @@ +file(GLOB_RECURSE PATHSENSITIVITY_SRC *.h *.cpp) + +add_phasar_library(phasar_dataflow_pathsensitivity + ${PATHSENSITIVITY_SRC} + + LINK_PRIVATE + nlohmann_json::nlohmann_json + + MODULE_FILES + PathSensitivity.cppm +) diff --git a/lib/DataFlow/PathSensitivity/PathSensitivity.cppm b/lib/DataFlow/PathSensitivity/PathSensitivity.cppm new file mode 100644 index 0000000000..f913d862af --- /dev/null +++ b/lib/DataFlow/PathSensitivity/PathSensitivity.cppm @@ -0,0 +1,20 @@ +module; + +#include "phasar/DataFlow/PathSensitivity/ExplodedSuperGraph.h" +#include "phasar/DataFlow/PathSensitivity/FlowPath.h" +#include "phasar/DataFlow/PathSensitivity/PathSensitivityConfig.h" +#include "phasar/DataFlow/PathSensitivity/PathSensitivityManager.h" + +export module phasar.dataflow.pathsensitivity; + +export namespace psr { +using psr::ExplodedSuperGraph; +using psr::FlowPath; +using psr::is_pathtracingfilter_for; +using psr::PathSensitivityConfig; +using psr::PathSensitivityConfigBase; +using psr::PathSensitivityManager; +using psr::PathSensitivityManagerBase; +using psr::PathSensitivityManagerMixin; +using psr::PathTracingFilter; +} // namespace psr diff --git a/lib/Domain/CMakeLists.txt b/lib/Domain/CMakeLists.txt new file mode 100644 index 0000000000..2879357b44 --- /dev/null +++ b/lib/Domain/CMakeLists.txt @@ -0,0 +1,11 @@ +file(GLOB_RECURSE DOMAIN_SRC *.h *.cpp) + +add_phasar_library(phasar_domain + ${DOMAIN_SRC} + + LINK_PRIVATE + nlohmann_json::nlohmann_json + + MODULE_FILES + Domain.cppm +) diff --git a/lib/Domain/Domain.cppm b/lib/Domain/Domain.cppm new file mode 100644 index 0000000000..2b78a69370 --- /dev/null +++ b/lib/Domain/Domain.cppm @@ -0,0 +1,25 @@ +module; + +#include "phasar/Domain/AnalysisDomain.h" +#include "phasar/Domain/BinaryDomain.h" +#include "phasar/Domain/LatticeDomain.h" + +export module phasar.domain; + +export namespace psr { +using psr::AnalysisDomain; +using psr::BinaryDomain; +using psr::to_string; +using psr::operator<<; +using psr::operator==; +using psr::operator<; +using psr::Bottom; +using psr::JoinLatticeTraits; +using psr::LatticeDomain; +using psr::NonTopBotValue; +using psr::Top; +} // namespace psr + +export namespace std { +using std::hash; +} // namespace std diff --git a/lib/PhasarLLVM/CMakeLists.txt b/lib/PhasarLLVM/CMakeLists.txt index be4adc5e0b..2a3908722b 100644 --- a/lib/PhasarLLVM/CMakeLists.txt +++ b/lib/PhasarLLVM/CMakeLists.txt @@ -1,6 +1,7 @@ -add_subdirectory(DB) add_subdirectory(ControlFlow) add_subdirectory(DataFlow) +add_subdirectory(DB) +add_subdirectory(Domain) add_subdirectory(Passes) add_subdirectory(Pointer) add_subdirectory(TaintConfig) @@ -13,13 +14,22 @@ add_phasar_library(phasar_llvm ${PHASAR_LLVM_SRC} LINKS - phasar_utils - phasar_llvm_pointer - phasar_llvm_db phasar_llvm_controlflow + phasar_llvm_dataflow + phasar_llvm_db + phasar_llvm_domain + phasar_llvm_ifdside + phasar_llvm_pointer phasar_llvm_typehierarchy + phasar_llvm_utils + phasar_passes + phasar_utils + phasar_taintconfig LLVM_LINK_COMPONENTS Core Support + + MODULE_FILES + PhasarLLVM.cppm ) diff --git a/lib/PhasarLLVM/ControlFlow/CMakeLists.txt b/lib/PhasarLLVM/ControlFlow/CMakeLists.txt index 0000f7b1ad..23c251cf49 100644 --- a/lib/PhasarLLVM/ControlFlow/CMakeLists.txt +++ b/lib/PhasarLLVM/ControlFlow/CMakeLists.txt @@ -13,4 +13,7 @@ add_phasar_library(phasar_llvm_controlflow Core Support Demangle + + MODULE_FILES + ControlFlow.cppm ) diff --git a/lib/PhasarLLVM/ControlFlow/ControlFlow.cppm b/lib/PhasarLLVM/ControlFlow/ControlFlow.cppm new file mode 100644 index 0000000000..271967a5b2 --- /dev/null +++ b/lib/PhasarLLVM/ControlFlow/ControlFlow.cppm @@ -0,0 +1,48 @@ +module; + +#include "phasar/PhasarLLVM/ControlFlow/EntryFunctionUtils.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFG.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCallGraphBuilder.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h" +#include "phasar/PhasarLLVM/ControlFlow/Resolver/NOResolver.h" +#include "phasar/PhasarLLVM/ControlFlow/Resolver/OTFResolver.h" +#include "phasar/PhasarLLVM/ControlFlow/Resolver/RTAResolver.h" +#include "phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedCFG.h" +#include "phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedCFGProvider.h" +#include "phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedICFG.h" +#include "phasar/PhasarLLVM/ControlFlow/SparseLLVMBasedICFGView.h" + +export module phasar.llvm.controlflow; + +export namespace psr { +using psr::buildLLVMBasedCallGraph; +using psr::CFGTraits; +using psr::CHAResolver; +using psr::getEntryFunctions; +using psr::getEntryFunctionsMut; +using psr::getNonPureVirtualVFTEntry; +using psr::getReceiverType; +using psr::getReceiverTypeName; +using psr::getVFTIndex; +using psr::GlobalCtorsDtorsModel; +using psr::ICFGBase; +using psr::isConsistentCall; +using psr::isHeapAllocatingFunction; +using psr::isVirtualCall; +using psr::LLVMBasedBackwardCFG; +using psr::LLVMBasedBackwardICFG; +using psr::LLVMBasedCallGraph; +using psr::LLVMBasedCFG; +using psr::LLVMBasedICFG; +using psr::LLVMVFTableProvider; +using psr::NOResolver; +using psr::OTFResolver; +using psr::Resolver; +using psr::RTAResolver; +using psr::SparseLLVMBasedCFG; +using psr::SparseLLVMBasedCFGProvider; +using psr::SparseLLVMBasedICFG; +using psr::SparseLLVMBasedICFGView; +using psr::valueOf; +} // namespace psr diff --git a/lib/PhasarLLVM/DB/CMakeLists.txt b/lib/PhasarLLVM/DB/CMakeLists.txt index bb6e3c3960..062af754c8 100644 --- a/lib/PhasarLLVM/DB/CMakeLists.txt +++ b/lib/PhasarLLVM/DB/CMakeLists.txt @@ -11,4 +11,7 @@ add_phasar_library(phasar_llvm_db Core Support IRReader + + MODULE_FILES + DB.cppm ) diff --git a/lib/PhasarLLVM/DB/DB.cppm b/lib/PhasarLLVM/DB/DB.cppm new file mode 100644 index 0000000000..ec8a41b961 --- /dev/null +++ b/lib/PhasarLLVM/DB/DB.cppm @@ -0,0 +1,11 @@ +module; + +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" + +export module phasar.llvm.db; + +export namespace psr { +using psr::fromMetaDataId; +using psr::LLVMProjectIRDB; +using psr::ProjectIRDBTraits; +} // namespace psr diff --git a/lib/PhasarLLVM/DataFlow/CMakeLists.txt b/lib/PhasarLLVM/DataFlow/CMakeLists.txt index 3af5da4864..06e922a93e 100644 --- a/lib/PhasarLLVM/DataFlow/CMakeLists.txt +++ b/lib/PhasarLLVM/DataFlow/CMakeLists.txt @@ -1,3 +1,13 @@ add_subdirectory(IfdsIde) add_subdirectory(Mono) add_subdirectory(PathSensitivity) + +add_phasar_library(phasar_llvm_dataflow + LINKS + phasar_llvm_ifdside + phasar_llvm_mono + phasar_llvm_pathsensitivity + + MODULE_FILES + DataFlow.cppm +) diff --git a/lib/PhasarLLVM/DataFlow/DataFlow.cppm b/lib/PhasarLLVM/DataFlow/DataFlow.cppm new file mode 100644 index 0000000000..5a769f0546 --- /dev/null +++ b/lib/PhasarLLVM/DataFlow/DataFlow.cppm @@ -0,0 +1,7 @@ +module; + +export module phasar.llvm.dataflow; + +export import phasar.llvm.dataflow.ifdside; +export import phasar.llvm.dataflow.mono; +export import phasar.llvm.dataflow.pathsensitivity; diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt b/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt index 327eb03afd..4c66687fb5 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt @@ -7,7 +7,6 @@ add_phasar_library(phasar_llvm_ifdside phasar_config phasar_utils phasar_llvm_pointer - phasar_llvm phasar_llvm_typehierarchy phasar_llvm_controlflow phasar_llvm_utils @@ -20,4 +19,7 @@ add_phasar_library(phasar_llvm_ifdside LINK_PRIVATE ${Boost_LIBRARIES} + + MODULE_FILES + IfdsIde.cppm ) diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/IfdsIde.cppm b/lib/PhasarLLVM/DataFlow/IfdsIde/IfdsIde.cppm new file mode 100644 index 0000000000..94a9f38607 --- /dev/null +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/IfdsIde.cppm @@ -0,0 +1,172 @@ +module; + +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultAliasAwareIDEProblem.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LibCSummary.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/AbstractMemoryLocation.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/AbstractMemoryLocationFactory.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/AllSanitized.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/ComposeEdgeFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/EdgeDomain.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/GenEdgeFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/Helpers.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/KillIfSanitizedEdgeFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/TransferEdgeFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/XTaintAnalysisBase.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/XTaintEdgeFunctionBase.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/BinaryEdgeFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/ConstantHelper.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/LCAEdgeFunctionComposer.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/MapFactsToCalleeFlowFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/MapFactsToCallerFlowFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/TypecastEdgeFunction.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEProtoAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSProtoAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSignAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSolverTest.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSUninitializedVariables.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.h" +#include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.h" + +export module phasar.llvm.dataflow.ifdside; + +export namespace psr { +using psr::AbstractMemoryLocation; +using psr::AbstractMemoryLocationFactory; +using psr::BasicBlockOrdering; +using psr::DToString; +using psr::FeatureTaintGenerator; +using psr::hash_value; +using psr::IDEExtendedTaintAnalysis; +using psr::IDEExtendedTaintAnalysisDomain; +using psr::IDEFeatureTaintAnalysis; +using psr::IDEFeatureTaintAnalysisDomain; +using psr::IDEFeatureTaintEdgeFact; +using psr::IDEIIAFlowFact; +using psr::IDELinearConstantAnalysis; +using psr::IFDSSolverTest; +using psr::JoinLatticeTraits; +using psr::LToString; +using psr::NonTopBotValue; +using psr::operator<<; +using psr::DefaultAliasAwareIDEProblem; +using psr::DefaultAliasAwareIFDSProblem; +using psr::DefaultNoAliasIDEProblem; +using psr::DefaultNoAliasIFDSProblem; +using psr::DToString; +using psr::IDEExtendedTaintAnalysis; +using psr::IDEInstInteractionAnalysis; +using psr::IDEInstInteractionAnalysisDomain; +using psr::IDEInstInteractionAnalysisT; +using psr::IDELinearConstantAnalysis; +using psr::IDELinearConstantAnalysisDomain; +using psr::IDEProtoAnalysis; +using psr::IDEProtoAnalysisDomain; +using psr::IDESecureHeapPropagation; +using psr::IDESecureHeapPropagationAnalysisDomain; +using psr::IDESolverTest; +using psr::IDESolverTestAnalysisDomain; +using psr::IDETypeStateAnalysis; +using psr::IDETypeStateAnalysisDomain; +using psr::IFDSConstAnalysis; +using psr::IFDSProtoAnalysis; +using psr::IFDSSignAnalysis; +using psr::IFDSSolverTest; +using psr::IFDSTaintAnalysis; +using psr::IFDSTypeAnalysis; +using psr::IFDSUninitializedVariables; +using psr::JoinLatticeTraits; +using psr::LLVMZeroValue; +using psr::LToString; +using psr::mapFactsAlongsideCallSite; +using psr::mapFactsToCallee; +using psr::mapFactsToCaller; +using psr::SecureHeapFact; +using psr::SecureHeapValue; +using psr::strongUpdateStore; +using psr::operator<<; +using psr::operator==; +using psr::CSTDFILEIOState; +using psr::EdgeFunctionBase; +using psr::IDEGeneralizedLCA; +using psr::IDEGeneralizedLCADomain; +using psr::JoinLatticeTraits; +using psr::to_string; +using psr::operator<<; +using psr::CSTDFILEIOTypeStateDescription; +using psr::getLibCSummary; +using psr::IDETypeStateAnalysis; +using psr::OpenSSLEVPKDFCTXDescription; +using psr::OpenSSLEVPKDFCTXState; +using psr::OpenSSLEVPKDFDescription; +using psr::OpenSSLEVPKDFState; +using psr::OpenSSLSecureHeapDescription; +using psr::OpenSSLSecureHeapState; +using psr::OpenSSLSecureMemoryDescription; +using psr::OpenSSLSecureMemoryState; +using psr::to_string; +using psr::TypeStateDescription; +using psr::TypeStateDescriptionBase; +} // namespace psr + +export namespace std { +using std::hash; +} // namespace std + +export namespace psr::library_summary { +using psr::library_summary::DataFlowFact; +using psr::library_summary::FunctionDataFlowFacts; +using psr::library_summary::LLVMFunctionDataFlowFacts; +using psr::library_summary::Parameter; +using psr::library_summary::readFromFDFF; +using psr::library_summary::ReturnValue; +} // namespace psr::library_summary + +export namespace llvm { +using llvm::DenseMapInfo; +} // namespace llvm + +export namespace psr::XTaint { +using psr::XTaint::AnalysisBase; +using psr::XTaint::ComposeEdgeFunction; +using psr::XTaint::EdgeDomain; +using psr::XTaint::KillIfSanitizedEdgeFunction; +using psr::XTaint::makeComposeEF; +using psr::XTaint::makeFF; +using psr::XTaint::Sanitized; +using psr::XTaint::TransferEdgeFunction; +} // namespace psr::XTaint + +namespace psr::glca { +using psr::glca::BinaryEdgeFunction; +using psr::glca::compare; +using psr::glca::EdgeValue; +using psr::glca::EdgeValueSet; +using psr::glca::isConstant; +using psr::glca::join; +using psr::glca::Ordering; +using psr::glca::performBinOp; +using psr::glca::performTypecast; +using psr::glca::operator<; +using psr::glca::isTopValue; +using psr::glca::operator<<; +using psr::glca::EdgeValueSet; +using psr::glca::LCAEdgeFunctionComposer; +using psr::glca::MapFactsToCalleeFlowFunction; +using psr::glca::MapFactsToCallerFlowFunction; +using psr::glca::TypecastEdgeFunction; +using psr::glca::operator==; +using psr::glca::operator<<; +} // namespace psr::glca diff --git a/lib/PhasarLLVM/DataFlow/Mono/CMakeLists.txt b/lib/PhasarLLVM/DataFlow/Mono/CMakeLists.txt index 4bbda61731..d7e8cab632 100644 --- a/lib/PhasarLLVM/DataFlow/Mono/CMakeLists.txt +++ b/lib/PhasarLLVM/DataFlow/Mono/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB_RECURSE MONO_SRC *.h *.cpp) -add_phasar_library(phasar_mono +add_phasar_library(phasar_llvm_mono ${MONO_SRC} LINKS @@ -13,4 +13,7 @@ add_phasar_library(phasar_mono LLVM_LINK_COMPONENTS Core Support + + MODULE_FILES + Mono.cppm ) diff --git a/lib/PhasarLLVM/DataFlow/Mono/Mono.cppm b/lib/PhasarLLVM/DataFlow/Mono/Mono.cppm new file mode 100644 index 0000000000..7b104ef449 --- /dev/null +++ b/lib/PhasarLLVM/DataFlow/Mono/Mono.cppm @@ -0,0 +1,32 @@ +module; + +#include "phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoFullConstantPropagation.h" +#include "phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoSolverTest.h" +#include "phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoTaintAnalysis.h" +#include "phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoSolverTest.h" +#include "phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoUninitVariables.h" + +export module phasar.llvm.dataflow.mono; + +export namespace psr { +using psr::DIBasedTypeHierarchy; +using psr::DToString; +using psr::InterMonoFullConstantPropagation; +using psr::InterMonoSolverTest; +using psr::InterMonoSolverTestDomain; +using psr::InterMonoTaintAnalysis; +using psr::InterMonoTaintAnalysisDomain; +using psr::IntraMonoFCAFact; +using psr::IntraMonoFullConstantPropagation; +using psr::IntraMonoFullConstantPropagationAnalysisDomain; +using psr::IntraMonoSolverTest; +using psr::IntraMonoSolverTestAnalysisDomain; +using psr::IntraMonoUninitVariables; +using psr::IntraMonoUninitVariablesDomain; +using psr::LLVMBasedCFG; +using psr::LLVMBasedICFG; +} // namespace psr + +namespace std { +using std::hash; +} // namespace std diff --git a/lib/PhasarLLVM/DataFlow/PathSensitivity/CMakeLists.txt b/lib/PhasarLLVM/DataFlow/PathSensitivity/CMakeLists.txt index e0d554e718..877cd983a7 100644 --- a/lib/PhasarLLVM/DataFlow/PathSensitivity/CMakeLists.txt +++ b/lib/PhasarLLVM/DataFlow/PathSensitivity/CMakeLists.txt @@ -41,4 +41,7 @@ add_phasar_library(phasar_llvm_pathsensitivity LINK_PUBLIC nlohmann_json::nlohmann_json ${ADDITIONAL_LINK_LIBS} + + MODULE_FILES + PathSensitivity.cppm ) diff --git a/lib/PhasarLLVM/DataFlow/PathSensitivity/PathSensitivity.cppm b/lib/PhasarLLVM/DataFlow/PathSensitivity/PathSensitivity.cppm new file mode 100644 index 0000000000..39a683287e --- /dev/null +++ b/lib/PhasarLLVM/DataFlow/PathSensitivity/PathSensitivity.cppm @@ -0,0 +1,14 @@ +module; + +#include "phasar/PhasarLLVM/DataFlow/PathSensitivity/LLVMPathConstraints.h" +#include "phasar/PhasarLLVM/DataFlow/PathSensitivity/Z3BasedPathSensitivityConfig.h" +#include "phasar/PhasarLLVM/DataFlow/PathSensitivity/Z3BasedPathSensitvityManager.h" + +export module phasar.llvm.dataflow.pathsensitivity; + +export namespace psr { +using psr::LLVMPathConstraints; +using psr::Z3BasedPathSensitivityConfig; +using psr::Z3BasedPathSensitivityManager; +using psr::Z3BasedPathSensitivityManagerBase; +} // namespace psr diff --git a/lib/PhasarLLVM/Domain/CMakeLists.txt b/lib/PhasarLLVM/Domain/CMakeLists.txt new file mode 100644 index 0000000000..e7dd25cf52 --- /dev/null +++ b/lib/PhasarLLVM/Domain/CMakeLists.txt @@ -0,0 +1,8 @@ +file(GLOB_RECURSE PSR_LLVM_DOMAIN_SRC *.h *.cpp) + +add_phasar_library(phasar_llvm_domain + ${PSR_LLVM_DOMAIN_SRC} + + MODULE_FILES + Domain.cppm +) diff --git a/lib/PhasarLLVM/Domain/Domain.cppm b/lib/PhasarLLVM/Domain/Domain.cppm new file mode 100644 index 0000000000..251de12cdf --- /dev/null +++ b/lib/PhasarLLVM/Domain/Domain.cppm @@ -0,0 +1,11 @@ +module; + +#include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" + +export module phasar.llvm.domain; + +export namespace psr { +using psr::LLVMAnalysisDomainDefault; +using LLVMIFDSAnalysisDomainDefault = + WithBinaryValueDomain; +} // namespace psr diff --git a/lib/PhasarLLVM/Passes/CMakeLists.txt b/lib/PhasarLLVM/Passes/CMakeLists.txt index d7b8613ba4..6349833195 100644 --- a/lib/PhasarLLVM/Passes/CMakeLists.txt +++ b/lib/PhasarLLVM/Passes/CMakeLists.txt @@ -11,4 +11,7 @@ add_phasar_library(phasar_passes Support Analysis Demangle + + MODULE_FILES + Passes.cppm ) diff --git a/lib/PhasarLLVM/Passes/Passes.cppm b/lib/PhasarLLVM/Passes/Passes.cppm new file mode 100644 index 0000000000..5dba1c68bf --- /dev/null +++ b/lib/PhasarLLVM/Passes/Passes.cppm @@ -0,0 +1,15 @@ +module; + +#include "phasar/PhasarLLVM/Passes/ExampleModulePass.h" +#include "phasar/PhasarLLVM/Passes/GeneralStatisticsAnalysis.h" +#include "phasar/PhasarLLVM/Passes/ValueAnnotationPass.h" + +export module phasar.llvm.passes; + +export namespace psr { +using psr::ExampleModulePass; +using psr::GeneralStatistics; +using psr::GeneralStatisticsAnalysis; +using psr::ValueAnnotationPass; +using psr::operator<<; +} // namespace psr diff --git a/lib/PhasarLLVM/PhasarLLVM.cppm b/lib/PhasarLLVM/PhasarLLVM.cppm new file mode 100644 index 0000000000..20e7a71a94 --- /dev/null +++ b/lib/PhasarLLVM/PhasarLLVM.cppm @@ -0,0 +1,21 @@ +module; + +#include "phasar/PhasarLLVM/HelperAnalyses.h" +#include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" + +export module phasar.llvm; + +export import phasar.llvm.controlflow; +export import phasar.llvm.dataflow; +export import phasar.llvm.db; +export import phasar.llvm.domain; +export import phasar.llvm.passes; +export import phasar.llvm.pointer; +export import phasar.llvm.taintconfig; +export import phasar.llvm.typehierarchy; +export import phasar.llvm.utils; + +export namespace psr { +using psr::createAnalysisProblem; +using psr::HelperAnalyses; +} // namespace psr diff --git a/lib/PhasarLLVM/Pointer/CMakeLists.txt b/lib/PhasarLLVM/Pointer/CMakeLists.txt index 522fd55e5e..f863a86046 100644 --- a/lib/PhasarLLVM/Pointer/CMakeLists.txt +++ b/lib/PhasarLLVM/Pointer/CMakeLists.txt @@ -18,6 +18,9 @@ add_phasar_library(phasar_llvm_pointer LINK_PRIVATE ${Boost_LIBRARIES} + + MODULE_FILES + Pointer.cppm ) add_subdirectory(external) diff --git a/lib/PhasarLLVM/Pointer/Pointer.cppm b/lib/PhasarLLVM/Pointer/Pointer.cppm new file mode 100644 index 0000000000..d7c812df74 --- /dev/null +++ b/lib/PhasarLLVM/Pointer/Pointer.cppm @@ -0,0 +1,36 @@ +module; + +#include "phasar/Config/phasar-config.h" +#include "phasar/PhasarLLVM/Pointer/AliasAnalysisView.h" +#include "phasar/PhasarLLVM/Pointer/FilteredLLVMAliasSet.h" +#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" +#include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" +#include "phasar/PhasarLLVM/Pointer/LLVMAliasSetData.h" +#include "phasar/PhasarLLVM/Pointer/LLVMPointsToUtils.h" + +#ifdef PHASAR_USE_SVF +#include "phasar/PhasarLLVM/Pointer/SVF/SVFPointsToSet.h" +#endif + +export module phasar.llvm.pointer; + +export namespace psr { +using psr::AliasAnalysisView; +using psr::AliasInfoTraits; +using psr::FilteredLLVMAliasSet; +using psr::FunctionAliasView; +using psr::isInterestingPointer; +using psr::LLVMAliasInfo; +using psr::LLVMAliasInfoRef; +using psr::LLVMAliasSet; +using psr::LLVMAliasSetData; + +#ifdef PHASAR_USE_SVF +using psr::createSVFDDAPointsToInfo; +using psr::createSVFVFSPointsToInfo; +using psr::SVFBasedPointsToInfo; +using psr::SVFBasedPointsToInfoRef; +using psr::SVFPointsToInfoTraits; +#endif + +} // namespace psr diff --git a/lib/PhasarLLVM/TaintConfig/CMakeLists.txt b/lib/PhasarLLVM/TaintConfig/CMakeLists.txt index e3a9050f3e..09f24c3132 100644 --- a/lib/PhasarLLVM/TaintConfig/CMakeLists.txt +++ b/lib/PhasarLLVM/TaintConfig/CMakeLists.txt @@ -15,4 +15,7 @@ add_phasar_library(phasar_taintconfig LLVM_LINK_COMPONENTS Core Support + + MODULE_FILES + TaintConfig.cppm ) diff --git a/lib/PhasarLLVM/TaintConfig/TaintConfig.cppm b/lib/PhasarLLVM/TaintConfig/TaintConfig.cppm new file mode 100644 index 0000000000..0a57589687 --- /dev/null +++ b/lib/PhasarLLVM/TaintConfig/TaintConfig.cppm @@ -0,0 +1,23 @@ +module; + +#include "phasar/PhasarLLVM/TaintConfig/LLVMTaintConfig.h" +#include "phasar/PhasarLLVM/TaintConfig/TaintConfigBase.h" +#include "phasar/PhasarLLVM/TaintConfig/TaintConfigData.h" +#include "phasar/PhasarLLVM/TaintConfig/TaintConfigUtilities.h" + +export module phasar.llvm.taintconfig; + +export namespace psr { +using psr::collectGeneratedFacts; +using psr::collectLeakedFacts; +using psr::collectSanitizedFacts; +using psr::FunctionData; +using psr::LLVMTaintConfig; +using psr::parseTaintConfig; +using psr::parseTaintConfigOrNull; +using psr::TaintCategory; +using psr::TaintConfigBase; +using psr::TaintConfigData; +using psr::TaintConfigTraits; +using psr::VariableData; +} // namespace psr diff --git a/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt b/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt index d717d39f59..2f9d48f4b6 100644 --- a/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt +++ b/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt @@ -16,4 +16,7 @@ add_phasar_library(phasar_llvm_typehierarchy LINK_PRIVATE ${Boost_LIBRARIES} + + MODULE_FILES + TypeHierarchy.cppm ) diff --git a/lib/PhasarLLVM/TypeHierarchy/TypeHierarchy.cppm b/lib/PhasarLLVM/TypeHierarchy/TypeHierarchy.cppm new file mode 100644 index 0000000000..073668c6a3 --- /dev/null +++ b/lib/PhasarLLVM/TypeHierarchy/TypeHierarchy.cppm @@ -0,0 +1,19 @@ +module; + +#include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h" +#include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchyData.h" +#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" +#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.h" +#include "phasar/PhasarLLVM/TypeHierarchy/LLVMVFTable.h" +#include "phasar/PhasarLLVM/TypeHierarchy/LLVMVFTableData.h" + +export module phasar.llvm.typehierarchy; + +export namespace psr { +using psr::DIBasedTypeHierarchy; +using psr::DIBasedTypeHierarchyData; +using psr::LLVMProjectIRDB; +using psr::LLVMTypeHierarchyData; +using psr::LLVMVFTable; +using psr::LLVMVFTableData; +} // namespace psr diff --git a/lib/PhasarLLVM/Utils/CMakeLists.txt b/lib/PhasarLLVM/Utils/CMakeLists.txt index b88ee9d75b..e3def7c7f9 100644 --- a/lib/PhasarLLVM/Utils/CMakeLists.txt +++ b/lib/PhasarLLVM/Utils/CMakeLists.txt @@ -12,4 +12,7 @@ add_phasar_library(phasar_llvm_utils Support BitWriter Demangle + + MODULE_FILES + Utils.cppm ) diff --git a/lib/PhasarLLVM/Utils/Utils.cppm b/lib/PhasarLLVM/Utils/Utils.cppm new file mode 100644 index 0000000000..44043bc45d --- /dev/null +++ b/lib/PhasarLLVM/Utils/Utils.cppm @@ -0,0 +1,76 @@ +module; + +#include "phasar/PhasarLLVM/Utils/Annotation.h" +#include "phasar/PhasarLLVM/Utils/BasicBlockOrdering.h" +#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h" +#include "phasar/PhasarLLVM/Utils/LLVMBasedContainerConfig.h" +#include "phasar/PhasarLLVM/Utils/LLVMCXXShorthands.h" +#include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h" +#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" +#include "phasar/PhasarLLVM/Utils/LLVMSourceManager.h" +#include "phasar/PhasarLLVM/Utils/SourceMgrPrinter.h" + +export module phasar.llvm.utils; + +export namespace psr { +using psr::DataFlowAnalysisType; +using psr::DefaultDominatorTreeAnalysis; +using psr::GlobalAnnotation; +using psr::toDataFlowAnalysisType; +using psr::toString; +using psr::VarAnnotation; +using psr::operator<<; +using psr::appendAllExitPoints; +using psr::computeModuleHash; +using psr::DebugLocation; +using psr::dumpIRValue; +using psr::from_json; +using psr::getAllExitPoints; +using psr::getColumnFromIR; +using psr::getDebugLocation; +using psr::getDIFileFromIR; +using psr::getDILocalVariable; +using psr::getDILocation; +using psr::getDirectoryFromIR; +using psr::getFilePathFromIR; +using psr::getFunctionArgumentNr; +using psr::getFunctionNameFromIR; +using psr::getLastInstructionOf; +using psr::getLineAndColFromIR; +using psr::getLineFromIR; +using psr::getMetaDataID; +using psr::getModuleFromVal; +using psr::getModuleIDFromIR; +using psr::getModuleNameFromVal; +using psr::getModuleSlotTrackerFor; +using psr::getNthFunctionArgument; +using psr::getNthInstruction; +using psr::getNthStoreInstruction; +using psr::getNthTermInstruction; +using psr::getSrcCodeFromIR; +using psr::getSrcCodeInfoFromIR; +using psr::getVarAnnotationIntrinsicName; +using psr::getVarNameFromIR; +using psr::getVarTypeFromIR; +using psr::globalValuesUsedinFunction; +using psr::isAllocaInstOrHeapAllocaFunction; +using psr::isGuardVariable; +using psr::isHeapAllocatingFunction; +using psr::isIntegerLikeType; +using psr::isStaticVariableLazyInitializationBranch; +using psr::isTouchVTableInst; +using psr::isVarAnnotationIntrinsic; +using psr::llvmIRToShortString; +using psr::llvmIRToStableString; +using psr::llvmIRToString; +using psr::LLVMSourceManager; +using psr::llvmTypeToString; +using psr::LLVMValueIDLess; +using psr::ManagedDebugLocation; +using psr::matchesSignature; +using psr::ModulesToSlotTracker; +using psr::Ref2PointerConverter; +using psr::SourceCodeInfo; +using psr::SourceMgrPrinter; +using psr::to_json; +} // namespace psr diff --git a/lib/PhasarPass/CMakeLists.txt b/lib/PhasarPass/CMakeLists.txt index dd4dff3cb4..19e02c7084 100644 --- a/lib/PhasarPass/CMakeLists.txt +++ b/lib/PhasarPass/CMakeLists.txt @@ -11,7 +11,7 @@ add_phasar_library(phasar_pass phasar_llvm_controlflow phasar_llvm_db phasar_llvm_ifdside - phasar_mono + phasar_llvm_mono phasar_passes phasar_llvm_utils phasar_llvm_pointer @@ -25,4 +25,7 @@ add_phasar_library(phasar_pass LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} + + MODULE_FILES + PhasarPass.cppm ) diff --git a/lib/PhasarPass/PhasarPass.cppm b/lib/PhasarPass/PhasarPass.cppm new file mode 100644 index 0000000000..b4dfd79f81 --- /dev/null +++ b/lib/PhasarPass/PhasarPass.cppm @@ -0,0 +1,20 @@ +module; + +#include "phasar/PhasarPass/Options.h" +#include "phasar/PhasarPass/PhasarPass.h" +#include "phasar/PhasarPass/PhasarPrinterPass.h" + +export module phasar.phasarpass; + +export namespace psr { +using psr::CallGraphAnalysis; +using psr::DataFlowAnalysis; +using psr::DumpResults; +using psr::EntryPoints; +using psr::InitLogger; +using psr::PammOutputFile; +using psr::PhasarPass; +using psr::PhasarPrinterPass; +using psr::PointerAnalysis; +using psr::PrintEdgeRecorder; +} // namespace psr diff --git a/lib/Pointer/CMakeLists.txt b/lib/Pointer/CMakeLists.txt index 4695aeb0ae..66b1d2710f 100644 --- a/lib/Pointer/CMakeLists.txt +++ b/lib/Pointer/CMakeLists.txt @@ -9,4 +9,7 @@ add_phasar_library(phasar_pointer LLVM_LINK_COMPONENTS Support + + MODULE_FILES + PhasarPointer.cppm ) diff --git a/lib/Pointer/PhasarPointer.cppm b/lib/Pointer/PhasarPointer.cppm new file mode 100644 index 0000000000..21e84a075a --- /dev/null +++ b/lib/Pointer/PhasarPointer.cppm @@ -0,0 +1,38 @@ +module; + +#include "phasar/Pointer/AliasAnalysisType.h" +#include "phasar/Pointer/AliasInfo.h" +#include "phasar/Pointer/AliasInfoBase.h" +#include "phasar/Pointer/AliasInfoTraits.h" +#include "phasar/Pointer/AliasResult.h" +#include "phasar/Pointer/AliasSetOwner.h" +#include "phasar/Pointer/PointsToInfo.h" + +export module phasar.pointer; + +export namespace psr { +using psr::AliasAnalysisType; +using psr::toAliasAnalysisType; +using psr::toString; +using psr::operator<<; +using psr::AliasAnalysisType; +using psr::AliasInfo; +using psr::AliasInfoBaseUtils; +using psr::AliasInfoRef; +using psr::AliasInfoTraits; +using psr::AliasResult; +using psr::AnalysisProperties; +using psr::DefaultAATraits; +using psr::IsAliasInfo; +using psr::toAliasResult; +using psr::toString; +using psr::operator<<; +using psr::AliasSetOwner; +using psr::is_equivalent_PointsToTraits_v; +using psr::is_PointsToTraits; +using psr::is_PointsToTraits_v; +using psr::PointsToInfo; +using psr::PointsToInfoBase; +using psr::PointsToInfoRef; +using psr::PointsToTraits; +} // namespace psr diff --git a/lib/TypeHierarchy/CMakeLists.txt b/lib/TypeHierarchy/CMakeLists.txt new file mode 100644 index 0000000000..734cb7c9d7 --- /dev/null +++ b/lib/TypeHierarchy/CMakeLists.txt @@ -0,0 +1,9 @@ +file(GLOB_RECURSE TYPEHIERARCHY *.h *.cpp) + +# Handle the library files +add_phasar_library(phasar_typehierarchy + ${TYPEHIERARCHY} + + MODULE_FILES + TypeHierarchy.cppm +) diff --git a/lib/TypeHierarchy/TypeHierarchy.cppm b/lib/TypeHierarchy/TypeHierarchy.cppm new file mode 100644 index 0000000000..a7bcbd7ccd --- /dev/null +++ b/lib/TypeHierarchy/TypeHierarchy.cppm @@ -0,0 +1,12 @@ +module; + +#include "phasar/TypeHierarchy/TypeHierarchy.h" +#include "phasar/TypeHierarchy/VFTable.h" + +export module phasar.typehierarchy; + +export namespace psr { +using psr::TypeHierarchy; +using psr::operator<<; +using psr::VFTable; +} // namespace psr diff --git a/lib/Utils/CMakeLists.txt b/lib/Utils/CMakeLists.txt index c105696638..2bee013212 100644 --- a/lib/Utils/CMakeLists.txt +++ b/lib/Utils/CMakeLists.txt @@ -19,6 +19,9 @@ add_phasar_library(phasar_utils ${PHASAR_STD_FILESYSTEM} LINK_PUBLIC nlohmann_json::nlohmann_json + + MODULE_FILES + Utils.cppm ) set_target_properties(phasar_utils diff --git a/lib/Utils/Utils.cppm b/lib/Utils/Utils.cppm new file mode 100644 index 0000000000..9440d6c5dd --- /dev/null +++ b/lib/Utils/Utils.cppm @@ -0,0 +1,199 @@ +module; + +#include "phasar/Utils/AdjacencyList.h" +#include "phasar/Utils/AnalysisPrinterBase.h" +#include "phasar/Utils/AnalysisProperties.h" +#include "phasar/Utils/Average.h" +#include "phasar/Utils/BitVectorSet.h" +#include "phasar/Utils/BoxedPointer.h" +#include "phasar/Utils/ByRef.h" +#include "phasar/Utils/ChronoUtils.h" +#include "phasar/Utils/DFAMinimizer.h" +#include "phasar/Utils/DOTGraph.h" +#include "phasar/Utils/DebugOutput.h" +#include "phasar/Utils/DefaultAnalysisPrinter.h" +#include "phasar/Utils/DefaultValue.h" +#include "phasar/Utils/EmptyBaseOptimizationUtils.h" +#include "phasar/Utils/EnumFlags.h" +#include "phasar/Utils/EquivalenceClassMap.h" +#include "phasar/Utils/ErrorHandling.h" +#include "phasar/Utils/GraphTraits.h" +#include "phasar/Utils/IO.h" +#include "phasar/Utils/InitPhasar.h" +#include "phasar/Utils/IotaIterator.h" +#include "phasar/Utils/JoinLattice.h" +#include "phasar/Utils/Macros.h" +#include "phasar/Utils/MaybeUniquePtr.h" +#include "phasar/Utils/NullAnalysisPrinter.h" +#include "phasar/Utils/Nullable.h" +#include "phasar/Utils/OnTheFlyAnalysisPrinter.h" +#include "phasar/Utils/PAMM.h" +#include "phasar/Utils/PAMMMacros.h" +#include "phasar/Utils/PointerUtils.h" +#include "phasar/Utils/Printer.h" +#include "phasar/Utils/RepeatIterator.h" +#include "phasar/Utils/SemiRing.h" +#include "phasar/Utils/Soundness.h" +#include "phasar/Utils/StableVector.h" +#include "phasar/Utils/Table.h" +#include "phasar/Utils/TableWrappers.h" +#include "phasar/Utils/Timer.h" +#include "phasar/Utils/TypeTraits.h" +#include "phasar/Utils/Utilities.h" + +export module phasar.utils; + +export namespace psr { +using psr::AdjacencyList; +using psr::AnalysisPrinterBase; +using psr::AnalysisProperties; +using psr::GraphTraits; +using psr::to_string; +using psr::operator<<; +using psr::AnalysisPropertiesMixin; +using psr::BitVectorSet; +using psr::BoxedConstPtr; +using psr::BoxedPtr; +using psr::CanEfficientlyPassByValue; +using psr::hms; +using psr::intersectWith; +using psr::PrettyPrinter; +using psr::Sampler; +using psr::operator<<; +using psr::createEquivalentGraphFrom; +using psr::DefaultAnalysisPrinter; +using psr::DOTConfig; +using psr::DOTEdge; +using psr::DOTNode; +using psr::getDefaultValue; +using psr::minimizeGraph; +using psr::Warning; +using psr::operator<; +using psr::operator==; +using psr::DOTFactSubGraph; +using psr::DOTFunctionSubGraph; +using psr::DOTGraph; +using psr::DummyPair; +using psr::EmptyType; +using psr::EnumFlagAutoBool; +using psr::operator&=; +using psr::operator|; +using psr::operator|=; +using psr::operator^; +using psr::operator^=; +using psr::operator~; +using psr::DefaultNodeTransform; +using psr::EquivalenceClassMap; +using psr::EquivalenceClassMapNG; +using psr::getOrEmpty; +using psr::getOrNull; +using psr::getOrThrow; +using psr::GraphTraits; +using psr::hasFlag; +using psr::InitPhasar; +using psr::iota; +using psr::IotaIterator; +using psr::is_graph; +using psr::is_graph_edge; +using psr::is_graph_trait; +using psr::is_removable_graph_trait_v; +using psr::is_reservable_graph_trait_v; +using psr::JoinLattice; +using psr::JoinLatticeTraits; +using psr::Logger; +using psr::mapValue; +using psr::MaybeUniquePtr; +using psr::NonTopBotValue; +using psr::openFileStream; +using psr::parseSeverityLevel; +using psr::printGraph; +using psr::readFile; +using psr::readFileOrErr; +using psr::readFileOrNull; +using psr::readJsonFile; +using psr::readTextFile; +using psr::readTextFileOrErr; +using psr::readTextFileOrNull; +using psr::reverseGraph; +using psr::setFlag; +using psr::SeverityLevel; +using psr::to_string; +using psr::unsetFlag; +using psr::writeTextFile; +using psr::operator<<; +using psr::DToString; +using psr::FToString; +using psr::getPointerFrom; +using psr::LToString; +using psr::NToString; +using psr::NullAnalysisPrinter; +using psr::OnTheFlyAnalysisPrinter; +using psr::PAMM; +using psr::PAMM_SEVERITY_LEVEL; +using psr::repeat; +using psr::RepeatIterator; +using psr::SemiRing; +using psr::Soundness; +using psr::toSoundness; +using psr::toString; +using psr::unwrapNullable; +using psr::operator<<; +using psr::adl_to_string; +using psr::AreEqualityComparable; +using psr::assertAllNotNull; +using psr::assertNotNull; +using psr::computePowerSet; +using psr::createTimeStamp; +using psr::DefaultConstruct; +using psr::DenseSet; +using psr::DenseTable1d; +using psr::DummyDenseTable1d; +using psr::DummyUnorderedTable1d; +using psr::ElementType; +using psr::FalseFn; +using psr::forward_like; +using psr::has_adl_to_string_v; +using psr::has_erase_iterator_v; +using psr::has_getAsJson; +using psr::has_getHashCode; +using psr::has_isInteresting_v; +using psr::has_llvm_dense_map_info; +using psr::has_std_hash; +using psr::has_str_v; +using psr::HasDepth; +using psr::HasIsConstant; +using psr::identity; +using psr::IdentityFn; +using psr::IgnoreArgs; +using psr::intersectWith; +using psr::is_crtp_base_of_v; +using psr::is_iterable_over_v; +using psr::is_iterable_v; +using psr::is_llvm_hashable_v; +using psr::is_llvm_printable_v; +using psr::is_pair_v; +using psr::is_printable_v; +using psr::is_std_hashable_v; +using psr::is_std_printable_v; +using psr::is_string_like_v; +using psr::is_tuple_v; +using psr::is_variant; +using psr::is_variant_v; +using psr::isConstructor; +using psr::IsEqualityComparable; +using psr::isMangled; +using psr::Overloaded; +using psr::remove_by_index; +using psr::reserveIfPossible; +using psr::scope_exit; +using psr::SmallDenseTable1d; +using psr::StableVector; +using psr::StringIDLess; +using psr::Table; +using psr::Timer; +using psr::TrueFn; +using psr::UnorderedSet; +using psr::UnorderedTable1d; +using psr::variant_idx; +// using psr::variant_idx; +} // namespace psr diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 64a97d80a7..a1b50268ee 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,2 +1,5 @@ add_subdirectory(example-tool) add_subdirectory(phasar-cli) +if (PHASAR_BUILD_MODULES) + add_subdirectory(hello-modules-tool) +endif() diff --git a/tools/hello-modules-tool/CMakeLists.txt b/tools/hello-modules-tool/CMakeLists.txt new file mode 100644 index 0000000000..f38f50030e --- /dev/null +++ b/tools/hello-modules-tool/CMakeLists.txt @@ -0,0 +1,18 @@ +# Build a stand-alone executable +if(PHASAR_IN_TREE) + # Build a small test tool to show how phasar may be used + add_phasar_executable(hello-modules + hello_modules.cpp + ) +else() + # Build a small test tool to show how phasar may be used + add_executable(hello-modules + hello_modules.cpp + ) +endif() + +target_link_libraries(hello-modules + PRIVATE + phasar + ${PHASAR_STD_FILESYSTEM} +) diff --git a/tools/hello-modules-tool/hello_modules.cpp b/tools/hello-modules-tool/hello_modules.cpp new file mode 100644 index 0000000000..edccb798f0 --- /dev/null +++ b/tools/hello-modules-tool/hello_modules.cpp @@ -0,0 +1,65 @@ +#include "llvm/Support/raw_ostream.h" + +#include +#include +#include + +import phasar.analysisstrategy; +import phasar.config; +import phasar.controlflow; +import phasar.dataflow; +import phasar.db; +import phasar.domain; +import phasar.llvm; +import phasar.phasarpass; +import phasar.pointer; +import phasar.typehierarchy; +import phasar.utils; + +using namespace psr; + +int main(int Argc, const char **Argv) { + using namespace std::string_literals; + + if (Argc < 2 || !std::filesystem::exists(Argv[1]) || + std::filesystem::is_directory(Argv[1])) { + llvm::errs() << "myphasartool\n" + "A small PhASAR-based example program\n\n" + "Usage: myphasartool \n"; + return 1; + } + + std::vector EntryPoints = {"main"s}; + + HelperAnalyses HA(Argv[1], EntryPoints); + if (!HA.getProjectIRDB().isValid()) { + return 1; + } + + if (const auto *F = HA.getProjectIRDB().getFunctionDefinition("main")) { + // print type hierarchy + HA.getTypeHierarchy().print(); + // print points-to information + HA.getAliasInfo().print(); + // print inter-procedural control-flow graph + HA.getICFG().print(); + + // IFDS template parametrization test + llvm::outs() << "Testing IFDS:\n"; + auto L = createAnalysisProblem(HA, EntryPoints); + IFDSSolver S(L, &HA.getICFG()); + auto IFDSResults = S.solve(); + IFDSResults.dumpResults(HA.getICFG()); + + // IDE template parametrization test + llvm::outs() << "Testing IDE:\n"; + auto M = createAnalysisProblem(HA, EntryPoints); + // Alternative way of solving an IFDS/IDEProblem: + auto IDEResults = solveIDEProblem(M, HA.getICFG()); + IDEResults.dumpResults(HA.getICFG()); + + } else { + llvm::errs() << "error: file does not contain a 'main' function!\n"; + } + return 0; +}