From d9442898ffecb24b653123f656e9c7e3278ae061 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Tue, 28 Oct 2025 18:41:15 +0100 Subject: [PATCH 1/4] Remove various deprecated APIs --- BreakingChanges.md | 9 +- include/phasar/DB.h | 5 - include/phasar/DB/Hexastore.h | 136 ------ include/phasar/DB/Queries.h | 49 -- include/phasar/DataFlow.h | 1 - .../DataFlow/IfdsIde/SpecialSummaries.h | 130 ------ .../ControlFlow/Resolver/CHAResolver.h | 4 +- .../ControlFlow/Resolver/Resolver.h | 12 - .../phasar/PhasarLLVM/DB/LLVMProjectIRDB.h | 11 - .../Problems/IDEExtendedTaintAnalysis.h | 1 - .../Problems/IDELinearConstantAnalysis.h | 1 - .../Problems/IDESecureHeapPropagation.h | 2 - .../IfdsIde/Problems/IFDSConstAnalysis.h | 1 - .../CSTDFILEIOTypeStateDescription.h | 1 - .../OpenSSLEVPKDFCTXDescription.h | 1 - .../OpenSSLEVPKDFDescription.h | 2 - .../OpenSSLSecureHeapDescription.h | 1 - .../OpenSSLSecureMemoryDescription.h | 1 - .../TypeStateDescription.h | 6 - include/phasar/PhasarLLVM/TypeHierarchy.h | 1 - .../TypeHierarchy/DIBasedTypeHierarchy.h | 5 - .../TypeHierarchy/LLVMTypeHierarchy.h | 220 --------- .../TypeHierarchy/LLVMTypeHierarchyData.h | 33 -- lib/DB/DB.cppm | 21 - lib/DB/Hexastore.cpp | 113 ----- lib/DB/Queries.cpp | 302 ------------- .../ControlFlow/LLVMVFTableProvider.cpp | 7 +- .../ControlFlow/Resolver/CHAResolver.cpp | 1 - .../ControlFlow/Resolver/Resolver.cpp | 6 - lib/PhasarLLVM/DB/LLVMProjectIRDB.cpp | 23 - .../Problems/IDEExtendedTaintAnalysis.cpp | 1 - .../Problems/IDELinearConstantAnalysis.cpp | 1 - .../IfdsIde/Problems/IDESolverTest.cpp | 1 - .../IfdsIde/Problems/IFDSTypeAnalysis.cpp | 1 - .../CSTDFILEIOTypeStateDescription.cpp | 4 - .../OpenSSLEVPKDFCTXDescription.cpp | 4 - .../OpenSSLEVPKDFDescription.cpp | 4 - .../OpenSSLSecureHeapDescription.cpp | 5 - .../OpenSSLSecureMemoryDescription.cpp | 4 - .../TypeHierarchy/DIBasedTypeHierarchy.cpp | 19 - .../TypeHierarchy/LLVMTypeHierarchy.cpp | 419 ----------------- .../TypeHierarchy/LLVMTypeHierarchyData.cpp | 65 --- .../TypeHierarchy/TypeHierarchy.cppm | 4 - .../ControlFlow/LLVMBasedBackwardICFGTest.cpp | 1 - .../ControlFlow/LLVMBasedICFG_OTFTest.cpp | 1 - .../IDEInstInteractionAnalysisTest.cpp | 1 - .../IDELinearConstantAnalysisSwiftTest.cpp | 1 - .../IDELinearConstantAnalysisTest.cpp | 1 - .../Problems/IDETSAnalysisFileIOTest.cpp | 1 - .../IDETSAnalysisOpenSSLEVPKDFTest.cpp | 1 - .../IDETSAnalysisOpenSSLSecureHeapTest.cpp | 1 - .../IDETSAnalysisOpenSSLSecureMemoryTest.cpp | 1 - .../Problems/IFDSConstAnalysisTest.cpp | 1 - .../Problems/IFDSTaintAnalysisTest.cpp | 1 - .../DataFlow/IfdsIde/SparseIDESolverTest.cpp | 1 - .../InterMonoFullConstantPropagationTest.cpp | 1 - .../Mono/InterMonoTaintAnalysisTest.cpp | 1 - .../IntraMonoFullConstantPropagationTest.cpp | 1 - .../Mono/IntraMonoUninitVariablesTest.cpp | 1 - .../PhasarLLVM/TypeHierarchy/CMakeLists.txt | 2 - .../LLVMTypeHierarchySerializationTest.cpp | 96 ---- .../TypeHierarchy/LLVMTypeHierarchyTest.cpp | 421 ------------------ 62 files changed, 16 insertions(+), 2157 deletions(-) delete mode 100644 include/phasar/DB/Hexastore.h delete mode 100644 include/phasar/DB/Queries.h delete mode 100644 include/phasar/DataFlow/IfdsIde/SpecialSummaries.h delete mode 100644 include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h delete mode 100644 include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.h delete mode 100644 lib/DB/Hexastore.cpp delete mode 100644 lib/DB/Queries.cpp delete mode 100644 lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.cpp delete mode 100644 lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.cpp delete mode 100644 unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchySerializationTest.cpp delete mode 100644 unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyTest.cpp diff --git a/BreakingChanges.md b/BreakingChanges.md index af467cf67f..385ef3f33d 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -2,7 +2,14 @@ ## development HEAD -*None* +- Removed `SpecialSummaries`. +- Removed `Hexastore` and the corresponding database queries. +- Removed `LLVMTypeHierarchy` (and `LLVMTypeHierarchyData`), which is superceeded by `DIBasedTypeHierarchy`. +- Removed `Resolver::preCall()`, `Resolver::postCall()`, and `Resolver::otherInst()`. +- Removed `TypestateDescription::start()`. Instead apply `TypestateDescription::getNextState()` on `TypestateDescription::uninit()`. +- Removed `LLVMProjectIRDB::getParsedIRModuleOrNull()`. Use `LLVMProjectIRDB::getParsedIRModuleOrErr()` instead. +- Removed `DIBasedTypeHierarchy::isVTable()` and `DIBasedTypeHierarchy::removeVTablePrefix()`. Use the corresponding functions from `LLVMVFTableProvider` instead. + ## v2510 diff --git a/include/phasar/DB.h b/include/phasar/DB.h index 4ddd16a5e0..a9f84201e7 100644 --- a/include/phasar/DB.h +++ b/include/phasar/DB.h @@ -13,9 +13,4 @@ #include "phasar/Config/phasar-config.h" #include "phasar/DB/ProjectIRDBBase.h" -#ifdef PHASAR_HAS_SQLITE -#include "phasar/DB/Hexastore.h" -#include "phasar/DB/Queries.h" -#endif - #endif // PHASAR_DB_H diff --git a/include/phasar/DB/Hexastore.h b/include/phasar/DB/Hexastore.h deleted file mode 100644 index 64ade62375..0000000000 --- a/include/phasar/DB/Hexastore.h +++ /dev/null @@ -1,136 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Philipp Schubert. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Christian Stritzke, Philipp Schubert and others - *****************************************************************************/ - -#ifndef PHASAR_DB_HEXASTORE_H_ -#define PHASAR_DB_HEXASTORE_H_ - -#include "phasar/Config/phasar-config.h" -#ifndef PHASAR_HAS_SQLITE -#error \ - "Hexastore requires SQLite3. Please install libsqlite3-dev and reconfigure PhASAR." -#endif - -#include "llvm/Support/raw_ostream.h" - -#include -#include -#include - -struct sqlite3; - -namespace psr { -/** - * @brief Holds the results of a query to the Hexastore. - */ -struct HSResult { - /// Used for the source node. - std::string Subject; - /// Used for the edge. - std::string Predicate; - /// Used for the destination node. - std::string Object; - HSResult() = default; - HSResult(const std::string Subject, // NOLINT - std::string Predicate, // NOLINT - std::string Object) // NOLINT - : Subject(Subject), Predicate(std::move(Predicate)), - Object(std::move(Object)) {} - /// Prints an entry of the results to the command-line - friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, - const HSResult &Result) { - return OS << "[ subject: " << Result.Subject - << " | predicate: " << Result.Predicate - << " | object: " << Result.Object << " ]"; - } - - friend bool operator==(const HSResult &LHS, const HSResult &RHS) { - return LHS.Subject == RHS.Subject && LHS.Predicate == RHS.Predicate && - LHS.Object == RHS.Object; - } -}; - -/** - * A Hexastore is an efficient approach to store large graphs. - * This approach is based on the paper "Database-Backed Program Analysis - * for Scalable Error Propagation" by Weiss, Rubio-González and Libit. - * - * To store a graph into a database, we represent the graph by a set of - * string 3-tuples by the form: - * - * (source node, edge, destination node) - * - * A Hexastore indexes and saves graphs six-fold, according to each of - * the permutations of source, edge and destination label. For example, - * this allows to quickly find all edges for a given source node with one - * look-up. In general, given one or two fixed elements of a (source, edge, - * destination) tuple, Hexastore can quickly access the related information. - * - * @brief Efficient data structure for holding graphs in databases. - */ -class [[deprecated("This ancient API is not maintained for long and should not " - "be used anymore!")]] Hexastore { -private: - sqlite3 *HSInternalDB{}; - static int callback(void * /*NotUsed*/, int Argc, char **Argv, - char **AzColName); - void doPut(const std::string &Query, std::array Edge); - -public: - /** - * If the given filename matches an already created Hexastore, no - * new Hexastore will be created. Instead the already created Hexastore - * will be used. - * - * @brief Constructs a Hexastore under the given filename. - * @param filename Filename of the Hexastore. - */ - Hexastore(const std::string &FileName); - Hexastore(const Hexastore &) = delete; - Hexastore &operator=(const Hexastore &) = delete; - - /** - * Destructor. - */ - ~Hexastore(); - - /** - * Adds the given tuple as a new entry to the Hexastore. It is not - * possible to have duplicate entries in the Hexastore and - * duplicate put queries will be silently ignored by the Hexastore. - * - * @brief Creates a new entry in the Hexastore. - * @note To mitigate certain compiler warnings, it is advised to use - * double braces, e.g.: - * hexastore.put({{"subject", "predicate", "object"}}); - * @param edge New entry in the form of a 3-tuple. - */ - void put(const std::array &Edge); - - /** - * A query is always in the form of a 3-tuple (source, edge, destination) - * where - * none/one/two or all three elements of the tuple are given, while the not - * fixed - * elements are represented by a "?". E.g. to query all destination nodes - * for a certain source node and edge, the following query is used: - * - * ("node_19", "edge_3", "?") - * - * @brief Query information from the Hexastore. - * @param edge_query Query in the form of a 3-tuple. - * @param result_size_hint Used for possible optimization. - * @return An object of hs_result, holding the queried information. - */ - std::vector get(std::array EdgeQuery, - size_t ResultSizeHint = 0); -}; - -} // namespace psr - -#endif diff --git a/include/phasar/DB/Queries.h b/include/phasar/DB/Queries.h deleted file mode 100644 index 710e640db1..0000000000 --- a/include/phasar/DB/Queries.h +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Philipp Schubert. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Christian Stritzke and others - *****************************************************************************/ - -#ifndef PHASAR_DB_QUERIES_H_ -#define PHASAR_DB_QUERIES_H_ - -#include - -namespace psr { - -extern const std::string SPOInsert; - -extern const std::string SOPInsert; - -extern const std::string PSOInsert; - -extern const std::string POSInsert; - -extern const std::string OSPInsert; - -extern const std::string OPSInsert; - -extern const std::string SearchSPO; - -extern const std::string SearchSPX; - -extern const std::string SearchSXO; - -extern const std::string SearchXPO; - -extern const std::string SearchSXX; - -extern const std::string SearchXPX; - -extern const std::string SearchXXO; - -extern const std::string SearchXXX; - -extern const std::string INIT; - -} // namespace psr - -#endif diff --git a/include/phasar/DataFlow.h b/include/phasar/DataFlow.h index 88453a251d..5cd7522f42 100644 --- a/include/phasar/DataFlow.h +++ b/include/phasar/DataFlow.h @@ -27,7 +27,6 @@ #include "phasar/DataFlow/IfdsIde/Solver/PathAwareIDESolver.h" #include "phasar/DataFlow/IfdsIde/Solver/PathEdge.h" #include "phasar/DataFlow/IfdsIde/SolverResults.h" -#include "phasar/DataFlow/IfdsIde/SpecialSummaries.h" #include "phasar/DataFlow/Mono/Contexts/CallStringCTX.h" #include "phasar/DataFlow/Mono/InterMonoProblem.h" #include "phasar/DataFlow/Mono/IntraMonoProblem.h" diff --git a/include/phasar/DataFlow/IfdsIde/SpecialSummaries.h b/include/phasar/DataFlow/IfdsIde/SpecialSummaries.h deleted file mode 100644 index f7cbd0cfc6..0000000000 --- a/include/phasar/DataFlow/IfdsIde/SpecialSummaries.h +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Philipp Schubert. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Philipp Schubert and others - *****************************************************************************/ - -/* - * SpecialSummaries.h - * - * Created on: 05.05.2017 - * Author: philipp - */ - -#ifndef PHASAR_DATAFLOW_IFDSIDE_SPECIALSUMMARIES_H -#define PHASAR_DATAFLOW_IFDSIDE_SPECIALSUMMARIES_H - -#include "phasar/Config/Configuration.h" -#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h" -#include "phasar/DataFlow/IfdsIde/EdgeFunctions.h" -#include "phasar/DataFlow/IfdsIde/FlowFunctions.h" -#include "phasar/Domain/BinaryDomain.h" -#include "phasar/Utils/IO.h" // readFile - -#include "llvm/IR/Function.h" - -#include -#include -#include -#include -#include - -namespace psr { - -template -class [[deprecated("This ancient API is not maintained and should not be used " - "anymore")]] SpecialSummaries { - using FlowFunctionType = FlowFunction; - using FlowFunctionPtrType = std::shared_ptr>; - -private: - std::map SpecialFlowFunctions; - std::map> SpecialEdgeFunctions; - std::vector SpecialFunctionNames; - - /// Constructs the SpecialSummaryMap such that it contains all glibc, - /// llvm.intrinsics and C++'s new, new[], delete, delete[] with identity - /// flow functions. - SpecialSummaries() { - // insert default flow and edge functions - for (const auto &FunctionName : - PhasarConfig::getPhasarConfig().specialFunctionNames()) { - // SpecialFlowFunctions.insert( - // std::make_pair(FunctionName, Identity::getInstance())); - SpecialEdgeFunctions.insert( - std::make_pair(FunctionName, EdgeIdentity{})); - } - } - -public: - SpecialSummaries(const SpecialSummaries &) = delete; - SpecialSummaries &operator=(const SpecialSummaries &) = delete; - SpecialSummaries(SpecialSummaries &&) = delete; - SpecialSummaries &operator=(SpecialSummaries &&) = delete; - ~SpecialSummaries() = default; - - static SpecialSummaries &getInstance() { - static SpecialSummaries Instance; - return Instance; - } - - /// Returns true, when an existing function is overwritten, false otherwise. - bool provideSpecialSummary(const std::string &Name, - FlowFunctionPtrType FlowFunc) { - bool Override = containsSpecialSummary(Name); - SpecialFlowFunctions[Name] = FlowFunc; - return Override; - } - - /// Returns true, when an existing function is overwritten, false otherwise. - bool provideSpecialSummary(const std::string &Name, - FlowFunctionPtrType FlowFunc, - std::shared_ptr> EdgeFunc) { - bool Override = containsSpecialSummary(Name); - SpecialFlowFunctions[Name] = FlowFunc; - SpecialEdgeFunctions[Name] = EdgeFunc; - return Override; - } - - bool containsSpecialSummary(const llvm::Function *Func) { - return containsSpecialSummary(Func->getName()); - } - - bool containsSpecialSummary(const std::string &Name) { - return SpecialFlowFunctions.count(Name); - } - - FlowFunctionPtrType - getSpecialFlowFunctionSummary(const llvm::Function *Func) { - return getSpecialFlowFunctionSummary(Func->getName()); - } - - FlowFunctionPtrType getSpecialFlowFunctionSummary(const std::string &Name) { - return SpecialFlowFunctions[Name]; - } - - std::shared_ptr> - getSpecialEdgeFunctionSummary(const llvm::Function *Func) { - return getSpecialEdgeFunctionSummary(Func->getName()); - } - - std::shared_ptr> - getSpecialEdgeFunctionSummary(const std::string &Name) { - return SpecialEdgeFunctions[Name]; - } - - friend llvm::raw_ostream & - operator<<(llvm::raw_ostream &OS, const SpecialSummaries &SpecialSumms) { - OS << "SpecialSummaries:\n"; - for (auto &Entry : SpecialSumms.SpecialFunctionNames) { - OS << Entry.first << " "; - } - return OS; - } -}; -} // namespace psr - -#endif diff --git a/include/phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h b/include/phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h index f4b73965cb..728d521f78 100644 --- a/include/phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h +++ b/include/phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h @@ -30,8 +30,8 @@ class CHAResolver : public Resolver { CHAResolver(const LLVMProjectIRDB *IRDB, const LLVMVFTableProvider *VTP, const DIBasedTypeHierarchy *TH); - // Deleting an incomplete type (LLVMTypeHierarchy) is UB, so instantiate the - // dtor in CHAResolver.cpp + // Deleting an incomplete type (DIBasedTypeHierarchy) is UB, so instantiate + // the dtor in CHAResolver.cpp ~CHAResolver() override; void resolveVirtualCall(FunctionSetTy &PossibleTargets, diff --git a/include/phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h b/include/phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h index cc1e31100a..938418b62d 100644 --- a/include/phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h +++ b/include/phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h @@ -89,24 +89,12 @@ class Resolver { virtual ~Resolver() = default; - [[deprecated("With the removal of DTAResolver, this is not used " - "anymore")]] virtual void - preCall(const llvm::Instruction *Inst); - virtual void handlePossibleTargets(const llvm::CallBase *CallSite, FunctionSetTy &PossibleTargets); - [[deprecated("With the removal of DTAResolver, this is not used " - "anymore")]] virtual void - postCall(const llvm::Instruction *Inst); - [[nodiscard]] FunctionSetTy resolveIndirectCall(const llvm::CallBase *CallSite); - [[deprecated("With the removal of DTAResolver, this is not used " - "anymore")]] virtual void - otherInst(const llvm::Instruction *Inst); - [[nodiscard]] virtual std::string str() const = 0; /// Whether the ICFG needs to reconsider all dynamic call-sites once there diff --git a/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h b/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h index 03b6c03ea8..9dc7b67a52 100644 --- a/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h +++ b/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h @@ -12,7 +12,6 @@ #include "phasar/DB/ProjectIRDBBase.h" #include "phasar/PhasarLLVM/Utils/LLVMBasedContainerConfig.h" -#include "phasar/Utils/Macros.h" #include "phasar/Utils/MaybeUniquePtr.h" #include "llvm/ADT/ArrayRef.h" @@ -80,16 +79,6 @@ class LLVMProjectIRDB : public ProjectIRDBBase { ~LLVMProjectIRDB(); - [[nodiscard]] PSR_DEPRECATED("Deprecated in favor of getParsedIRModuleOrErr", - "getParsedIRModuleOrErr") static std:: - unique_ptr getParsedIRModuleOrNull( - const llvm::Twine &IRFileName, llvm::LLVMContext &Ctx) noexcept; - - [[nodiscard]] PSR_DEPRECATED("Deprecated in favor of getParsedIRModuleOrErr", - "getParsedIRModuleOrErr") static std:: - unique_ptr getParsedIRModuleOrNull( - llvm::MemoryBufferRef IRFileContent, llvm::LLVMContext &Ctx) noexcept; - [[nodiscard]] static llvm::ErrorOr> getParsedIRModuleOrErr(const llvm::Twine &IRFileName, llvm::LLVMContext &Ctx) noexcept; diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h index fa1efd880b..f006c9d54a 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h @@ -22,7 +22,6 @@ #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" #include "phasar/PhasarLLVM/TaintConfig/LLVMTaintConfig.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/BasicBlockOrdering.h" #include "llvm/ADT/STLExtras.h" diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h index 725c60fcc2..30c8ed8b58 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h @@ -36,7 +36,6 @@ struct IDELinearConstantAnalysisDomain : public LLVMAnalysisDomainDefault { }; class LLVMBasedICFG; -class LLVMTypeHierarchy; // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class IDELinearConstantAnalysis diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h index 1780d2d790..2141946dd7 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h @@ -61,8 +61,6 @@ class IDESecureHeapPropagation IDESecureHeapPropagation(const LLVMProjectIRDB *IRDB, std::vector EntryPoints = {"main"}); - ~IDESecureHeapPropagation() override = default; - FlowFunctionPtrType getNormalFlowFunction(n_t Curr, n_t Succ) override; FlowFunctionPtrType getCallFlowFunction(n_t CallSite, f_t DestFunc) override; diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h index 7dd0d7c5df..73f9355ce6 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h @@ -31,7 +31,6 @@ class Value; namespace psr { class LLVMBasedICFG; -class LLVMTypeHierarchy; /** * This IFDS analysis will compute possibly mutable memory diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.h index d5a9b4f869..66295c452c 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.h @@ -77,7 +77,6 @@ class CSTDFILEIOTypeStateDescription [[nodiscard]] TypeStateDescription::State bottom() const override; [[nodiscard]] TypeStateDescription::State top() const override; [[nodiscard]] TypeStateDescription::State uninit() const override; - [[nodiscard]] TypeStateDescription::State start() const override; [[nodiscard]] TypeStateDescription::State error() const override; [[nodiscard]] DataFlowAnalysisType analysisType() const override; }; diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.h index 144d3571c4..937cc68714 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.h @@ -100,7 +100,6 @@ class OpenSSLEVPKDFCTXDescription [[nodiscard]] State bottom() const override; [[nodiscard]] State top() const override; [[nodiscard]] State uninit() const override; - [[nodiscard]] State start() const override; [[nodiscard]] State error() const override; [[nodiscard]] DataFlowAnalysisType analysisType() const override; /* diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.h index 27eed099ea..b720bcc426 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.h @@ -81,8 +81,6 @@ class OpenSSLEVPKDFDescription [[nodiscard]] TypeStateDescription::State uninit() const override; - [[nodiscard]] TypeStateDescription::State start() const override; - [[nodiscard]] TypeStateDescription::State error() const override; [[nodiscard]] DataFlowAnalysisType analysisType() const override; diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.h index 597fa27955..343c594dd3 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.h @@ -70,7 +70,6 @@ class OpenSSLSecureHeapDescription [[nodiscard]] TypeStateDescription::State bottom() const override; [[nodiscard]] TypeStateDescription::State top() const override; [[nodiscard]] TypeStateDescription::State uninit() const override; - [[nodiscard]] TypeStateDescription::State start() const override; [[nodiscard]] TypeStateDescription::State error() const override; [[nodiscard]] DataFlowAnalysisType analysisType() const override; }; diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.h index 57c41710c6..0140f8361a 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.h @@ -39,7 +39,6 @@ class OpenSSLSecureMemoryDescription [[nodiscard]] TypeStateDescription::State bottom() const override; [[nodiscard]] TypeStateDescription::State top() const override; [[nodiscard]] TypeStateDescription::State uninit() const override; - [[nodiscard]] TypeStateDescription::State start() const override; [[nodiscard]] TypeStateDescription::State error() const override; [[nodiscard]] DataFlowAnalysisType analysisType() const override; }; diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/TypeStateDescription.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/TypeStateDescription.h index 169b2b8f1e..0fb1abe4b1 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/TypeStateDescription.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/TypeStateDescription.h @@ -76,12 +76,6 @@ struct TypeStateDescription : public TypeStateDescriptionBase { */ [[nodiscard]] virtual State uninit() const = 0; - /** - * Represents the start/initial state of an object after creation, e.g. state - * of a file handle after fopen() - */ - [[nodiscard, deprecated]] virtual State start() const = 0; - /** * Represents the error state of an object */ diff --git a/include/phasar/PhasarLLVM/TypeHierarchy.h b/include/phasar/PhasarLLVM/TypeHierarchy.h index 7f9c9d6078..b2b21d2de7 100644 --- a/include/phasar/PhasarLLVM/TypeHierarchy.h +++ b/include/phasar/PhasarLLVM/TypeHierarchy.h @@ -11,7 +11,6 @@ #define PHASAR_PHASARLLVM_TYPEHIERARCHY_H #include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/TypeHierarchy/LLVMVFTable.h" #endif // PHASAR_PHASARLLVM_TYPEHIERARCHY_H diff --git a/include/phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h b/include/phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h index fccd023f85..325ec800d2 100644 --- a/include/phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h +++ b/include/phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h @@ -58,11 +58,6 @@ class DIBasedTypeHierarchy const DIBasedTypeHierarchyData &SerializedData); ~DIBasedTypeHierarchy() override = default; - [[deprecated("Use LLVMVFTableProvider::isVTable() instead")]] - static bool isVTable(llvm::StringRef VarName); - [[deprecated("Use LLVMVFTableProvider::removeVTablePrefix() instead")]] - static std::string removeVTablePrefix(llvm::StringRef VarName); - [[nodiscard]] bool hasType(ClassType Type) const override { return TypeToVertex.count(Type); } diff --git a/include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h b/include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h deleted file mode 100644 index 1e1a79cfe6..0000000000 --- a/include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h +++ /dev/null @@ -1,220 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Philipp Schubert. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Philipp Schubert and others - *****************************************************************************/ - -/* - * ClassHierarchy.h - * - * Created on: 01.02.2017 - * Author: pdschbrt - */ - -#ifndef PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMTYPEHIERARCHY_H_ -#define PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMTYPEHIERARCHY_H_ - -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMVFTable.h" -#include "phasar/TypeHierarchy/TypeHierarchy.h" - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/raw_ostream.h" - -#include "boost/graph/adjacency_list.hpp" -#include "boost/graph/graph_traits.hpp" - -#include -#include -#include -#include -#include -#include - -namespace llvm { -class Module; -class StructType; -class Function; -class GlobalVariable; -} // namespace llvm - -namespace psr { - -class LLVMProjectIRDB; -/** - * @brief Owns the class hierarchy of the analyzed program. - * - * This class is responsible for constructing a inter-modular class - * hierarchy graph based on the data from the %ProjectIRCompiledDB - * and reconstructing the virtual method tables. - */ -class [[deprecated("Use DIBasedTypeHierarchy instead")]] LLVMTypeHierarchy - : public TypeHierarchy { -public: - struct VertexProperties { - VertexProperties() = default; - VertexProperties(const llvm::StructType *Type); - - [[nodiscard]] std::string getTypeName() const; - - const llvm::StructType *Type = nullptr; - std::optional VFT = std::nullopt; - std::set ReachableTypes; - }; - - /// Edges in the class hierarchy graph doesn't hold any additional - /// information. - struct EdgeProperties { - EdgeProperties() = default; - }; - - /// Data structure holding the class hierarchy graph. - using bidigraph_t = - boost::adjacency_list; - - /// The type for vertex representative objects. - using vertex_t = boost::graph_traits::vertex_descriptor; - /// The type for edge representative objects. - using edge_t = boost::graph_traits::edge_descriptor; - // Let us have some further handy typedefs. - using vertex_iterator = boost::graph_traits::vertex_iterator; - using out_edge_iterator = boost::graph_traits::out_edge_iterator; - using in_edge_iterator = boost::graph_traits::in_edge_iterator; - - static inline constexpr llvm::StringLiteral StructPrefix = "struct."; - static inline constexpr llvm::StringLiteral ClassPrefix = "class."; - static inline constexpr llvm::StringLiteral VTablePrefix = "_ZTV"; - static inline constexpr llvm::StringLiteral VTablePrefixDemang = - "vtable for "; - static inline constexpr llvm::StringLiteral TypeInfoPrefix = "_ZTI"; - static inline constexpr llvm::StringLiteral TypeInfoPrefixDemang = - "typeinfo for "; - static inline constexpr llvm::StringLiteral PureVirtualCallName = - "__cxa_pure_virtual"; - -private: - bidigraph_t TypeGraph; - std::unordered_map TypeVertexMap; - // maps type names to the corresponding vtable - std::unordered_map TypeVFTMap; - // holds all modules that are included in the type hierarchy - std::unordered_set VisitedModules; - // helper map from clearname to type* - std::unordered_map ClearNameTypeMap; - // map from clearname to type info variable - std::unordered_map ClearNameTIMap; - // map from clearname to vtable variable - std::unordered_map ClearNameTVMap; - - std::vector getSubTypes( - const llvm::Module &M, const llvm::StructType &Type) const; - - std::vector getVirtualFunctions( - const llvm::Module &M, const llvm::StructType &Type); - -protected: - void buildLLVMTypeHierarchy(const llvm::Module &M); - -public: - static bool isTypeInfo(llvm::StringRef VarName); - static bool isVTable(llvm::StringRef VarName); - static bool isStruct(const llvm::StructType &T); - static bool isStruct(llvm::StringRef TypeName); - - static std::string removeStructOrClassPrefix(const llvm::StructType &T); - static std::string removeStructOrClassPrefix(llvm::StringRef TypeName); - static std::string removeTypeInfoPrefix(llvm::StringRef VarName); - static std::string removeVTablePrefix(llvm::StringRef VarName); - - /** - * @brief Creates a LLVMStructTypeHierarchy based on the - * given ProjectIRCompiledDB. - * @param IRDB ProjectIRCompiledDB object. - */ - LLVMTypeHierarchy(const LLVMProjectIRDB &IRDB); - LLVMTypeHierarchy(const LLVMProjectIRDB &IRDB, - const LLVMTypeHierarchyData &SerializedData); - - /** - * @brief Creates a LLVMStructTypeHierarchy based on the - * llvm::Module. - * @param M A llvm::Module. - */ - LLVMTypeHierarchy(const llvm::Module &M); - - ~LLVMTypeHierarchy() override = default; - - /** - * @brief Constructs the actual class hierarchy graph. - * @param M LLVM module - * - * Extracts new information from the given module and adds new vertices - * and edges accordingly to the type hierarchy graph. - */ - void constructHierarchy(const llvm::Module &M); - - [[nodiscard]] inline bool hasType(const llvm::StructType *Type) - const override { - return TypeVertexMap.count(Type); - } - - [[nodiscard]] inline bool isSubType(const llvm::StructType *Type, - const llvm::StructType *SubType) - const override { - auto ReachableTypes = getSubTypes(Type); - return ReachableTypes.count(SubType); - } - - std::set getSubTypes(const llvm::StructType *Type) - const override; - - [[nodiscard]] const llvm::StructType *getType(llvm::StringRef TypeName) - const override; - - [[nodiscard]] std::vector getAllTypes() - const override; - - [[nodiscard]] llvm::StringRef getTypeName(const llvm::StructType *Type) - const override; - - [[nodiscard]] size_t size() const noexcept override { - return boost::num_vertices(TypeGraph); - }; - - [[nodiscard]] bool empty() const noexcept override { - return boost::num_vertices(TypeGraph) == 0; - }; - - void print(llvm::raw_ostream &OS = llvm::outs()) const override; - - // void mergeWith(LLVMTypeHierarchy &Other); - - /** - * @brief Prints the transitive closure of the class hierarchy graph. - */ - void printTransitiveClosure(llvm::raw_ostream &OS = llvm::outs()) const; - - /** - * @brief Prints the class hierarchy to an ostream in dot format. - * @param an outputstream - */ - void printAsDot(llvm::raw_ostream &OS = llvm::outs()) const; - - /** - * @brief Prints the class hierarchy to an ostream in json format. - * @param an outputstream - */ - void printAsJson(llvm::raw_ostream &OS = llvm::outs()) const override; - - // void printGraphAsDot(llvm::raw_ostream &out); - - // static bidigraph_t loadGraphFormDot(std::istream &in); -}; - -} // namespace psr - -#endif diff --git a/include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.h b/include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.h deleted file mode 100644 index b9757d0b3c..0000000000 --- a/include/phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.h +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2024 Fabian Schiebel. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Maximilian Leo Huber and others - *****************************************************************************/ - -#ifndef PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMTYPEHIERARCHYDATA_H_ -#define PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMTYPEHIERARCHYDATA_H_ - -#include "llvm/ADT/StringMap.h" -#include "llvm/Support/raw_ostream.h" - -#include - -namespace psr { -struct LLVMTypeHierarchyData { - std::string PhasarConfigJsonTypeHierarchyID; - // key = vertex, value = edges - llvm::StringMap> TypeGraph; - - LLVMTypeHierarchyData() noexcept = default; - void printAsJson(llvm::raw_ostream &OS); - - static LLVMTypeHierarchyData deserializeJson(const llvm::Twine &Path); - static LLVMTypeHierarchyData loadJsonString(llvm::StringRef JsonAsString); -}; - -} // namespace psr - -#endif // PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMTYPEHIERARCHYDATA_H_ diff --git a/lib/DB/DB.cppm b/lib/DB/DB.cppm index 70c396ce87..70e53fefb7 100644 --- a/lib/DB/DB.cppm +++ b/lib/DB/DB.cppm @@ -1,8 +1,6 @@ module; -#include "phasar/DB/Hexastore.h" #include "phasar/DB/ProjectIRDBBase.h" -#include "phasar/DB/Queries.h" export module phasar.db; @@ -11,23 +9,4 @@ 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/DB/Hexastore.cpp b/lib/DB/Hexastore.cpp deleted file mode 100644 index a912b4683e..0000000000 --- a/lib/DB/Hexastore.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Philipp Schubert. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Philipp Schubert and others - *****************************************************************************/ - -#include "phasar/DB/Hexastore.h" - -#include "phasar/DB/Queries.h" - -#include "boost/format.hpp" -#include "sqlite3.h" - -namespace psr { - -Hexastore::Hexastore(const std::string &Filename) { - sqlite3_open(Filename.c_str(), &HSInternalDB); - const std::string &Query = INIT; - char *Err; - sqlite3_exec(HSInternalDB, Query.c_str(), callback, nullptr, &Err); - if (Err != nullptr) { - llvm::outs() << Err << "\n\n"; - } -} - -Hexastore::~Hexastore() { sqlite3_close(HSInternalDB); } - -int Hexastore::callback(void * /*NotUsed*/, int Argc, char **Argv, - char **AzColName) { - for (int Idx = 0; Idx < Argc; ++Idx) { - llvm::outs() << AzColName[Idx] << " " << (Argv[Idx] ? Argv[Idx] : "NULL") - << '\n'; - } - return 0; -} - -void Hexastore::put(const std::array &Edge) { - doPut(SPOInsert, Edge); - doPut(SOPInsert, Edge); - doPut(PSOInsert, Edge); - doPut(POSInsert, Edge); - doPut(OSPInsert, Edge); - doPut(OPSInsert, Edge); -} - -void Hexastore::doPut(const std::string &Query, - std::array Edge) { - std::string CompiledQuery = - str(boost::format(Query) % Edge[0] % Edge[1] % Edge[2]); - char *Err; - sqlite3_exec(HSInternalDB, CompiledQuery.c_str(), callback, nullptr, &Err); - if (Err != nullptr) { - llvm::outs() << Err; - } -} - -std::vector Hexastore::get(std::array EdgeQuery, - size_t ResultSizeHint) { - std::vector Result; - Result.reserve(ResultSizeHint); - std::string QueryString; - if (EdgeQuery[0] == "?") { - if (EdgeQuery[1] == "?") { - if (EdgeQuery[2] == "?") { - QueryString = SearchXXX; - } else { - QueryString = SearchXXO; - } - } else { - if (EdgeQuery[2] == "?") { - QueryString = SearchXPX; - } else { - QueryString = SearchXPO; - } - } - } else { - if (EdgeQuery[1] == "?") { - if (EdgeQuery[2] == "?") { - QueryString = SearchSXX; - } else { - QueryString = SearchSXO; - } - } else { - if (EdgeQuery[2] == "?") { - QueryString = SearchSPX; - } else { - QueryString = SearchSPO; - } - } - } - std::string CompiledQuery = str(boost::format(QueryString) % EdgeQuery[0] % - EdgeQuery[1] % EdgeQuery[2]); - // this lambda will collect all of our results, since it is called on every - // row of the result set - auto SqliteCBResultCollector = [](void *CB, int /*Argc*/, char **Argv, - char ** /*AzColName*/) { - auto *Res = static_cast *>(CB); - Res->emplace_back(Argv[0], Argv[1], Argv[2]); - return 0; - }; - char *Err; - sqlite3_exec(HSInternalDB, CompiledQuery.c_str(), SqliteCBResultCollector, - &Result, &Err); - if (Err != nullptr) { - llvm::outs() << Err; - } - return Result; -} - -} // namespace psr diff --git a/lib/DB/Queries.cpp b/lib/DB/Queries.cpp deleted file mode 100644 index 671a9db22c..0000000000 --- a/lib/DB/Queries.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Philipp Schubert. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Christian Stritzke and others - *****************************************************************************/ - -#include "phasar/DB/Queries.h" - -using namespace std; -using namespace psr; - -namespace psr { - -const string SPOInsert = - "insert or ignore into spo_subject (name) " - "values (\"%1%\");" - - "insert or ignore into spo_predicate (name, sid) " - "values (\"%2%\", (select id from spo_subject where name=\"%1%\"));" - - "insert or ignore into spo_object (name, sid, pid) " - "values (\"%3%\", (select id from spo_subject where name=\"%1%\"), " - "(select id from spo_predicate where name=\"%2%\" and sid=(select id from " - "spo_subject where name=\"%1%\")));"; - -const string SOPInsert = - "insert or ignore into sop_subject (name) " - "values (\"%1%\");" - - "insert or ignore into sop_object (name, sid) " - "values (\"%3%\", (select id from sop_subject where name=\"%1%\"));" - - "insert or ignore into sop_predicate (name, sid, oid) " - "values (\"%2%\", (select id from sop_subject where name=\"%1%\"), " - "(select id from sop_object where name=\"%3%\" and sid=(select id from " - "sop_subject where name=\"%1%\")));"; - -const string PSOInsert = - "insert or ignore into pso_predicate (name) " - "values (\"%2%\");" - - "insert or ignore into pso_subject (name, pid) " - "values (\"%1%\", (select id from pso_predicate where name=\"%2%\"));" - - "insert or ignore into pso_object (name, pid, sid) " - "values (\"%3%\", (select id from pso_predicate where name=\"%2%\"), " - "(select id from pso_subject where name=\"%1%\" and pid=(select id from " - "pso_predicate where name=\"%2%\")));"; - -const string POSInsert = - "insert or ignore into pos_predicate (name) " - "values (\"%2%\");" - - "insert or ignore into pos_object (name, pid) " - "values (\"%3%\", (select id from pos_predicate where name=\"%2%\"));" - - "insert or ignore into pos_subject (name, oid, pid) " - "values (\"%1%\", (select id from pos_object where pos_object.name=\"%3%\" " - "and " - "pos_object.pid=(select id from pos_predicate where name=\"%2%\")), " - "(select pid from pos_object where name=\"%3%\" and pid=(select id from " - "pos_predicate where name=\"%2%\")));"; - -const string OSPInsert = - "insert or ignore into osp_object (name) " - "values (\"%3%\");" - - "insert or ignore into osp_subject (name, oid) " - "values (\"%1%\", (select id from osp_object where name=\"%3%\"));" - - "insert or ignore into osp_predicate (name, sid, oid) " - "values (\"%2%\", (select id from osp_subject where name=\"%1%\" and " - "oid=(select id from osp_object where name=\"%3%\")), " - "(select id from osp_object where name=\"%3%\" and oid=(select id from " - "osp_object where name=\"%3%\")));"; - -const string OPSInsert = - "insert or ignore into ops_object (name) " - "values (\"%3%\");" - - "insert or ignore into ops_predicate (name, oid) " - "values (\"%2%\", (select id from ops_object where name=\"%3%\"));" - - "insert or ignore into ops_subject (name, pid, oid) " - "values (\"%1%\", (select id from ops_predicate where name=\"%2%\"), " - "(select id from pos_object where name=\"%3%\" and oid=(select id from " - "osp_object where name=\"%3%\")));"; - -const string SearchSPO = - "select spo_subject.name, spo_predicate.name, spo_object.name from " - "spo_subject inner join spo_predicate on spo_subject.id=spo_predicate.sid " - "inner join spo_object on spo_predicate.id=spo_object.pid and " - "spo_subject.id=spo_object.sid " - "where spo_subject.name=\"%1%\" and spo_predicate.name=\"%2%\" and " - "spo_object.name=\"%3%\";"; - -const string SearchSPX = - "-- %3%\n" - "select spo_subject.name, spo_predicate.name, spo_object.name from " - "spo_subject inner join spo_predicate on spo_subject.id=spo_predicate.sid " - "inner join spo_object on spo_predicate.id=spo_object.pid and " - "spo_subject.id=spo_object.sid " - "where spo_subject.name=\"%1%\" and spo_predicate.name=\"%2%\";"; - -const string SearchSXO = - "-- %2%\n" - "select sop_subject.name, sop_predicate.name, sop_object.name from " - "sop_subject " - "inner join sop_object on sop_subject.id=sop_object.sid " - "inner join sop_predicate on sop_object.id=sop_predicate.id and " - "sop_subject.id=sop_predicate.sid " - "where sop_subject.name=\"%1%\" and sop_object.name=\"%3%\";"; - -const string SearchXPO = - "-- %1%\n" - "select pos_subject.name, pos_predicate.name, pos_object.name from " - "pos_predicate " - "inner join pos_object on pos_object.pid=pos_predicate.id " - "inner join pos_subject on pos_subject.pid=pos_predicate.id and " - "pos_subject.oid=pos_object.id " - "where pos_predicate.name=\"%2%\" and pos_object.name=\"%3%\";"; - -const string SearchSXX = - "-- %2%%3%\n" - "select spo_subject.name, spo_predicate.name, spo_object.name from " - "spo_subject inner join spo_predicate on spo_subject.id=spo_predicate.sid " - "inner join spo_object on spo_predicate.id=spo_object.pid and " - "spo_subject.id=spo_object.sid " - "where spo_subject.name=\"%1%\";"; - -const string SearchXPX = - "-- %1%%3%\n" - "select pso_subject.name, pso_predicate.name, pso_object.name from " - "pso_predicate inner join pso_subject on pso_predicate.id=pso_subject.pid " - "inner join pso_object on pso_predicate.id=pso_object.pid and " - "pso_subject.id=pso_object.sid " - "where pso_predicate.name=\"%2%\";"; - -const string SearchXXO = - "-- %1%%2%\n" - "select osp_subject.name, osp_predicate.name, osp_object.name from " - "osp_object inner join osp_subject on osp_object.id=osp_subject.oid " - "inner join osp_predicate on osp_subject.id=osp_predicate.sid and " - "osp_object.id=osp_predicate.oid " - "where osp_object.name=\"%3%\";"; - -const string SearchXXX = - "-- %1%%2%%3%\n" - "select spo_subject.name, spo_predicate.name, spo_object.name from " - "spo_subject inner join spo_predicate on spo_subject.id=spo_predicate.sid " - "inner join spo_object on spo_predicate.id=spo_object.pid and " - "spo_subject.id=spo_object.sid;"; - -const string INIT = R"( --- SPO Tables -create table if not exists spo_subject ( - id integer not null primary key AUTOINCREMENT, - name varchar unique not null -); -create table if not exists spo_predicate( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - sid integer not null, - foreign key (sid) references spo_subject(id), - unique(name, sid) -); -create table if not exists spo_object( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - pid integer not null, - sid integer not null, - foreign key (pid) references spo_predicate(id), - foreign key (sid) references spo_subject(id), - unique(name, pid, sid) -); - - - --- SOP Tables -create table if not exists sop_subject ( - id integer not null primary key AUTOINCREMENT, - name varchar unique not null -); -create table if not exists sop_object( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - sid integer not null, - foreign key (sid) references sop_subject(id), - unique(name, sid) -); -create table if not exists sop_predicate( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - oid integer not null, - sid integer not null, - foreign key (oid) references sop_object(id), - foreign key (sid) references sop_subject(id), - unique(name, oid, sid) -); - - - --- PSO Tables -create table if not exists pso_predicate ( - id integer not null primary key AUTOINCREMENT, - name varchar unique not null -); -create table if not exists pso_subject( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - pid integer not null, - foreign key (pid) references pso_predicate(id), - unique(name, pid) -); -create table if not exists pso_object( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - sid integer not null, - pid integer not null, - foreign key (sid) references pso_subject(id), - foreign key (pid) references pso_predicate(id), - unique(name, sid, pid) -); - - - --- POS Tables -create table if not exists pos_predicate ( - id integer not null primary key AUTOINCREMENT, - name varchar unique not null -); -create table if not exists pos_object( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - pid integer not null, - foreign key (pid) references pos_predicate(id), - unique(name, pid) -); -create table if not exists pos_subject( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - oid integer not null, - pid integer not null, - foreign key (oid) references pos_object(id), - foreign key (pid) references pos_predicate(id), - unique(name, oid, pid) -); - - - --- OSP Tables -create table if not exists osp_object ( - id integer not null primary key AUTOINCREMENT, - name varchar unique not null -); -create table if not exists osp_subject( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - oid integer not null, - foreign key (oid) references osp_object(id), - unique(name, oid) -); -create table if not exists osp_predicate( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - sid integer not null, - oid integer not null, - foreign key (sid) references osp_subject(id), - foreign key (oid) references osp_object(id), - unique(name, sid, oid) -); - - - --- OPS Tables -create table if not exists ops_object ( - id integer not null primary key AUTOINCREMENT, - name varchar unique not null -); -create table if not exists ops_predicate( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - oid integer not null, - foreign key (oid) references ops_object(id), - unique(name, oid) -); -create table if not exists ops_subject( - id integer not null unique primary key AUTOINCREMENT, - name varchar not null, - pid integer not null, - oid integer not null, - foreign key (pid) references ops_predicate(id), - foreign key (oid) references ops_object(id), - unique(name, pid, oid) -); - - )"; - -} // namespace psr diff --git a/lib/PhasarLLVM/ControlFlow/LLVMVFTableProvider.cpp b/lib/PhasarLLVM/ControlFlow/LLVMVFTableProvider.cpp index 67246c938e..d3021167cf 100644 --- a/lib/PhasarLLVM/ControlFlow/LLVMVFTableProvider.cpp +++ b/lib/PhasarLLVM/ControlFlow/LLVMVFTableProvider.cpp @@ -180,5 +180,10 @@ LLVMVFTableProvider::removeVTablePrefix(llvm::StringRef GlobName) noexcept { /// Supercedes DIBasedTypeHierarchy::isVTable() + removeVTablePrefix bool LLVMVFTableProvider::isVTable(llvm::StringRef MangledVarName) { - return MangledVarName.startswith(VTablePrefix); + if (MangledVarName.startswith(VTablePrefix)) { + return true; + } + // In LLVM 17 demangle() takes a StringRef + auto Demang = llvm::demangle(MangledVarName.str()); + return llvm::StringRef(Demang).startswith(VTablePrefixDemang); } diff --git a/lib/PhasarLLVM/ControlFlow/Resolver/CHAResolver.cpp b/lib/PhasarLLVM/ControlFlow/Resolver/CHAResolver.cpp index 56b9565a80..c902cf0658 100644 --- a/lib/PhasarLLVM/ControlFlow/Resolver/CHAResolver.cpp +++ b/lib/PhasarLLVM/ControlFlow/Resolver/CHAResolver.cpp @@ -17,7 +17,6 @@ #include "phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h" #include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" diff --git a/lib/PhasarLLVM/ControlFlow/Resolver/Resolver.cpp b/lib/PhasarLLVM/ControlFlow/Resolver/Resolver.cpp index b80fe475eb..fd498a7aa8 100644 --- a/lib/PhasarLLVM/ControlFlow/Resolver/Resolver.cpp +++ b/lib/PhasarLLVM/ControlFlow/Resolver/Resolver.cpp @@ -231,13 +231,9 @@ Resolver::Resolver(const LLVMProjectIRDB *IRDB, const LLVMVFTableProvider *VTP) assert(IRDB != nullptr); } -void Resolver::preCall(const llvm::Instruction *Inst) {} - void Resolver::handlePossibleTargets(const llvm::CallBase *CallSite, FunctionSetTy &PossibleTargets) {} -void Resolver::postCall(const llvm::Instruction *Inst) {} - auto Resolver::resolveIndirectCall(const llvm::CallBase *CallSite) -> FunctionSetTy { FunctionSetTy PossibleTargets; @@ -282,8 +278,6 @@ void Resolver::resolveFunctionPointer(FunctionSetTy &PossibleTargets, } } -void Resolver::otherInst(const llvm::Instruction *Inst) {} - std::unique_ptr Resolver::create(CallGraphAnalysisType Ty, const LLVMProjectIRDB *IRDB, const LLVMVFTableProvider *VTP, diff --git a/lib/PhasarLLVM/DB/LLVMProjectIRDB.cpp b/lib/PhasarLLVM/DB/LLVMProjectIRDB.cpp index 27c35db533..dd8c7e730d 100644 --- a/lib/PhasarLLVM/DB/LLVMProjectIRDB.cpp +++ b/lib/PhasarLLVM/DB/LLVMProjectIRDB.cpp @@ -113,29 +113,6 @@ LLVMProjectIRDB::getParsedIRModuleOrErr(const llvm::Twine &IRFileName, return getParsedIRModuleOrErr(*FileOrErr.get(), Ctx); } -std::unique_ptr -LLVMProjectIRDB::getParsedIRModuleOrNull(llvm::MemoryBufferRef IRFileContent, - llvm::LLVMContext &Ctx) noexcept { - - auto Mod = getParsedIRModuleOrErr(IRFileContent, Ctx); - if (Mod) { - return std::move(*Mod); - } - - return nullptr; -} - -std::unique_ptr -LLVMProjectIRDB::getParsedIRModuleOrNull(const llvm::Twine &IRFileName, - llvm::LLVMContext &Ctx) noexcept { - auto Mod = getParsedIRModuleOrErr(IRFileName, Ctx); - if (Mod) { - return std::move(*Mod); - } - - return nullptr; -} - llvm::ErrorOr LLVMProjectIRDB::load(const llvm::Twine &IRFileName, bool EnableOpaquePointers) { diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.cpp index f1b5852f50..dc1b619e22 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.cpp @@ -18,7 +18,6 @@ #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/KillIfSanitizedEdgeFunction.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/TransferEdgeFunction.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Pointer/PointsToInfo.h" diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp index 1833aceefa..107694bd90 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.cpp @@ -18,7 +18,6 @@ #include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMFlowFunctions.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.cpp index 1324d61a55..752939bd53 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.cpp @@ -17,7 +17,6 @@ #include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" #include "phasar/Utils/Utilities.h" diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.cpp index f7521ff33e..c43a9f99ea 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.cpp @@ -14,7 +14,6 @@ #include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.cpp index c00c1f2cbe..7f9d53dc95 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/CSTDFILEIOTypeStateDescription.cpp @@ -182,10 +182,6 @@ CSTDFILEIOState CSTDFILEIOTypeStateDescription::uninit() const { return CSTDFILEIOState::UNINIT; } -CSTDFILEIOState CSTDFILEIOTypeStateDescription::start() const { - return CSTDFILEIOState::OPENED; -} - CSTDFILEIOState CSTDFILEIOTypeStateDescription::error() const { return CSTDFILEIOState::ERROR; } diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.cpp index c46ec6d775..f22bec6963 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFCTXDescription.cpp @@ -184,10 +184,6 @@ OpenSSLEVPKDFCTXState OpenSSLEVPKDFCTXDescription::uninit() const { return OpenSSLEVPKDFCTXState::UNINIT; } -OpenSSLEVPKDFCTXState OpenSSLEVPKDFCTXDescription::start() const { - return OpenSSLEVPKDFCTXState::CTX_ATTACHED; -} - OpenSSLEVPKDFCTXState OpenSSLEVPKDFCTXDescription::error() const { return OpenSSLEVPKDFCTXState::ERROR; } diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.cpp index beeebd9b81..f08a3b6463 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLEVPKDFDescription.cpp @@ -120,10 +120,6 @@ OpenSSLEVPKDFState OpenSSLEVPKDFDescription::uninit() const { return OpenSSLEVPKDFState::UNINIT; } -OpenSSLEVPKDFState OpenSSLEVPKDFDescription::start() const { - return OpenSSLEVPKDFState::KDF_FETCHED; -} - OpenSSLEVPKDFState OpenSSLEVPKDFDescription::error() const { return OpenSSLEVPKDFState::ERROR; } diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.cpp index fcdcb70324..0bcb2b9774 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureHeapDescription.cpp @@ -155,11 +155,6 @@ OpenSSLSecureHeapState OpenSSLSecureHeapDescription::top() const { return OpenSSLSecureHeapState::TOP; } -OpenSSLSecureHeapState OpenSSLSecureHeapDescription::start() const { - llvm::report_fatal_error("TypeStateDescription::start() is deprecated"); - return OpenSSLSecureHeapState::BOT; -} - OpenSSLSecureHeapState OpenSSLSecureHeapDescription::uninit() const { return OpenSSLSecureHeapState::UNINIT; } diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.cpp index f836b5d0e2..ca5e26966e 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/OpenSSLSecureMemoryDescription.cpp @@ -158,10 +158,6 @@ OpenSSLSecureMemoryState OpenSSLSecureMemoryDescription::top() const { return OpenSSLSecureMemoryState::TOP; } -OpenSSLSecureMemoryState OpenSSLSecureMemoryDescription::start() const { - return OpenSSLSecureMemoryState::ALLOCATED; -} - OpenSSLSecureMemoryState OpenSSLSecureMemoryDescription::uninit() const { return OpenSSLSecureMemoryState::BOT; } diff --git a/lib/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.cpp b/lib/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.cpp index 4967c9faf0..4a6473d15d 100644 --- a/lib/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.cpp +++ b/lib/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.cpp @@ -311,25 +311,6 @@ auto DIBasedTypeHierarchy::subTypesOf(ClassType Ty) const noexcept return subTypesOf(It->second); } -bool DIBasedTypeHierarchy::isVTable(llvm::StringRef VarName) { - if (VarName.startswith(VTablePrefix)) { - return true; - } - // In LLVM 17 demangle() takes a StringRef - auto Demang = llvm::demangle(VarName.str()); - return llvm::StringRef(Demang).startswith(VTablePrefixDemang); -} - -std::string DIBasedTypeHierarchy::removeVTablePrefix(llvm::StringRef VarName) { - if (VarName.startswith(VTablePrefixDemang)) { - return VarName.drop_front(VTablePrefixDemang.size()).str(); - } - if (VarName.startswith(VTablePrefix)) { - return VarName.drop_front(VTablePrefix.size()).str(); - } - return VarName.str(); -} - void DIBasedTypeHierarchy::print(llvm::raw_ostream &OS) const { { OS << "Type Hierarchy:\n"; diff --git a/lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.cpp b/lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.cpp deleted file mode 100644 index 716f759af0..0000000000 --- a/lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2017 Philipp Schubert. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Philipp Schubert and others - *****************************************************************************/ - -/* - * ClassHierarchy.cpp - * - * Created on: 01.02.2017 - * Author: pdschbrt - */ - -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" - -#include "phasar/Config/Configuration.h" -#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" -#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" -#include "phasar/Utils/Logger.h" - -#include "llvm/ADT/StringMap.h" -#include "llvm/Demangle/Demangle.h" -#include "llvm/IR/Constants.h" -#include "llvm/IR/DerivedTypes.h" -#include "llvm/IR/Function.h" -#include "llvm/IR/GlobalVariable.h" -#include "llvm/IR/Module.h" - -#include "boost/graph/graphviz.hpp" -#include "boost/graph/transitive_closure.hpp" - -#include -#include - -using namespace std; - -namespace psr { - -// provide a VertexPropertyWrite to tell boost how to write a vertex -class [[deprecated]] TypeHierarchyVertexWriter { -public: - TypeHierarchyVertexWriter(const LLVMTypeHierarchy::bidigraph_t &TyGraph) - : TyGraph(TyGraph) {} - template - void operator()(std::ostream &Out, const VertexOrEdge &V) const { - Out << "[label=\"" << TyGraph[V].getTypeName() << "\"]"; - } - -private: - const LLVMTypeHierarchy::bidigraph_t &TyGraph; -}; - -LLVMTypeHierarchy::VertexProperties::VertexProperties( - const llvm::StructType *Type) - : Type(Type), ReachableTypes({Type}) {} - -std::string LLVMTypeHierarchy::VertexProperties::getTypeName() const { - return Type->getStructName().str(); -} - -LLVMTypeHierarchy::LLVMTypeHierarchy(const LLVMProjectIRDB &IRDB) { - PHASAR_LOG_LEVEL(INFO, "Construct type hierarchy"); - buildLLVMTypeHierarchy(*IRDB.getModule()); -} - -LLVMTypeHierarchy::LLVMTypeHierarchy( - const LLVMProjectIRDB &IRDB, const LLVMTypeHierarchyData &SerializedData) { - - llvm::StringMap NameToStructType; - const auto &IRDBModule = IRDB.getModule(); - - VisitedModules.insert(IRDBModule); - auto StructTypes = IRDBModule->getIdentifiedStructTypes(); - - // find all struct types by name - for (const auto &SerElement : SerializedData.TypeGraph) { - bool MatchFound = false; - - for (const auto &StructTypeElement : StructTypes) { - if (SerElement.getKey() == StructTypeElement->getName()) { - NameToStructType.try_emplace(SerElement.getKey(), StructTypeElement); - MatchFound = true; - break; - } - } - - if (!MatchFound) { - PHASAR_LOG_LEVEL(WARNING, - "No matching StructType found for Type with name: " - << SerElement.getKey()); - } - } - - // add all vertices - for (const auto &Curr : NameToStructType) { - const auto &StructType = Curr.getValue(); - auto Vertex = boost::add_vertex(TypeGraph); - TypeVertexMap[StructType] = Vertex; - TypeGraph[Vertex] = VertexProperties(StructType); - TypeVFTMap[StructType] = getVirtualFunctions(*IRDBModule, *StructType); - } - - // add all edges - for (const auto &SerElement : SerializedData.TypeGraph) { - const auto *SrcType = NameToStructType[SerElement.getKey()]; - if (!SrcType) { - continue; - } - auto Vtx = TypeVertexMap.at(SrcType); - for (const auto &CurrEdge : SerElement.getValue()) { - const auto *DestType = NameToStructType[CurrEdge]; - if (!SrcType) { - continue; - } - auto DestVtx = TypeVertexMap.at(DestType); - - TypeGraph[Vtx].ReachableTypes.insert(DestType); - boost::add_edge(Vtx, DestVtx, TypeGraph); - } - } -} - -LLVMTypeHierarchy::LLVMTypeHierarchy(const llvm::Module &M) { - PHASAR_LOG_LEVEL_CAT(INFO, "LLVMTypeHierarchy", "Construct type hierarchy"); - buildLLVMTypeHierarchy(M); - PHASAR_LOG_LEVEL_CAT(INFO, "LLVMTypeHierarchy", "Finished type hierarchy"); -} - -std::string -LLVMTypeHierarchy::removeStructOrClassPrefix(const llvm::StructType &T) { - return removeStructOrClassPrefix(T.getName().str()); -} - -std::string -LLVMTypeHierarchy::removeStructOrClassPrefix(llvm::StringRef TypeName) { - if (TypeName.startswith(StructPrefix)) { - TypeName = TypeName.drop_front(StructPrefix.size()); - } else if (TypeName.startswith(ClassPrefix)) { - TypeName = TypeName.drop_front(ClassPrefix.size()); - } - if (TypeName.endswith(".base")) { - TypeName = TypeName.drop_back(llvm::StringRef(".base").size()); - } - return TypeName.str(); -} - -std::string LLVMTypeHierarchy::removeTypeInfoPrefix(llvm::StringRef VarName) { - if (VarName.startswith(TypeInfoPrefixDemang)) { - return VarName.drop_front(TypeInfoPrefixDemang.size()).str(); - } - if (VarName.startswith(TypeInfoPrefix)) { - return VarName.drop_front(TypeInfoPrefix.size()).str(); - } - return VarName.str(); -} - -std::string LLVMTypeHierarchy::removeVTablePrefix(llvm::StringRef VarName) { - if (VarName.startswith(VTablePrefixDemang)) { - return VarName.drop_front(VTablePrefixDemang.size()).str(); - } - if (VarName.startswith(VTablePrefix)) { - return VarName.drop_front(VTablePrefix.size()).str(); - } - return VarName.str(); -} - -bool LLVMTypeHierarchy::isTypeInfo(llvm::StringRef VarName) { - if (VarName.startswith("_ZTI")) { - return true; - } - // In LLVM 16 demangle() takes a StringRef - auto Demang = llvm::demangle(VarName.str()); - return llvm::StringRef(Demang).startswith(TypeInfoPrefixDemang); -} - -bool LLVMTypeHierarchy::isVTable(llvm::StringRef VarName) { - if (VarName.startswith("_ZTV")) { - return true; - } - // In LLVM 16 demangle() takes a StringRef - auto Demang = llvm::demangle(VarName.str()); - return llvm::StringRef(Demang).startswith(VTablePrefixDemang); -} - -bool LLVMTypeHierarchy::isStruct(const llvm::StructType &T) { - return isStruct(T.getName()); -} - -bool LLVMTypeHierarchy::isStruct(llvm::StringRef TypeName) { - return TypeName.startswith(StructPrefix); -} - -void LLVMTypeHierarchy::buildLLVMTypeHierarchy(const llvm::Module &M) { - // build the hierarchy for the module - constructHierarchy(M); - // cache the reachable types - bidigraph_t TC; - boost::transitive_closure(TypeGraph, TC); - for (auto V : boost::make_iterator_range(boost::vertices(TypeGraph))) { - for (auto OE : boost::make_iterator_range(boost::out_edges(V, TC))) { - auto Target = boost::target(OE, TC); - TypeGraph[V].ReachableTypes.insert(TypeGraph[Target].Type); - } - } -} - -std::vector -LLVMTypeHierarchy::getSubTypes(const llvm::Module & /*M*/, - const llvm::StructType &Type) const { - // find corresponding type info variable - std::vector SubTypes; - std::string ClearName = removeStructOrClassPrefix(Type); - - if (auto It = ClearNameTIMap.find(ClearName); It != ClearNameTIMap.end()) { - const auto *TI = It->second; - if (!TI->hasInitializer()) { - PHASAR_LOG_LEVEL_CAT(DEBUG, "LLVMTypeHierarchy", - ClearName << " does not have initializer"); - return SubTypes; - } - if (const auto *I = - llvm::dyn_cast(TI->getInitializer())) { - for (const auto &Op : I->operands()) { - const auto *CE = Op->stripPointerCastsAndAliases(); - - if (CE->hasName()) { - auto Name = CE->getName(); - if (Name.find(TypeInfoPrefix) != llvm::StringRef::npos) { - auto ClearName = removeTypeInfoPrefix(llvm::demangle(Name.str())); - if (auto TypeIt = ClearNameTypeMap.find(ClearName); - TypeIt != ClearNameTypeMap.end()) { - SubTypes.push_back(TypeIt->second); - } - } - } - } - } - } - return SubTypes; -} - -std::vector -LLVMTypeHierarchy::getVirtualFunctions(const llvm::Module &M, - const llvm::StructType &Type) { - auto ClearName = removeStructOrClassPrefix(Type.getName()); - std::vector VFS; - if (const auto *TV = ClearNameTVMap[ClearName]) { - if (const auto *TI = llvm::dyn_cast(TV)) { - if (!TI->hasInitializer()) { - PHASAR_LOG_LEVEL_CAT(DEBUG, "LLVMTypeHierarchy", - ClearName << " does not have initializer"); - return VFS; - } - if (const auto *I = - llvm::dyn_cast(TI->getInitializer())) { - VFS = LLVMVFTable::getVFVectorFromIRVTable(*I); - } - } - } - return VFS; -} - -void LLVMTypeHierarchy::constructHierarchy(const llvm::Module &M) { - PHASAR_LOG_LEVEL_CAT(DEBUG, "LLVMTypeHierarchy", - "Analyze types in module: " << M.getModuleIdentifier()); - // store analyzed module - VisitedModules.insert(&M); - auto StructTypes = M.getIdentifiedStructTypes(); - // build helper maps - for (auto *StructType : StructTypes) { - ClearNameTypeMap[removeStructOrClassPrefix(*StructType)] = StructType; - } - for (const auto &Global : M.globals()) { - if (Global.hasName()) { - if (isTypeInfo(Global.getName())) { - auto Demang = llvm::demangle(Global.getName().str()); - auto ClearName = removeTypeInfoPrefix(Demang); - ClearNameTIMap[ClearName] = &Global; - } - if (isVTable(Global.getName())) { - auto Demang = llvm::demangle(Global.getName().str()); - auto ClearName = removeVTablePrefix(Demang); - ClearNameTVMap[ClearName] = &Global; - } - } - } - // iterate struct types and add vertices - for (auto *StructType : StructTypes) { - if (!TypeVertexMap.count(StructType)) { - auto Vertex = boost::add_vertex(TypeGraph); - TypeVertexMap[StructType] = Vertex; - TypeGraph[Vertex] = VertexProperties(StructType); - TypeVFTMap[StructType] = getVirtualFunctions(M, *StructType); - } - } - - // construct the edges between a type and its subtypes - for (auto *StructType : StructTypes) { - // use type information to check if it is really a subtype - auto SubTypes = getSubTypes(M, *StructType); - - for (const auto *SubType : SubTypes) { - boost::add_edge(TypeVertexMap[SubType], TypeVertexMap[StructType], - TypeGraph); - } - } -} - -std::set -LLVMTypeHierarchy::getSubTypes(const llvm::StructType *Type) const { - if (TypeVertexMap.count(Type)) { - if (auto It = TypeVertexMap.find(Type); It != TypeVertexMap.end()) { - return TypeGraph[It->second].ReachableTypes; - } - } - return {}; -} - -template -static const llvm::StructType *getTypeImpl(const GraphT &TypeGraph, - llvm::StringRef TypeName) { - for (auto V : boost::make_iterator_range(boost::vertices(TypeGraph))) { - if (TypeGraph[V].Type->getName() == TypeName) { - return TypeGraph[V].Type; - } - } - return nullptr; -} - -const llvm::StructType * -LLVMTypeHierarchy::getType(llvm::StringRef TypeName) const { - if (const auto *Ty = getTypeImpl(TypeGraph, TypeName)) { - return Ty; - } - - // Sometimes, clang adds a .base suffix - return getTypeImpl(TypeGraph, (TypeName + ".base").str()); -} - -std::vector LLVMTypeHierarchy::getAllTypes() const { - std::vector Types; - Types.reserve(boost::num_vertices(TypeGraph)); - for (auto V : boost::make_iterator_range(boost::vertices(TypeGraph))) { - Types.push_back(TypeGraph[V].Type); - } - return Types; -} - -llvm::StringRef -LLVMTypeHierarchy::getTypeName(const llvm::StructType *Type) const { - return Type->getStructName(); -} - -void LLVMTypeHierarchy::print(llvm::raw_ostream &OS) const { - OS << "Type Hierarchy:\n"; - vertex_iterator UI; - - vertex_iterator UIEnd; - for (boost::tie(UI, UIEnd) = boost::vertices(TypeGraph); UI != UIEnd; ++UI) { - OS << TypeGraph[*UI].getTypeName() << " --> "; - out_edge_iterator EI; - - out_edge_iterator EIEnd; - for (boost::tie(EI, EIEnd) = boost::out_edges(*UI, TypeGraph); EI != EIEnd; - ++EI) { - OS << TypeGraph[target(*EI, TypeGraph)].getTypeName() << " "; - } - OS << '\n'; - } - OS << "VFTables:\n"; - for (const auto &[Ty, VFT] : TypeVFTMap) { - OS << "Virtual function table for: " << Ty->getName() << '\n'; - for (const auto *F : VFT) { - OS << "\t-" << F->getName() << '\n'; - } - } -} - -void LLVMTypeHierarchy::printAsDot(llvm::raw_ostream &OS) const { - std::stringstream S; - boost::write_graphviz(S, TypeGraph, TypeHierarchyVertexWriter(TypeGraph)); - OS << S.str(); -} - -void LLVMTypeHierarchy::printAsJson(llvm::raw_ostream &OS) const { - LLVMTypeHierarchyData Data; - Data.PhasarConfigJsonTypeHierarchyID = - PhasarConfig::JsonTypeHierarchyID().str(); - - // iterate all graph vertices - for (auto Vtx : boost::make_iterator_range(boost::vertices(TypeGraph))) { - // iterate all out edges of vertex vi_v - auto &SerTypes = Data.TypeGraph[TypeGraph[Vtx].getTypeName()]; - for (const auto &CurrReachable : TypeGraph[Vtx].ReachableTypes) { - SerTypes.push_back(CurrReachable->getName().str()); - } - } - - Data.printAsJson(OS); -} - -// void LLVMTypeHierarchy::printGraphAsDot(ostream &out) { -// boost::dynamic_properties dp; -// dp.property("node_id", get(&LLVMTypeHierarchy::VertexProperties::name, -// TypeGraph)); boost::write_graphviz_dp(out, TypeGraph, dp); -// } - -// LLVMTypeHierarchy::bidigraph_t -// LLVMTypeHierarchy::loadGraphFormDot(istream &in) { -// LLVMTypeHierarchy::bidigraph_t G(0); -// boost::dynamic_properties dp; -// dp.property("node_id", get(&LLVMTypeHierarchy::VertexProperties::name, -// G)); boost::read_graphviz(in, G, dp); return G; -// } - -} // namespace psr diff --git a/lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.cpp b/lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.cpp deleted file mode 100644 index 504885b7c2..0000000000 --- a/lib/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2024 Fabian Schiebel. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of LICENSE.txt. - * - * Contributors: - * Maximilian Leo Huber and others - *****************************************************************************/ - -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyData.h" - -#include "phasar/Utils/IO.h" -#include "phasar/Utils/NlohmannLogging.h" - -namespace psr { - -static LLVMTypeHierarchyData getDataFromJson(const nlohmann::json &Json) { - LLVMTypeHierarchyData Data; - Data.PhasarConfigJsonTypeHierarchyID = - Json["PhasarConfigJsonTypeHierarchyID"]; - - for (const auto &[Key, ValueArray] : - Json[Data.PhasarConfigJsonTypeHierarchyID].items()) { - Data.TypeGraph.try_emplace(Key, std::vector{}); - - for (const auto &CurrInnerType : ValueArray) { - for (const auto &CurrString : CurrInnerType) { - Data.TypeGraph[Key].push_back(CurrString.get()); - } - } - } - - return Data; -} - -void LLVMTypeHierarchyData::printAsJson(llvm::raw_ostream &OS) { - nlohmann::json Json; - - Json["PhasarConfigJsonTypeHierarchyID"] = PhasarConfigJsonTypeHierarchyID; - auto &JTH = Json[PhasarConfigJsonTypeHierarchyID]; - - for (const auto &Curr : TypeGraph) { - auto &DataPos = JTH[Curr.getKey()].emplace_back(); - - for (const auto &CurrTypeName : Curr.getValue()) { - DataPos.push_back(CurrTypeName); - } - } - - OS << Json << '\n'; -} - -LLVMTypeHierarchyData -LLVMTypeHierarchyData::deserializeJson(const llvm::Twine &Path) { - return getDataFromJson(readJsonFile(Path)); -} - -LLVMTypeHierarchyData -LLVMTypeHierarchyData::loadJsonString(llvm::StringRef JsonAsString) { - nlohmann::json Data = - nlohmann::json::parse(JsonAsString.begin(), JsonAsString.end()); - return getDataFromJson(Data); -} - -} // namespace psr diff --git a/lib/PhasarLLVM/TypeHierarchy/TypeHierarchy.cppm b/lib/PhasarLLVM/TypeHierarchy/TypeHierarchy.cppm index 073668c6a3..f7d5d35c40 100644 --- a/lib/PhasarLLVM/TypeHierarchy/TypeHierarchy.cppm +++ b/lib/PhasarLLVM/TypeHierarchy/TypeHierarchy.cppm @@ -2,8 +2,6 @@ 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" @@ -12,8 +10,6 @@ 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/unittests/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFGTest.cpp b/unittests/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFGTest.cpp index f1fd1ce6a9..864a06928d 100644 --- a/unittests/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFGTest.cpp +++ b/unittests/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFGTest.cpp @@ -1,7 +1,6 @@ #include "phasar/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFG.h" #include "phasar/Config/Configuration.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "llvm/IR/InstIterator.h" diff --git a/unittests/PhasarLLVM/ControlFlow/LLVMBasedICFG_OTFTest.cpp b/unittests/PhasarLLVM/ControlFlow/LLVMBasedICFG_OTFTest.cpp index bb6c8da5dc..0c9c0406fb 100644 --- a/unittests/PhasarLLVM/ControlFlow/LLVMBasedICFG_OTFTest.cpp +++ b/unittests/PhasarLLVM/ControlFlow/LLVMBasedICFG_OTFTest.cpp @@ -6,7 +6,6 @@ #include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "llvm/ADT/STLExtras.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysisTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysisTest.cpp index 33fcdaa918..9115c5d4a9 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysisTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysisTest.cpp @@ -17,7 +17,6 @@ #include "phasar/PhasarLLVM/HelperAnalysisConfig.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/BitVectorSet.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisSwiftTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisSwiftTest.cpp index 35f070a2ab..cc618db977 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisSwiftTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisSwiftTest.cpp @@ -5,7 +5,6 @@ #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "TestConfig.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisTest.cpp index a84d1d55eb..8eec062309 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysisTest.cpp @@ -6,7 +6,6 @@ #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "TestConfig.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisFileIOTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisFileIOTest.cpp index 79f09ab423..db858dd575 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisFileIOTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisFileIOTest.cpp @@ -15,7 +15,6 @@ #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/DebugOutput.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLEVPKDFTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLEVPKDFTest.cpp index c801682777..a10a5b419b 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLEVPKDFTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLEVPKDFTest.cpp @@ -16,7 +16,6 @@ #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "TestConfig.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureHeapTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureHeapTest.cpp index 92a05db2a3..0d7bc51bb4 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureHeapTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureHeapTest.cpp @@ -16,7 +16,6 @@ #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "llvm/ADT/Twine.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureMemoryTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureMemoryTest.cpp index c8e7bd9369..c56fcd8db0 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureMemoryTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETSAnalysisOpenSSLSecureMemoryTest.cpp @@ -15,7 +15,6 @@ #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "TestConfig.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysisTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysisTest.cpp index 04f564ac70..07c5187024 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysisTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysisTest.cpp @@ -7,7 +7,6 @@ #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "llvm/IR/Instruction.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysisTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysisTest.cpp index 8b60573548..f29987dabd 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysisTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysisTest.cpp @@ -7,7 +7,6 @@ #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" #include "phasar/PhasarLLVM/TaintConfig/LLVMTaintConfig.h" #include "phasar/PhasarLLVM/TaintConfig/TaintConfigBase.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/Utils/DebugOutput.h" #include "llvm/ADT/StringRef.h" diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/SparseIDESolverTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/SparseIDESolverTest.cpp index ee0353254a..3abcd460da 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/SparseIDESolverTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/SparseIDESolverTest.cpp @@ -12,7 +12,6 @@ #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" #include "phasar/PhasarLLVM/TaintConfig/LLVMTaintConfig.h" #include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Soundness.h" diff --git a/unittests/PhasarLLVM/DataFlow/Mono/InterMonoFullConstantPropagationTest.cpp b/unittests/PhasarLLVM/DataFlow/Mono/InterMonoFullConstantPropagationTest.cpp index c8cd293b85..98aed42b95 100644 --- a/unittests/PhasarLLVM/DataFlow/Mono/InterMonoFullConstantPropagationTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/Mono/InterMonoFullConstantPropagationTest.cpp @@ -17,7 +17,6 @@ #include "phasar/PhasarLLVM/Passes/ValueAnnotationPass.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" diff --git a/unittests/PhasarLLVM/DataFlow/Mono/InterMonoTaintAnalysisTest.cpp b/unittests/PhasarLLVM/DataFlow/Mono/InterMonoTaintAnalysisTest.cpp index 0ab2c5bc7a..14d8240de0 100644 --- a/unittests/PhasarLLVM/DataFlow/Mono/InterMonoTaintAnalysisTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/Mono/InterMonoTaintAnalysisTest.cpp @@ -7,7 +7,6 @@ #include "phasar/PhasarLLVM/Passes/ValueAnnotationPass.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" diff --git a/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoFullConstantPropagationTest.cpp b/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoFullConstantPropagationTest.cpp index 779cbdc672..63ba49a9b8 100644 --- a/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoFullConstantPropagationTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoFullConstantPropagationTest.cpp @@ -16,7 +16,6 @@ #include "phasar/PhasarLLVM/Passes/ValueAnnotationPass.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" diff --git a/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoUninitVariablesTest.cpp b/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoUninitVariablesTest.cpp index 63973c59ab..bdf9b71a65 100644 --- a/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoUninitVariablesTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/Mono/IntraMonoUninitVariablesTest.cpp @@ -17,7 +17,6 @@ #include "phasar/PhasarLLVM/Passes/ValueAnnotationPass.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" #include "phasar/Utils/Logger.h" diff --git a/unittests/PhasarLLVM/TypeHierarchy/CMakeLists.txt b/unittests/PhasarLLVM/TypeHierarchy/CMakeLists.txt index 75f52a91d5..5300452eda 100644 --- a/unittests/PhasarLLVM/TypeHierarchy/CMakeLists.txt +++ b/unittests/PhasarLLVM/TypeHierarchy/CMakeLists.txt @@ -1,8 +1,6 @@ set(PointerSources DIBasedTypeHierarchySerializationTest.cpp DIBasedTypeHierarchyTest.cpp - LLVMTypeHierarchySerializationTest.cpp - LLVMTypeHierarchyTest.cpp ) foreach(TEST_SRC ${PointerSources}) diff --git a/unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchySerializationTest.cpp b/unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchySerializationTest.cpp deleted file mode 100644 index 9042b52547..0000000000 --- a/unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchySerializationTest.cpp +++ /dev/null @@ -1,96 +0,0 @@ - -#include "phasar/Config/Configuration.h" -#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" -#include "phasar/PhasarLLVM/TypeHierarchy/DIBasedTypeHierarchy.h" -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" -#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" -#include "phasar/Utils/NlohmannLogging.h" -#include "phasar/Utils/Utilities.h" - -#include "llvm/ADT/StringRef.h" -#include "llvm/IR/DerivedTypes.h" - -#include "TestConfig.h" -#include "gtest/gtest.h" - -using namespace psr; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated" - -/* ============== TEST FIXTURE ============== */ -class LLVMTypeHierarchySerialization - : public ::testing::TestWithParam { -protected: - static constexpr auto PathToLlFiles = - PHASAR_BUILD_SUBFOLDER("type_hierarchies/"); - const std::vector EntryPoints = {"main"}; - -}; // Test Fixture - -void compareResults(psr::LLVMTypeHierarchy &Orig, - psr::LLVMTypeHierarchy &Deser) { - ASSERT_EQ(Orig.getAllTypes().size(), Deser.getAllTypes().size()); - - for (const auto &OrigCurrentType : Orig.getAllTypes()) { - // check types - EXPECT_EQ(OrigCurrentType, Deser.getType(OrigCurrentType->getName().str())); - - // check edges - for (const auto &OrigEdgeCurrentType : Orig.getAllTypes()) { - // Deser.isSubType can take the same arguments as Orig.isSubType, since - // Deser should have the same types - - bool ExpectedValue = Orig.isSubType(OrigCurrentType, OrigEdgeCurrentType); - bool DeserializedValue = - Deser.isSubType(Deser.getType(OrigCurrentType->getName().str()), - Deser.getType(OrigEdgeCurrentType->getName().str())); - - EXPECT_EQ(ExpectedValue, DeserializedValue); - } - } -} - -TEST_P(LLVMTypeHierarchySerialization, OrigAndDeserEqual) { - using namespace std::string_literals; - - psr::LLVMProjectIRDB IRDB(PathToLlFiles + GetParam()); - psr::LLVMTypeHierarchy TypeHierarchy(IRDB); - - std::string Ser; - llvm::raw_string_ostream StringStream(Ser); - - TypeHierarchy.printAsJson(StringStream); - - psr::LLVMTypeHierarchy DeserializedTypeHierarchy( - IRDB, psr::LLVMTypeHierarchyData::loadJsonString(Ser)); - - compareResults(TypeHierarchy, DeserializedTypeHierarchy); -} - -#pragma GCC diagnostic pop - -static constexpr std::string_view TypeHierarchyTestFiles[] = { - "type_hierarchy_1_cpp_dbg.ll", "type_hierarchy_2_cpp_dbg.ll", - "type_hierarchy_3_cpp_dbg.ll", "type_hierarchy_4_cpp_dbg.ll", - "type_hierarchy_5_cpp_dbg.ll", "type_hierarchy_6_cpp_dbg.ll", - "type_hierarchy_7_cpp_dbg.ll", "type_hierarchy_7_b_cpp_dbg.ll", - "type_hierarchy_8_cpp_dbg.ll", "type_hierarchy_9_cpp_dbg.ll", - "type_hierarchy_10_cpp_dbg.ll", "type_hierarchy_11_cpp_dbg.ll", - "type_hierarchy_12_cpp_dbg.ll", "type_hierarchy_12_b_cpp_dbg.ll", - "type_hierarchy_12_c_cpp_dbg.ll", "type_hierarchy_13_cpp_dbg.ll", - "type_hierarchy_14_cpp_dbg.ll", "type_hierarchy_15_cpp_dbg.ll", - "type_hierarchy_16_cpp_dbg.ll", "type_hierarchy_17_cpp_dbg.ll", - "type_hierarchy_18_cpp_dbg.ll", "type_hierarchy_19_cpp_dbg.ll", - "type_hierarchy_20_cpp_dbg.ll", "type_hierarchy_21_cpp_dbg.ll", -}; - -INSTANTIATE_TEST_SUITE_P(LLVMTypeHierarchySerializationTest, - LLVMTypeHierarchySerialization, - ::testing::ValuesIn(TypeHierarchyTestFiles)); - -int main(int Argc, char **Argv) { - ::testing::InitGoogleTest(&Argc, Argv); - auto Res = RUN_ALL_TESTS(); - return Res; -} diff --git a/unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyTest.cpp b/unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyTest.cpp deleted file mode 100644 index c9404f6070..0000000000 --- a/unittests/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchyTest.cpp +++ /dev/null @@ -1,421 +0,0 @@ - -#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h" - -#include "phasar/Config/Configuration.h" -#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" -#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" -#include "phasar/Utils/Utilities.h" - -#include "llvm/Demangle/Demangle.h" -#include "llvm/Support/ManagedStatic.h" - -#include "TestConfig.h" -#include "boost/graph/graph_utility.hpp" -#include "boost/graph/graphviz.hpp" -#include "boost/graph/isomorphism.hpp" -#include "gtest/gtest.h" - -using namespace std; -using namespace psr; - -using llvm::demangle; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated" - -namespace psr { - -// Check basic type hierarchy construction -TEST(LTHTest, BasicTHReconstruction_1) { - LLVMProjectIRDB IRDB(unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_1_cpp.ll"); - LLVMTypeHierarchy LTH(IRDB); - - ASSERT_EQ(LTH.hasType(LTH.getType("struct.Base")), true); - ASSERT_EQ(LTH.hasType(LTH.getType("struct.Child")), true); - EXPECT_EQ(LTH.getAllTypes().size(), 2U); - EXPECT_EQ( - LTH.isSubType(LTH.getType("struct.Base"), LTH.getType("struct.Child")), - true); - - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Base")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Child")).size(), 1U); - auto BaseReachable = LTH.getSubTypes(LTH.getType("struct.Base")); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Base")), true); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Child")), true); - auto ChildReachable = LTH.getSubTypes(LTH.getType("struct.Child")); - EXPECT_EQ(ChildReachable.count(LTH.getType("struct.Child")), true); -} - -TEST(LTHTest, THConstructionException) { - LLVMProjectIRDB IRDB(unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_15_cpp.ll"); - LLVMTypeHierarchy LTH(IRDB); -} - -TEST(LTHTest, BasicTHReconstruction_2) { - LLVMProjectIRDB IRDB({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_2_cpp.ll"}); - LLVMTypeHierarchy LTH(IRDB); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Base")), true); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Child")), true); - EXPECT_EQ(LTH.getAllTypes().size(), 2U); - EXPECT_EQ( - LTH.isSubType(LTH.getType("struct.Base"), LTH.getType("struct.Child")), - true); - - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Base")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Child")).size(), 1U); - auto BaseReachable = LTH.getSubTypes(LTH.getType("struct.Base")); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Base")), true); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Child")), true); - auto ChildReachable = LTH.getSubTypes(LTH.getType("struct.Child")); - EXPECT_EQ(ChildReachable.count(LTH.getType("struct.Child")), true); -} - -TEST(LTHTest, BasicTHReconstruction_3) { - LLVMProjectIRDB IRDB({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_3_cpp.ll"}); - LLVMTypeHierarchy LTH(IRDB); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Base")), true); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Child")), true); - EXPECT_EQ(LTH.getAllTypes().size(), 2U); - EXPECT_EQ( - LTH.isSubType(LTH.getType("struct.Base"), LTH.getType("struct.Child")), - true); - - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Base")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Child")).size(), 1U); - auto BaseReachable = LTH.getSubTypes(LTH.getType("struct.Base")); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Base")), true); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Child")), true); - auto ChildReachable = LTH.getSubTypes(LTH.getType("struct.Child")); - EXPECT_EQ(ChildReachable.count(LTH.getType("struct.Child")), true); -} - -TEST(LTHTest, BasicTHReconstruction_4) { - LLVMProjectIRDB IRDB({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_4_cpp.ll"}); - LLVMTypeHierarchy LTH(IRDB); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Base")), true); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Child")), true); - EXPECT_EQ(LTH.getAllTypes().size(), 2U); - EXPECT_EQ( - LTH.isSubType(LTH.getType("struct.Base"), LTH.getType("struct.Child")), - true); - - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Base")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Child")).size(), 1U); - auto BaseReachable = LTH.getSubTypes(LTH.getType("struct.Base")); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Base")), true); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Child")), true); - auto ChildReachable = LTH.getSubTypes(LTH.getType("struct.Child")); - EXPECT_EQ(ChildReachable.count(LTH.getType("struct.Child")), true); -} - -TEST(LTHTest, BasicTHReconstruction_5) { - LLVMProjectIRDB IRDB({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_5_cpp.ll"}); - LLVMTypeHierarchy LTH(IRDB); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Base")), true); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Child")), true); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.OtherBase")), true); - EXPECT_EQ(LTH.getAllTypes().size(), 3U); - EXPECT_EQ( - LTH.isSubType(LTH.getType("struct.Base"), LTH.getType("struct.Child")), - true); - EXPECT_EQ(LTH.isSubType(LTH.getType("struct.OtherBase"), - LTH.getType("struct.Child")), - true); - - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Base")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.OtherBase")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Child")).size(), 1U); - auto BaseReachable = LTH.getSubTypes(LTH.getType("struct.Base")); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Base")), true); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Child")), true); - auto OtherBaseReachable = LTH.getSubTypes(LTH.getType("struct.OtherBase")); - EXPECT_EQ(OtherBaseReachable.count(LTH.getType("struct.OtherBase")), true); - EXPECT_EQ(OtherBaseReachable.count(LTH.getType("struct.Child")), true); - auto ChildReachable = LTH.getSubTypes(LTH.getType("struct.Child")); - EXPECT_EQ(ChildReachable.count(LTH.getType("struct.Child")), true); -} - -TEST(LTHTest, BasicTHReconstruction_6) { - LLVMProjectIRDB IRDB({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_12_cpp.ll"}); - LLVMTypeHierarchy LTH(IRDB); - EXPECT_EQ(LTH.hasType(LTH.getType("class.Base")), true); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Child")), true); - EXPECT_EQ(LTH.getAllTypes().size(), 2U); - EXPECT_EQ( - LTH.isSubType(LTH.getType("class.Base"), LTH.getType("struct.Child")), - true); - - EXPECT_EQ(LTH.getSubTypes(LTH.getType("class.Base")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Child")).size(), 1U); - auto BaseReachable = LTH.getSubTypes(LTH.getType("class.Base")); - EXPECT_EQ(BaseReachable.count(LTH.getType("class.Base")), true); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Child")), true); - auto ChildReachable = LTH.getSubTypes(LTH.getType("struct.Child")); - EXPECT_EQ(ChildReachable.count(LTH.getType("struct.Child")), true); -} - -TEST(LTHTest, BasicTHReconstruction_7) { - LLVMProjectIRDB IRDB({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_11_cpp.ll"}); - LLVMTypeHierarchy LTH(IRDB); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Base")), true); - EXPECT_EQ(LTH.hasType(LTH.getType("struct.Child")), true); - EXPECT_EQ(LTH.getAllTypes().size(), 2U); - EXPECT_EQ( - LTH.isSubType(LTH.getType("struct.Base"), LTH.getType("struct.Child")), - true); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Base")).size(), 2U); - EXPECT_EQ(LTH.getSubTypes(LTH.getType("struct.Child")).size(), 1U); - auto BaseReachable = LTH.getSubTypes(LTH.getType("struct.Base")); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Base")), true); - EXPECT_EQ(BaseReachable.count(LTH.getType("struct.Child")), true); - auto ChildReachable = LTH.getSubTypes(LTH.getType("struct.Child")); - EXPECT_EQ(ChildReachable.count(LTH.getType("struct.Child")), true); -} - -TEST(LTHTest, TransitivelyReachableTypes) { - LLVMProjectIRDB IRDB1({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_1_cpp.ll"}); - LLVMProjectIRDB IRDB2({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_7_cpp.ll"}); - LLVMProjectIRDB IRDB3({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_8_cpp.ll"}); - LLVMProjectIRDB IRDB4({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_9_cpp.ll"}); - LLVMProjectIRDB IRDB5({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_10_cpp.ll"}); - // Creates an empty type hierarchy - LLVMTypeHierarchy TH1(IRDB1); - LLVMTypeHierarchy TH2(IRDB2); - LLVMTypeHierarchy TH3(IRDB3); - LLVMTypeHierarchy TH4(IRDB4); - LLVMTypeHierarchy TH5(IRDB5); - - auto ReachableTypesBase1 = TH1.getSubTypes(TH1.getType("struct.Base")); - auto ReachableTypesChild1 = TH1.getSubTypes(TH1.getType("struct.Child")); - - auto ReachableTypesA2 = TH2.getSubTypes(TH2.getType("struct.A")); - auto ReachableTypesB2 = TH2.getSubTypes(TH2.getType("struct.B")); - auto ReachableTypesC2 = TH2.getSubTypes(TH2.getType("struct.C")); - auto ReachableTypesD2 = TH2.getSubTypes(TH2.getType("struct.D")); - auto ReachableTypesX2 = TH2.getSubTypes(TH2.getType("struct.X")); - auto ReachableTypesY2 = TH2.getSubTypes(TH2.getType("struct.Y")); - auto ReachableTypesZ2 = TH2.getSubTypes(TH2.getType("struct.Z")); - - auto ReachableTypesBase3 = TH3.getSubTypes(TH3.getType("struct.Base")); - auto ReachableTypesChild3 = TH3.getSubTypes(TH3.getType("struct.Child")); - auto ReachableTypesNonvirtualclass3 = - TH3.getSubTypes(TH3.getType("class.NonvirtualClass")); - auto ReachableTypesNonvirtualstruct3 = - TH3.getSubTypes(TH3.getType("struct.NonvirtualStruct")); - - auto ReachableTypesBase4 = TH4.getSubTypes(TH4.getType("struct.Base")); - auto ReachableTypesChild4 = TH4.getSubTypes(TH4.getType("struct.Child")); - - auto ReachableTypesBase5 = TH5.getSubTypes(TH5.getType("struct.Base")); - auto ReachableTypesChild5 = TH5.getSubTypes(TH5.getType("struct.Child")); - - // Will be way less dangerous to have an interface (like a map) between the - // llvm given name of class & struct (i.e. struct.Base.base ...) and the name - // inside phasar (i.e. just Base) and never work with the llvm name inside - // phasar - ASSERT_TRUE(ReachableTypesBase1.count(TH1.getType("struct.Base"))); - ASSERT_TRUE(ReachableTypesBase1.count(TH1.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesBase1.size() == 2U); - ASSERT_FALSE(ReachableTypesChild1.count(TH1.getType("struct.Base"))); - ASSERT_TRUE(ReachableTypesChild1.count(TH1.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesChild1.size() == 1U); - - ASSERT_TRUE(ReachableTypesA2.count(TH2.getType("struct.A"))); - ASSERT_TRUE(ReachableTypesA2.count(TH2.getType("struct.B"))); - ASSERT_TRUE(ReachableTypesA2.count(TH2.getType("struct.C"))); - ASSERT_TRUE(ReachableTypesA2.count(TH2.getType("struct.D"))); - ASSERT_TRUE(ReachableTypesA2.count(TH2.getType("struct.Z"))); - ASSERT_TRUE(ReachableTypesA2.size() == 5U); - ASSERT_TRUE(ReachableTypesB2.count(TH2.getType("struct.B"))); - ASSERT_TRUE(ReachableTypesB2.count(TH2.getType("struct.D"))); - ASSERT_TRUE(ReachableTypesB2.size() == 2U); - ASSERT_TRUE(ReachableTypesC2.count(TH2.getType("struct.C"))); - ASSERT_TRUE(ReachableTypesC2.count(TH2.getType("struct.Z"))); - ASSERT_TRUE(ReachableTypesC2.size() == 2U); - ASSERT_TRUE(ReachableTypesD2.count(TH2.getType("struct.D"))); - ASSERT_TRUE(ReachableTypesD2.size() == 1U); - ASSERT_TRUE(ReachableTypesX2.count(TH2.getType("struct.X"))); - ASSERT_TRUE(ReachableTypesX2.count(TH2.getType("struct.Y"))); - ASSERT_TRUE(ReachableTypesX2.count(TH2.getType("struct.Z"))); - ASSERT_TRUE(ReachableTypesX2.size() == 3U); - ASSERT_TRUE(ReachableTypesY2.count(TH2.getType("struct.Y"))); - ASSERT_TRUE(ReachableTypesY2.count(TH2.getType("struct.Z"))); - ASSERT_TRUE(ReachableTypesY2.size() == 2U); - ASSERT_TRUE(ReachableTypesZ2.count(TH2.getType("struct.Z"))); - ASSERT_TRUE(ReachableTypesZ2.size() == 1U); - - ASSERT_TRUE(ReachableTypesBase3.count(TH3.getType("struct.Base"))); - ASSERT_TRUE(ReachableTypesBase3.count(TH3.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesBase3.size() == 2U); - ASSERT_TRUE(ReachableTypesChild3.count(TH3.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesChild3.size() == 1U); - ASSERT_TRUE(ReachableTypesNonvirtualclass3.count( - TH3.getType("class.NonvirtualClass"))); - ASSERT_TRUE(ReachableTypesNonvirtualclass3.size() == 1U); - ASSERT_TRUE(ReachableTypesNonvirtualstruct3.count( - TH3.getType("struct.NonvirtualStruct"))); - ASSERT_TRUE(ReachableTypesNonvirtualstruct3.size() == 1U); - - ASSERT_TRUE(ReachableTypesBase4.count(TH4.getType("struct.Base.base"))); - ASSERT_TRUE(ReachableTypesBase4.count(TH4.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesBase4.size() == 2U); - ASSERT_TRUE(ReachableTypesChild4.count(TH4.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesChild4.size() == 1U); - - ASSERT_TRUE(ReachableTypesBase5.count(TH5.getType("struct.Base"))); - ASSERT_TRUE(ReachableTypesBase5.count(TH5.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesBase5.size() == 2U); - ASSERT_TRUE(ReachableTypesChild5.count(TH5.getType("struct.Child"))); - ASSERT_TRUE(ReachableTypesChild5.size() == 1U); -} - -// TEST(LTHTest, HandleLoadAndPrintOfNonEmptyGraph) { -// LLVMProjectIRDB IRDB( -// {pathToLLFiles + "type_hierarchies/type_hierarchy_1_cpp.ll"}); -// LLVMTypeHierarchy TH(IRDB); -// TH.print(llvm::outs()); -// // std::ostringstream oss; -// // // Write empty LTH graph as dot to string -// // TH.printGraphAsDot(oss); -// // oss.flush(); -// // llvm::outs() << oss.str() << std::endl; -// // std::string dot = oss.str(); -// // // Reconstruct a LTH graph from the created dot file -// // std::istringstream iss(dot); -// // LLVMTypeHierarchy::bidigraph_t G = -// // LLVMTypeHierarchy::loadGraphFormDot(iss); boost::dynamic_properties -// dp; -// // dp.property("node_id", get(&LLVMTypeHierarchy::VertexProperties::name, -// // G)); std::ostringstream oss2; boost::write_graphviz_dp(oss2, G, dp); -// // oss2.flush(); -// // llvm::outs() << oss2.str() << std::endl; -// // ASSERT_TRUE(boost::isomorphism(G, TH.TypeGraph)); -// } - -// // TEST(LTHTest, HandleLoadAndPrintOfEmptyGraph) { -// // LLVMProjectIRDB IRDB({pathToLLFiles + -// // "taint_analysis/growing_example_cpp.ll"}); LLVMTypeHierarchy TH(IRDB); -// // std::ostringstream oss; -// // // Write empty LTH graph as dot to string -// // TH.printGraphAsDot(oss); -// // oss.flush(); -// // std::string dot = oss.str(); -// // // Reconstruct a LTH graph from the created dot file -// // std::istringstream iss(dot); -// // LLVMTypeHierarchy::bidigraph_t G = -// // LLVMTypeHierarchy::loadGraphFormDot(iss); boost::dynamic_properties dp; -// // dp.property("node_id", get(&LLVMTypeHierarchy::VertexProperties::name, -// G)); -// // std::ostringstream oss2; -// // boost::write_graphviz_dp(oss2, G, dp); -// // oss2.flush(); -// // ASSERT_EQ(oss.str(), oss2.str()); -// // } - -// // TEST(LTHTest, HandleMerge_1) { -// // LLVMProjectIRDB IRDB( -// // {pathToLLFiles + "type_hierarchies/type_hierarchy_12_cpp.ll", -// // pathToLLFiles + "type_hierarchies/type_hierarchy_12_b_cpp.ll"}); -// // LLVMTypeHierarchy TH1(*IRDB.getModule( -// // pathToLLFiles + "type_hierarchies/type_hierarchy_12_cpp.ll")); -// // LLVMTypeHierarchy TH2(*IRDB.getModule( -// // pathToLLFiles + "type_hierarchies/type_hierarchy_12_b_cpp.ll")); -// // TH1.mergeWith(TH2); -// // TH1.print(); -// // EXPECT_TRUE(TH1.hasType(LTH.getType("class.Base"))); -// // EXPECT_TRUE(TH1.hasType(LTH.getType("struct.Child"))); -// // EXPECT_TRUE(TH1.hasType("struct.ChildsChild")); -// // EXPECT_EQ(TH1.getNumTypes(), 3); -// // EXPECT_TRUE( -// // TH1.isSubType(LTH.getType("class.Base"), -// LTH.getType("struct.Child"))); -// // EXPECT_TRUE(TH1.isSubType(LTH.getType("class.Base"), -// // "struct.ChildsChild")); -// // EXPECT_TRUE(TH1.isSubType(LTH.getType("struct.Child"), -// // "struct.ChildsChild")); EXPECT_TRUE( -// // TH1.isSuperType(LTH.getType("struct.Child"), -// // LTH.getType("class.Base"))); -// // EXPECT_TRUE( -// // TH1.isSuperType("struct.ChildsChild", LTH.getType("struct.Child"))); -// // EXPECT_TRUE(TH1.isSuperType("struct.ChildsChild", -// // LTH.getType("class.Base"))); -// // EXPECT_TRUE(TH1.hasVFTable(LTH.getType("class.Base"))); -// // EXPECT_TRUE(TH1.hasVFTable(LTH.getType("struct.Child"))); -// // EXPECT_TRUE(TH1.hasVFTable("struct.ChildsChild")); -// // EXPECT_EQ(TH1.getVTableEntry(LTH.getType("class.Base"), 0), -// // "_ZN4Base3fooEv"); -// // EXPECT_EQ(TH1.getVTableEntry(LTH.getType("struct.Child"), 0), -// // "_ZN5Child3fooEv"); -// // EXPECT_EQ(TH1.getVTableEntry("struct.ChildsChild", 0), -// // "_ZN11ChildsChild3fooEv"); -// // EXPECT_EQ(TH1.getNumVTableEntries(LTH.getType("class.Base")), 1); -// // EXPECT_EQ(TH1.getNumVTableEntries(LTH.getType("struct.Child")), 1); -// // EXPECT_EQ(TH1.getNumVTableEntries("struct.ChildsChild"), 1); -// // EXPECT_EQ(TH1.getReachableSuperTypes(LTH.getType("class.Base")).size(), -// 3U); -// // EXPECT_EQ(TH1.getReachableSuperTypes(LTH.getType("struct.Child")).size(), -// // 2U); EXPECT_EQ(TH1.getReachableSuperTypes("struct.ChildsChild").size(), -// 1U); -// // auto BaseReachable = -// TH1.getReachableSuperTypes(LTH.getType("class.Base")); -// // EXPECT_TRUE(BaseReachable.count(LTH.getType("class.Base"))); -// // EXPECT_TRUE(BaseReachable.count(LTH.getType("struct.Child"))); -// // EXPECT_TRUE(BaseReachable.count("struct.ChildsChild")); -// // auto ChildReachable = -// // TH1.getReachableSuperTypes(LTH.getType("struct.Child")); -// // EXPECT_TRUE(ChildReachable.count(LTH.getType("struct.Child"))); -// // EXPECT_TRUE(ChildReachable.count("struct.ChildsChild")); -// // auto ChildsChildReachable = -// // TH1.getReachableSuperTypes("struct.ChildsChild"); -// // EXPECT_TRUE(ChildsChildReachable.count("struct.ChildsChild")); -// // } - -// Failing test case -PHASAR_SKIP_TEST(TEST(LTHTest, HandleSTLString) { - // If we use libcxx this won't work since internal implementation is different - LIBCPP_GTEST_SKIP; - - LLVMProjectIRDB IRDB({unittest::PathToLLTestFiles + - "type_hierarchies/type_hierarchy_13_cpp.ll"}); - LLVMTypeHierarchy TH(IRDB); - // NOTE: Even if using libstdc++, depending on the version the generated IR is - // different; so, we cannot assert on the number of types here - // EXPECT_EQ(TH.getAllTypes().size(), 7U); - EXPECT_TRUE(TH.hasType(TH.getType("class.std::__cxx11::basic_string"))); - EXPECT_TRUE(TH.hasType( - TH.getType("struct.std::__cxx11::basic_string::_Alloc_hider"))); - EXPECT_TRUE(TH.hasType(TH.getType("union.anon"))); - EXPECT_TRUE(TH.hasType(TH.getType("class.std::allocator"))); - // (virtual) inheritance is not used in STL types - EXPECT_FALSE(TH.isSubType( - TH.getType( - "struct.std::__cxx11::basic_string, " - "std::allocator >::_Alloc_hider"), - TH.getType("class.std::__cxx11::basic_string"))); - EXPECT_FALSE(TH.isSubType(TH.getType("union.anon"), - TH.getType("class.std::__cxx11::basic_string"))); -}) - -} // namespace psr - -#pragma GCC diagnostic pop - -int main(int Argc, char **Argv) { - ::testing::InitGoogleTest(&Argc, Argv); - auto Res = RUN_ALL_TESTS(); - llvm::llvm_shutdown(); - return Res; -} From 6eee88f8e91a456929aeffe3bc4e1d427584dbd2 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Tue, 28 Oct 2025 19:03:36 +0100 Subject: [PATCH 2/4] Remove the dependency to SQLite3 + use BUILD_PHASAR_CLANG=OFF by default --- BreakingChanges.md | 3 +- CMakeLists.txt | 10 +- Config.cmake.in | 4 - cmake/add_llvm.cmake | 2 +- conanfile.py | 4 - lib/CMakeLists.txt | 2 +- lib/DB/CMakeLists.txt | 8 +- lib/PhasarClang/CMakeLists.txt | 2 - unittests/CMakeLists.txt | 1 - unittests/DB/CMakeLists.txt | 9 -- unittests/DB/HexastoreTest.cpp | 274 -------------------------------- utils/InstallAptDependencies.sh | 2 +- 12 files changed, 8 insertions(+), 313 deletions(-) delete mode 100644 unittests/DB/CMakeLists.txt delete mode 100644 unittests/DB/HexastoreTest.cpp diff --git a/BreakingChanges.md b/BreakingChanges.md index 385ef3f33d..5ca01b4fad 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -9,7 +9,8 @@ - Removed `TypestateDescription::start()`. Instead apply `TypestateDescription::getNextState()` on `TypestateDescription::uninit()`. - Removed `LLVMProjectIRDB::getParsedIRModuleOrNull()`. Use `LLVMProjectIRDB::getParsedIRModuleOrErr()` instead. - Removed `DIBasedTypeHierarchy::isVTable()` and `DIBasedTypeHierarchy::removeVTablePrefix()`. Use the corresponding functions from `LLVMVFTableProvider` instead. - +- Removed the CMake variable `PHASAR_HAS_SQLITE` as we removed the dependency on sqlite3. +- The CMake Option `BUILD_PHASAR_CLANG` is no longer `ON` by default. ## v2510 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cf3198a04..ee36110bcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,14 +294,6 @@ else() set(GTEST_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include") endif() -# SQL -find_package(SQLite3) -if(SQLite3_FOUND) - set(PHASAR_HAS_SQLITE ON) -else() - set(PHASAR_HAS_SQLITE OFF) -endif() - option(USE_LLVM_FAT_LIB "Link against libLLVM.so instead of the individual LLVM libraries if possible (default is OFF; always on if BUILD_SHARED_LIBS is ON)" OFF) # LLVM @@ -350,7 +342,7 @@ else() endif() # Clang -option(BUILD_PHASAR_CLANG "Build the phasar_clang library (default is ON)" ON) +option(BUILD_PHASAR_CLANG "Build the phasar_clang library (default is OFF)" OFF) if(BUILD_PHASAR_CLANG) add_clang() endif() diff --git a/Config.cmake.in b/Config.cmake.in index 0af87e19b9..b64f86e8a7 100644 --- a/Config.cmake.in +++ b/Config.cmake.in @@ -15,15 +15,11 @@ find_dependency(LLVM ${PHASAR_LLVM_VERSION} REQUIRED CONFIG) 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) endif() -if(PHASAR_HAS_SQLITE) - find_dependency(SQLite3 REQUIRED) -endif() set(PHASAR_COMPONENTS utils diff --git a/cmake/add_llvm.cmake b/cmake/add_llvm.cmake index 5ec7e966bf..1cbc9cd637 100644 --- a/cmake/add_llvm.cmake +++ b/cmake/add_llvm.cmake @@ -62,7 +62,7 @@ macro(add_clang) if (USE_LLVM_FAT_LIB) find_library(CLANG_LIBRARY NAMES clang-cpp libclang-cpp HINTS ${LLVM_LIBRARY_DIRS}) else() - find_library(CLANG_LIBRARY NAMES clangCodeGen clangTooling HINTS ${LLVM_LIBRARY_DIRS}) + find_library(CLANG_LIBRARY NAMES clangTooling clangCodeGen HINTS ${LLVM_LIBRARY_DIRS}) endif() if(${CLANG_LIBRARY} STREQUAL "CLANG_LIBRARY-NOTFOUND") set(NEED_LIBCLANG_COMPONENT_LIBS ON) diff --git a/conanfile.py b/conanfile.py index af1dfe05bf..fe3b83919e 100644 --- a/conanfile.py +++ b/conanfile.py @@ -30,7 +30,6 @@ def node_labels(dot): "nlohmann_json_schema_validator": "json-schema-validator::json-schema-validator", "clangCodeGen": "clang::clangCodeGen", "clangTooling": "clang::clangTooling", - "SQLite::SQLite3": "sqlite3::sqlite3", } for row in dot: # e.g. "node0" [ label = "phasar\n(phasar::phasar)", shape = octagon ]; @@ -41,8 +40,6 @@ def node_labels(dot): if label.startswith("LLVM"): yield node, f"llvm-core::{label}" # XXX find_library adds direct filepath -> imho a flaw in current cmake files - elif label.endswith("libsqlite3.a"): - yield node, "sqlite3::sqlite3" elif label.endswith("libclang-cpp.so"): yield node, "clang::clang" elif label.endswith("libclangCodeGen.a"): @@ -229,7 +226,6 @@ def config_options(self): def requirements(self): self.requires("boost/[>1.72.0 <=1.86.0]") - self.requires("sqlite3/[>=3 <4]") self.requires(f"clang/{self.options.llvm_version}@secure-software-engineering", transitive_libs=True, transitive_headers=True) self.requires("nlohmann_json/3.11.3", transitive_headers=True) self.requires("json-schema-validator/2.3.0", transitive_libs=True, transitive_headers=True) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ab2eae3998..352bfb64c5 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -53,7 +53,7 @@ set(PHASAR_LINK_LIBS if(BUILD_PHASAR_CLANG) list(APPEND PHASAR_LINK_LIBS phasar_clang) endif() -if(SQLite3_FOUND) +if(TARGET phasar_db) list(APPEND PHASAR_LINK_LIBS phasar_db) endif() if(PHASAR_USE_SVF) diff --git a/lib/DB/CMakeLists.txt b/lib/DB/CMakeLists.txt index 5469d9933d..ce54af1160 100644 --- a/lib/DB/CMakeLists.txt +++ b/lib/DB/CMakeLists.txt @@ -1,6 +1,5 @@ -if(SQLite3_FOUND) - file(GLOB_RECURSE DB_SRC *.h *.cpp) - +file(GLOB_RECURSE DB_SRC *.h *.cpp) +if(PHASAR_BUILD_MODULES OR NOT "${DB_SRC}" STREQUAL "") add_phasar_library(phasar_db ${DB_SRC} @@ -10,9 +9,6 @@ if(SQLite3_FOUND) LLVM_LINK_COMPONENTS Support - LINK_PRIVATE - SQLite::SQLite3 - MODULE_FILES DB.cppm ) diff --git a/lib/PhasarClang/CMakeLists.txt b/lib/PhasarClang/CMakeLists.txt index 961953ae29..9af28cb997 100644 --- a/lib/PhasarClang/CMakeLists.txt +++ b/lib/PhasarClang/CMakeLists.txt @@ -1,7 +1,5 @@ file(GLOB_RECURSE PHASARCLANG_SRC *.h *.cpp) - - add_phasar_library(phasar_clang ${PHASARCLANG_SRC} LINKS diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 405738b1f8..abeba8e0a4 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -45,7 +45,6 @@ endfunction() include_directories(TestUtils) -add_subdirectory(DB) add_subdirectory(PhasarLLVM) add_subdirectory(Utils) if(BUILD_PHASAR_CLANG) diff --git a/unittests/DB/CMakeLists.txt b/unittests/DB/CMakeLists.txt deleted file mode 100644 index 6f6c3606b6..0000000000 --- a/unittests/DB/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# if(SQLite3_FOUND) -# set(DBSources -# HexastoreTest.cpp -# ) - -# foreach(TEST_SRC ${DBSources}) -# add_phasar_unittest(${TEST_SRC}) -# endforeach(TEST_SRC) -# endif() diff --git a/unittests/DB/HexastoreTest.cpp b/unittests/DB/HexastoreTest.cpp deleted file mode 100644 index 6ce20b23a7..0000000000 --- a/unittests/DB/HexastoreTest.cpp +++ /dev/null @@ -1,274 +0,0 @@ -#include "phasar/DB/Hexastore.h" - -#include "boost/graph/adjacency_list.hpp" -#include "boost/graph/graph_utility.hpp" -#include "boost/graph/isomorphism.hpp" -#include "gtest/gtest.h" - -#include - -using namespace psr; -using namespace std; - -TEST(HexastoreTest, QueryBlankFieldEntries) { - Hexastore H(""); - H.put({{"one", "", ""}}); - H.put({{"two", "", ""}}); - H.put({{"", "three", ""}}); - H.put({{"one", "", "four"}}); - - // query results - HSResult FirstRes("one", "", ""); - HSResult SecondRes("one", "", "four"); - - auto Result = H.get({{"one", "", ""}}); - ASSERT_EQ(Result.size(), 1U); - ASSERT_EQ(Result[0], FirstRes); - - Result = H.get({{"one", "?", "?"}}); - ASSERT_EQ(Result.size(), 2U); - ASSERT_EQ(Result[0], FirstRes); - ASSERT_EQ(Result[1], SecondRes); -} - -TEST(HexastoreTest, AllQueryTypes) { - Hexastore H(""); - H.put({{"mary", "likes", "hexastores"}}); - H.put({{"mary", "likes", "apples"}}); - H.put({{"mary", "hates", "oranges"}}); - H.put({{"peter", "likes", "apples"}}); - H.put({{"peter", "hates", "hexastores"}}); - H.put({{"frank", "admires", "bananas"}}); - - std::vector GroundTruth; - GroundTruth.emplace_back(HSResult("mary", "likes", "hexastores")); - GroundTruth.emplace_back(HSResult("mary", "likes", "apples")); - GroundTruth.emplace_back(HSResult("mary", "hates", "oranges")); - GroundTruth.emplace_back(HSResult("peter", "likes", "apples")); - GroundTruth.emplace_back(HSResult("peter", "hates", "hexastores")); - GroundTruth.emplace_back(HSResult("frank", "admires", "bananas")); - - // Does peter hate hexastores? (SPO query in 'spo' tables) - auto Result = H.get({{"peter", "hates", "hexastores"}}); - ASSERT_EQ(Result.size(), 1U); - ASSERT_EQ(Result[0], GroundTruth[4]); - - // What does Mary like? (SPX query in 'spo' tables) - Result = H.get({{"mary", "likes", "?"}}); - ASSERT_EQ(Result.size(), 2U); - ASSERT_EQ(Result[0], GroundTruth[0]); - ASSERT_EQ(Result[1], GroundTruth[1]); - - // What's Franks opinion on bananas? (SXO query in 'sop' tables) - Result = H.get({{"frank", "?", "bananas"}}); - ASSERT_EQ(Result.size(), 1U); - ASSERT_EQ(Result[0], GroundTruth[5]); - - // Who likes apples? (XPO query in 'pos' tables) - Result = H.get({{"?", "likes", "apples"}}); - ASSERT_EQ(Result.size(), 2U); - ASSERT_EQ(Result[0], GroundTruth[1]); - ASSERT_EQ(Result[1], GroundTruth[3]); - - // What's Marry up to? (SXX query in 'spo' tables) - Result = H.get({{"mary", "?", "?"}}); - ASSERT_EQ(Result.size(), 3U); - ASSERT_EQ(Result[0], GroundTruth[0]); - ASSERT_EQ(Result[1], GroundTruth[1]); - ASSERT_EQ(Result[2], GroundTruth[2]); - - // Who likes what? (XPX query in 'pso' tables) - Result = H.get({{"?", "likes", "?"}}); - ASSERT_EQ(Result.size(), 3U); - ASSERT_EQ(Result[0], GroundTruth[0]); - ASSERT_EQ(Result[1], GroundTruth[1]); - ASSERT_EQ(Result[2], GroundTruth[3]); - - // Who has what opinion on apples? (XXO query in 'osp' tables) - Result = H.get({{"?", "?", "apples"}}); - ASSERT_EQ(Result.size(), 2U); - ASSERT_EQ(Result[0], GroundTruth[1]); - ASSERT_EQ(Result[1], GroundTruth[3]); - - // All data in the Hexastore? (XXX query in 'spo' tables) - Result = H.get({{"?", "?", "?"}}); - ASSERT_EQ(Result.size(), 6U); - ASSERT_EQ(Result, GroundTruth); -} - -TEST(HexastoreTest, StoreGraphNoEdgeLabels) { - struct Vertex { - string Name; - Vertex() = default; - Vertex(string Name) : Name(std::move(Name)) {} - }; - struct Edge { - string EdgeName; - Edge() = default; - Edge(string Label) : EdgeName(std::move(Label)) {} - }; - - using graph_t = boost::adjacency_list; - using vertex_t = boost::graph_traits::vertex_descriptor; - typename boost::graph_traits::edge_iterator EiStart; - - typename boost::graph_traits::edge_iterator EEnd; - - // graph with unlabeled edges - graph_t G; - - vertex_t V1 = boost::add_vertex(G); - G[V1].Name = "A"; - vertex_t V2 = boost::add_vertex(G); - G[V2].Name = "B"; - vertex_t V3 = boost::add_vertex(G); - G[V3].Name = "C"; - vertex_t V4 = boost::add_vertex(G); - G[V4].Name = "D"; - vertex_t V5 = boost::add_vertex(G); - G[V5].Name = "X"; - vertex_t V6 = boost::add_vertex(G); - G[V6].Name = "Y"; - vertex_t V7 = boost::add_vertex(G); - G[V7].Name = "Z"; - - boost::add_edge(V2, V1, G); - boost::add_edge(V3, V1, G); - boost::add_edge(V7, V3, G); - boost::add_edge(V7, V6, G); - boost::add_edge(V6, V5, G); - boost::add_edge(V4, V2, G); - - // llvm::outs() << "Graph G:" << std::endl; - // boost::print_graph(G, boost::get(&Vertex::name, G)); - - Hexastore HS(""); - - // serialize graph G - for (tie(EiStart, EEnd) = boost::edges(G); EiStart != EEnd; ++EiStart) { - auto Source = boost::source(*EiStart, G); - auto Target = boost::target(*EiStart, G); - HS.put({{G[Source].Name, "no label", G[Target].Name}}); - } - - // de-serialize graph G as graph H" - graph_t H; - set Recognized; - map Vertices; - - vector ResultSet = HS.get({{"?", "no label", "?"}}, 20); - - for (const auto &Entry : ResultSet) { - if (Recognized.find(Entry.Subject) == Recognized.end()) { - Vertices[Entry.Subject] = boost::add_vertex(H); - H[Vertices[Entry.Subject]].Name = Entry.Subject; - } - if (Recognized.find(Entry.Object) == Recognized.end()) { - Vertices[Entry.Object] = boost::add_vertex(H); - H[Vertices[Entry.Object]].Name = Entry.Object; - } - boost::add_edge(Vertices[Entry.Subject], Vertices[Entry.Object], H); - Recognized.insert(Entry.Subject); - Recognized.insert(Entry.Object); - } - - // boost::print_graph(H, boost::get(&Vertex::name, H)); - ASSERT_TRUE(boost::isomorphism(G, H)); -} - -TEST(HexastoreTest, StoreGraphWithEdgeLabels) { - struct Vertex { - string Name; - Vertex() = default; - Vertex(string Name) : Name(std::move(Name)) {} - }; - struct Edge { - string EdgeName; - Edge() = default; - Edge(string Label) : EdgeName(std::move(Label)) {} - }; - - using graph_t = boost::adjacency_list; - using vertex_t = boost::graph_traits::vertex_descriptor; - typename boost::graph_traits::edge_iterator EiStart; - - typename boost::graph_traits::edge_iterator EEnd; - - // graph with labeled edges - graph_t I; - - vertex_t W1 = boost::add_vertex(I); - I[W1].Name = "A"; - vertex_t W2 = boost::add_vertex(I); - I[W2].Name = "B"; - vertex_t W3 = boost::add_vertex(I); - I[W3].Name = "C"; - vertex_t W4 = boost::add_vertex(I); - I[W4].Name = "D"; - vertex_t W5 = boost::add_vertex(I); - I[W5].Name = "X"; - vertex_t W6 = boost::add_vertex(I); - I[W6].Name = "Y"; - vertex_t W7 = boost::add_vertex(I); - I[W7].Name = "Z"; - - boost::add_edge(W2, W1, Edge("one"), I); - boost::add_edge(W3, W1, Edge("two"), I); - boost::add_edge(W7, W3, Edge("three"), I); - boost::add_edge(W7, W6, Edge("four"), I); - boost::add_edge(W6, W5, Edge("five"), I); - boost::add_edge(W4, W2, Edge("six"), I); - - // llvm::outs() << "Graph I:" << std::endl; - // boost::print_graph(I, boost::get(&Vertex::name, I)); - // for (tie(ei_start, e_end) = boost::edges(I); ei_start != e_end; ++ei_start) - // { - // // auto source = boost::source(*ei_start, I); - // // auto target = boost::target(*ei_start, I); - // cout << boost::get(&Edge::edge_name, I, *ei_start) << endl; - // } - - Hexastore HS(""); - - // serialize graph I - for (tie(EiStart, EEnd) = boost::edges(I); EiStart != EEnd; ++EiStart) { - auto Source = boost::source(*EiStart, I); - auto Target = boost::target(*EiStart, I); - string Edge = boost::get(&Edge::EdgeName, I, *EiStart); - HS.put({{I[Source].Name, Edge, I[Target].Name}}); - } - - // de-serialize graph I as graph J - graph_t J; - set RecognizedVertices; - map Vertices; - vector HsiRes = HS.get({{"?", "?", "?"}}, 10); - for (const auto &Entry : HsiRes) { - if (RecognizedVertices.find(Entry.Subject) == RecognizedVertices.end()) { - Vertices[Entry.Subject] = boost::add_vertex(J); - J[Vertices[Entry.Subject]].Name = Entry.Subject; - } - if (RecognizedVertices.find(Entry.Object) == RecognizedVertices.end()) { - Vertices[Entry.Object] = boost::add_vertex(J); - J[Vertices[Entry.Object]].Name = Entry.Object; - } - RecognizedVertices.insert(Entry.Subject); - RecognizedVertices.insert(Entry.Object); - boost::add_edge(Vertices[Entry.Subject], Vertices[Entry.Object], - Edge(Entry.Predicate), J); - } - - // boost::print_graph(J, boost::get(&Vertex::name, J)); - // for (tie(ei_start, e_end) = boost::edges(J); ei_start != e_end; ++ei_start) - // { - // cout << boost::get(&Edge::edge_name, J, *ei_start) << endl; - // } - ASSERT_TRUE(boost::isomorphism(I, J)); -} - -int main(int Argc, char **Argv) { - ::testing::InitGoogleTest(&Argc, Argv); - return RUN_ALL_TESTS(); -} diff --git a/utils/InstallAptDependencies.sh b/utils/InstallAptDependencies.sh index 8317271ff2..317454b1b0 100755 --- a/utils/InstallAptDependencies.sh +++ b/utils/InstallAptDependencies.sh @@ -26,7 +26,7 @@ additional_dependencies=("$@") git ca-certificates build-essential cmake ninja-build # build "clang-$LLVM_IR_VERSION" # compiler for IR "libclang-rt-$LLVM_IR_VERSION-dev" # ASAN - libsqlite3-dev libz3-dev libssl-dev "libclang-$LLVM_IR_VERSION-dev" "libclang-common-$LLVM_IR_VERSION-dev" # optional build deps + libz3-dev libssl-dev "libclang-$LLVM_IR_VERSION-dev" "libclang-common-$LLVM_IR_VERSION-dev" # optional build deps libboost-graph-dev zlib1g-dev libzstd-dev "llvm-$LLVM_IR_VERSION-dev" # build deps ) From eb7de56652becb0d9d5b6b27e4daf0a514e6d82f Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Tue, 28 Oct 2025 19:12:32 +0100 Subject: [PATCH 3/4] Remove boost --- BreakingChanges.md | 3 + CMakeLists.txt | 3 - Config.cmake.in | 1 - bootstrap.sh | 70 +------------------ conanfile.py | 1 - include/phasar/Utils/GraphTraits.h | 59 ++++++++-------- lib/CMakeLists.txt | 2 - lib/Config/CMakeLists.txt | 3 - .../DataFlow/IfdsIde/CMakeLists.txt | 3 - lib/PhasarLLVM/Pointer/CMakeLists.txt | 3 - lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt | 3 - lib/PhasarPass/CMakeLists.txt | 1 - utils/InstallAptDependencies.sh | 2 +- 13 files changed, 35 insertions(+), 119 deletions(-) diff --git a/BreakingChanges.md b/BreakingChanges.md index 5ca01b4fad..732ab9474c 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -11,6 +11,9 @@ - Removed `DIBasedTypeHierarchy::isVTable()` and `DIBasedTypeHierarchy::removeVTablePrefix()`. Use the corresponding functions from `LLVMVFTableProvider` instead. - Removed the CMake variable `PHASAR_HAS_SQLITE` as we removed the dependency on sqlite3. - The CMake Option `BUILD_PHASAR_CLANG` is no longer `ON` by default. +- Removed the dependency to boost: + - Removed the boost-related command-line options in `bootstrap.sh` + - `InstallAptDependencies.sh` no longer installs boost (so, boost is also no longer built into PhASAR's Docker containers) ## v2510 diff --git a/CMakeLists.txt b/CMakeLists.txt index ee36110bcb..945e85aec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,9 +264,6 @@ endif() # Threads find_package(Threads) -# Boost -find_package(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG) - # Disable clang-tidy for the external projects set(CMAKE_CXX_CLANG_TIDY "") diff --git a/Config.cmake.in b/Config.cmake.in index b64f86e8a7..085a277031 100644 --- a/Config.cmake.in +++ b/Config.cmake.in @@ -9,7 +9,6 @@ include (CMakeFindDependencyMacro) set(PHASAR_LLVM_VERSION @PHASAR_LLVM_VERSION@) include("${CMAKE_CURRENT_LIST_DIR}/PhasarDepsExports.cmake") -find_dependency(Boost 1.65.1 COMPONENTS graph REQUIRED CONFIG) find_dependency(LLVM ${PHASAR_LLVM_VERSION} REQUIRED CONFIG) set(PHASAR_USE_LLVM_FAT_LIB @USE_LLVM_FAT_LIB@) diff --git a/bootstrap.sh b/bootstrap.sh index 9d0a911acc..1972f88eb6 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -23,8 +23,6 @@ function usage { echo -e "\t--unittest\t-u\t\t- Build and run PhASARs unit-tests (default is true)" echo -e "\t--install\t\t\t- Install PhASAR system-wide after building (default is false)" echo -e "\t--help\t\t-h\t\t- Display this help message" - echo -e "\t-DBOOST_DIR=\t\t- The directory where boost should be installed (optional)" - echo -e "\t-DBOOST_VERSION=\t- The desired boost version to install (optional)" echo -e "\t-DCMAKE_BUILD_TYPE=\t- The build mode for building PhASAR. One of {Debug, RelWithDebInfo, Release} (default is Release)" echo -e "\t-DPHASAR_INSTALL_DIR=\t- The folder where to install PhASAR if --install is specified (default is ${PHASAR_INSTALL_DIR})" echo -e "\t-DLLVM_INSTALL_DIR=\t- The folder where to install LLVM if --install is specified (default is ${LLVM_INSTALL_DIR})" @@ -48,24 +46,6 @@ case $key in DO_UNIT_TEST=true shift # past argument ;; - -DBOOST_DIR) - DESIRED_BOOST_DIR="$2" - shift # past argument - shift # past value - ;; - -DBOOST_DIR=*) - DESIRED_BOOST_DIR="${key#*=}" - shift # past argument=value - ;; - -DBOOST_VERSION) - DESIRED_BOOST_VERSION="$2" - shift # past argument - shift # past value - ;; - -DBOOST_VERSION=*) - DESIRED_BOOST_VERSION="${key#*=}" - shift # past argument=value - ;; -DCMAKE_BUILD_TYPE=*) BUILD_TYPE="${key#*=}" shift # past argument=value @@ -113,54 +93,6 @@ else ./utils/InstallAptDependencies.sh fi -if [ ! -z "${DESIRED_BOOST_DIR}" ]; then - BOOST_PARAMS="-DBOOST_ROOT=${DESIRED_BOOST_DIR}" -else -# New way of installing boost: -# Check whether we have the required boost packages installed - { BOOST_VERSION=$(echo -e '#include \nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"'); } || true - - if [ -z "$BOOST_VERSION" ] ;then - if [ -x "$(command -v pacman)" ]; then - yes | sudo pacman -Syu --needed boost-libs boost - else - if [ -z "$DESIRED_BOOST_VERSION" ] ;then - sudo apt-get install libboost-graph-dev -y - else - # DESIRED_BOOST_VERSION in form d.d, i.e. 1.65 (this is the latest version I found in the apt repo) - sudo apt-get install "libboost${DESIRED_BOOST_VERSION}-graph-dev" -y - fi - #verify installation - BOOST_VERSION=$(echo -e '#include \nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"') - if [ -z "$BOOST_VERSION" ] ;then - echo "Failed installing boost $DESIRED_BOOST_VERSION" - exit 1 - else - echo "Successfully installed boost v${BOOST_VERSION//_/.}" - fi - fi - else - echo "Already installed boost version ${BOOST_VERSION//_/.}" - if [ -x "$(command -v apt)" ]; then - DESIRED_BOOST_VERSION=${BOOST_VERSION//_/.} - # install missing packages if necessary - boostlibnames=("libboost-graph") - additional_boost_libs=() - for boost_lib in "${boostlibnames[@]}"; do - dpkg -s "$boost_lib${DESIRED_BOOST_VERSION}" >/dev/null 2>&1 || - dpkg -s "$boost_lib${DESIRED_BOOST_VERSION}.0" >/dev/null 2>&1 || - additional_boost_libs+=("$boost_lib${DESIRED_BOOST_VERSION}") || - additional_boost_libs+=("$boost_lib${DESIRED_BOOST_VERSION}.0") - dpkg -s "${boost_lib}-dev" >/dev/null 2>&1 || additional_boost_libs+=("${boost_lib}-dev") - done - if [ ${#additional_boost_libs[@]} -gt 0 ] ;then - echo "Installing additional ${#additional_boost_libs[@]} boost packages: ${additional_boost_libs[*]}" - sudo apt-get install "${additional_boost_libs[@]}" -y || true - fi - fi - fi -fi - # installing LLVM tmp_dir=$(mktemp -d "llvm-build.XXXXXXXX" --tmpdir) ./utils/install-llvm.sh "${NUM_THREADS}" "${tmp_dir}" "${LLVM_INSTALL_DIR}" ${LLVM_RELEASE} @@ -182,7 +114,7 @@ export CXX=${LLVM_INSTALL_DIR}/bin/clang++ mkdir -p "${PHASAR_DIR}"/build safe_cd "${PHASAR_DIR}"/build -cmake -G Ninja -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "${BOOST_PARAMS}" -DPHASAR_BUILD_UNITTESTS="${DO_UNIT_TEST}" "${LLVM_PARAMS}" "${PHASAR_DIR}" +cmake -G Ninja -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DPHASAR_BUILD_UNITTESTS="${DO_UNIT_TEST}" "${LLVM_PARAMS}" "${PHASAR_DIR}" cmake --build . -j "${NUM_THREADS}" echo "phasar successfully built" diff --git a/conanfile.py b/conanfile.py index fe3b83919e..a975138817 100644 --- a/conanfile.py +++ b/conanfile.py @@ -225,7 +225,6 @@ def config_options(self): self.options.rm_safe("fPIC") def requirements(self): - self.requires("boost/[>1.72.0 <=1.86.0]") self.requires(f"clang/{self.options.llvm_version}@secure-software-engineering", transitive_libs=True, transitive_headers=True) self.requires("nlohmann_json/3.11.3", transitive_headers=True) self.requires("json-schema-validator/2.3.0", transitive_libs=True, transitive_headers=True) diff --git a/include/phasar/Utils/GraphTraits.h b/include/phasar/Utils/GraphTraits.h index de96b9cc20..e0c21f33d6 100644 --- a/include/phasar/Utils/GraphTraits.h +++ b/include/phasar/Utils/GraphTraits.h @@ -25,11 +25,11 @@ namespace psr { -/// We aim to get rid of boost, so introduce a new GraphTraits class to replace -/// it. -/// This GraphTraits type should be specialized for each type that implements a -/// "graph". All the functionality should be reflected by the GraphTraits class. -/// Once moving to C++20, we have nice type-checking using concepts +/// We removed the dependency to boost, so introduce a new GraphTraits class to +/// replace it. This GraphTraits type should be specialized for each type that +/// implements a "graph". All the functionality should be reflected by the +/// GraphTraits class. Once moving to C++20, we have nice type-checking using +/// concepts template struct GraphTraits; #if __cplusplus >= 202002L @@ -55,36 +55,36 @@ concept is_graph_trait = requires(typename GraphTrait::graph_type &graph, { GraphTrait::Invalid } -> std::convertible_to; { GraphTrait::addNode(graph, val) - } -> std::convertible_to; - {GraphTrait::addEdge(graph, vtx, edge)}; + } -> std::convertible_to; + { GraphTrait::addEdge(graph, vtx, edge) }; { GraphTrait::outEdges(cgraph, vtx) - } -> psr::is_iterable_over_v; + } -> psr::is_iterable_over_v; { GraphTrait::outDegree(cgraph, vtx) } -> std::convertible_to; - {GraphTrait::dedupOutEdges(graph, vtx)}; + { GraphTrait::dedupOutEdges(graph, vtx) }; { GraphTrait::nodes(cgraph) - } -> psr::is_iterable_over_v; + } -> psr::is_iterable_over_v; { GraphTrait::vertices(cgraph) - } -> psr::is_iterable_over_v; + } -> psr::is_iterable_over_v; { GraphTrait::node(cgraph, vtx) - } -> std::convertible_to; + } -> std::convertible_to; { GraphTrait::size(cgraph) } -> std::convertible_to; - {GraphTrait::addRoot(graph, vtx)}; + { GraphTrait::addRoot(graph, vtx) }; { GraphTrait::roots(cgraph) - } -> psr::is_iterable_over_v; + } -> psr::is_iterable_over_v; { GraphTrait::pop(graph, vtx) } -> std::same_as; { GraphTrait::roots_size(cgraph) } -> std::convertible_to; { GraphTrait::target(edge) - } -> std::convertible_to; + } -> std::convertible_to; { GraphTrait::withEdgeTarget(edge, vtx) - } -> std::convertible_to; - {GraphTrait::weight(edge)}; + } -> std::convertible_to; + { GraphTrait::weight(edge) }; }; template @@ -94,22 +94,23 @@ concept is_graph = requires(Graph g) { }; template -concept is_reservable_graph_trait_v = is_graph_trait && - requires(typename GraphTrait::graph_type &g) { - {GraphTrait::reserve(g, size_t(0))}; -}; +concept is_reservable_graph_trait_v = + is_graph_trait && requires(typename GraphTrait::graph_type &g) { + { GraphTrait::reserve(g, size_t(0)) }; + }; template -concept is_removable_graph_trait_v = is_graph_trait && +concept is_removable_graph_trait_v = + is_graph_trait && requires(typename GraphTrait::graph_type &g, typename GraphTrait::vertex_t vtx, typename GraphTrait::edge_iterator edge_it, typename GraphTrait::roots_iterator root_it) { - typename GraphTrait::edge_iterator; - typename GraphTrait::roots_iterator; - {GraphTrait::removeEdge(g, vtx, edge_it)}; - {GraphTrait::removeRoot(g, root_it)}; -}; + typename GraphTrait::edge_iterator; + typename GraphTrait::roots_iterator; + { GraphTrait::removeEdge(g, vtx, edge_it) }; + { GraphTrait::removeRoot(g, root_it) }; + }; #else namespace detail { @@ -155,7 +156,7 @@ static constexpr bool is_removable_graph_trait_v = template std::decay_t reverseGraph(GraphTy &&G) #if __cplusplus >= 202002L - requires is_graph + requires is_graph #endif { std::decay_t Ret; @@ -193,7 +194,7 @@ template void printGraph(const GraphTy &G, llvm::raw_ostream &OS, llvm::StringRef Name = "", NodeTransform NodeToString = {}) #if __cplusplus >= 202002L - requires is_graph + requires is_graph #endif { using traits_t = GraphTraits; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 352bfb64c5..29d75fb21b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -65,8 +65,6 @@ add_phasar_library(phasar ${PHASAR_DYNLIB_KIND} LibPhasar.cpp LINKS ${PHASAR_LINK_LIBS} - LINK_PRIVATE - ${Boost_LIBRARIES} LLVM_LINK_COMPONENTS Core Support diff --git a/lib/Config/CMakeLists.txt b/lib/Config/CMakeLists.txt index 4c125ca131..ad3f2f3d17 100644 --- a/lib/Config/CMakeLists.txt +++ b/lib/Config/CMakeLists.txt @@ -6,9 +6,6 @@ add_phasar_library(phasar_config LINKS phasar_utils - LINK_PRIVATE - ${Boost_LIBRARIES} - LLVM_LINK_COMPONENTS Support diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt b/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt index 4c66687fb5..1045a52239 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/CMakeLists.txt @@ -17,9 +17,6 @@ add_phasar_library(phasar_llvm_ifdside Support Demangle - LINK_PRIVATE - ${Boost_LIBRARIES} - MODULE_FILES IfdsIde.cppm ) diff --git a/lib/PhasarLLVM/Pointer/CMakeLists.txt b/lib/PhasarLLVM/Pointer/CMakeLists.txt index f863a86046..2825505ba5 100644 --- a/lib/PhasarLLVM/Pointer/CMakeLists.txt +++ b/lib/PhasarLLVM/Pointer/CMakeLists.txt @@ -16,9 +16,6 @@ add_phasar_library(phasar_llvm_pointer Passes Demangle - LINK_PRIVATE - ${Boost_LIBRARIES} - MODULE_FILES Pointer.cppm ) diff --git a/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt b/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt index 2f9d48f4b6..cab60cecc5 100644 --- a/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt +++ b/lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt @@ -14,9 +14,6 @@ add_phasar_library(phasar_llvm_typehierarchy Support Analysis - LINK_PRIVATE - ${Boost_LIBRARIES} - MODULE_FILES TypeHierarchy.cppm ) diff --git a/lib/PhasarPass/CMakeLists.txt b/lib/PhasarPass/CMakeLists.txt index 19e02c7084..29ff6de6ef 100644 --- a/lib/PhasarPass/CMakeLists.txt +++ b/lib/PhasarPass/CMakeLists.txt @@ -24,7 +24,6 @@ add_phasar_library(phasar_pass LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT} - ${Boost_LIBRARIES} MODULE_FILES PhasarPass.cppm diff --git a/utils/InstallAptDependencies.sh b/utils/InstallAptDependencies.sh index 317454b1b0..3376cfcd1a 100755 --- a/utils/InstallAptDependencies.sh +++ b/utils/InstallAptDependencies.sh @@ -27,7 +27,7 @@ additional_dependencies=("$@") "clang-$LLVM_IR_VERSION" # compiler for IR "libclang-rt-$LLVM_IR_VERSION-dev" # ASAN libz3-dev libssl-dev "libclang-$LLVM_IR_VERSION-dev" "libclang-common-$LLVM_IR_VERSION-dev" # optional build deps - libboost-graph-dev zlib1g-dev libzstd-dev "llvm-$LLVM_IR_VERSION-dev" # build deps + zlib1g-dev libzstd-dev "llvm-$LLVM_IR_VERSION-dev" # build deps ) From eb83a4ad174a5b3474374f91fea0711197c7b721 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Mon, 3 Nov 2025 14:55:52 +0100 Subject: [PATCH 4/4] build: fix nlohmann_json dep for conan --- conanfile.py | 4 +++- lib/PhasarLLVM/Domain/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index a975138817..6f372a521d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -164,7 +164,9 @@ def export_sources(self): "utils", "img", "githooks", - "external" + "external", + "build", + "cmake-build" ]) for tlf in os.listdir("."): diff --git a/lib/PhasarLLVM/Domain/CMakeLists.txt b/lib/PhasarLLVM/Domain/CMakeLists.txt index 8c8ae40519..57a27723e7 100644 --- a/lib/PhasarLLVM/Domain/CMakeLists.txt +++ b/lib/PhasarLLVM/Domain/CMakeLists.txt @@ -7,5 +7,5 @@ add_phasar_library(phasar_llvm_domain Domain.cppm LINK_PRIVATE - nlohmann_json + nlohmann_json::nlohmann_json )