diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad1da83e6f..bb040a7d53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,7 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DBUILD_PHASAR_CLANG=OFF \ -DPHASAR_USE_Z3=ON \ + -DPHASAR_BUILD_MODULES=ON \ -DPHASAR_LLVM_VERSION=${{ matrix.llvm-version }} \ ${{ matrix.flags }} \ -G Ninja diff --git a/BreakingChanges.md b/BreakingChanges.md index acb51fa4a9..c343795c6a 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -2,6 +2,7 @@ ## development HEAD +- `IntraMonoProblem` and `InterMonoProblem`, and all reference-implementations of these problems do not receive a TypeHierarchy-pointer anymore in the ctor. - Requiring C++20 instead of C++17 - Type-traits and other templates that are specialized now use `requires` instead of `enable_if`, wherever possible. This may reduce the number of (defaulted) template parameters in some cases. - The `AdjacencyList` struct now now has one more template argument to denote the intege-like `vertex_t` type. It is the second template argument (which previously was the EdgeType). The edge-type is now denoted by the *third* template argument. diff --git a/include/phasar/ControlFlow.h b/include/phasar/ControlFlow.h index b820c0ec0e..83df86d82f 100644 --- a/include/phasar/ControlFlow.h +++ b/include/phasar/ControlFlow.h @@ -10,11 +10,15 @@ #ifndef PHASAR_CONTROLFLOW_H #define PHASAR_CONTROLFLOW_H +#include "phasar/ControlFlow/CFG.h" #include "phasar/ControlFlow/CFGBase.h" #include "phasar/ControlFlow/CallGraph.h" #include "phasar/ControlFlow/CallGraphAnalysisType.h" #include "phasar/ControlFlow/CallGraphBase.h" +#include "phasar/ControlFlow/ICFG.h" #include "phasar/ControlFlow/ICFGBase.h" +#include "phasar/ControlFlow/SparseCFGBase.h" +#include "phasar/ControlFlow/SparseCFGProvider.h" #include "phasar/ControlFlow/SpecialMemberFunctionType.h" #endif // PHASAR_CONTROLFLOW_H diff --git a/include/phasar/ControlFlow/CFG.h b/include/phasar/ControlFlow/CFG.h new file mode 100644 index 0000000000..3200b0c17a --- /dev/null +++ b/include/phasar/ControlFlow/CFG.h @@ -0,0 +1,90 @@ +/****************************************************************************** + * Copyright (c) 2026 Fabian Schiebel. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of LICENSE.txt. + * + * Contributors: + * Fabian Schiebel and others + *****************************************************************************/ +#pragma once + +#include "phasar/Utils/TypeTraits.h" + +#include "llvm/Support/raw_ostream.h" + +#include +#include + +namespace psr { + +template +concept InstructionClassifier = + requires(const T &IC, typename T::n_t Inst, typename T::n_t Succ) { + { IC.isCallSite(Inst) } -> std::convertible_to; + { IC.isFieldLoad(Inst) } -> std::convertible_to; + { IC.isFieldStore(Inst) } -> std::convertible_to; + { IC.isFallThroughSuccessor(Inst, Succ) } -> std::convertible_to; + { IC.isBranchTarget(Inst, Succ) } -> std::convertible_to; + }; + +template +concept CFG = requires(const T &CF, typename T::n_t Inst, typename T::f_t Fun) { + typename T::n_t; + typename T::f_t; + + /// Returns the function that contains the given instruction Inst. + // TODO: Actually belongs into ProjectIRDB! + { CF.getFunctionOf(Inst) } -> std::convertible_to; + /// Returns an iterable range of all instructions of the given function that + /// are part of the control-flow graph. + // TODO: We should have sth like this in the ProjectIRDB as well! + { CF.getAllInstructionsOf(Fun) } -> psr::is_iterable_over_v; + + /// Returns an iterable range of all successor instructions of Inst in the + /// CFG. + /// NOTE: This function is typically being called in a hot part of the + /// analysis and should therefore be highly optimized for performance. + { CF.getSuccsOf(Inst) } -> psr::is_iterable_over_v; + + /// Returns an iterable range of all starting instructions of the given + /// function. For a forward-CFG, this is typically a singleton range. + { CF.getStartPointsOf(Fun) } -> psr::is_iterable_over_v; + + /// Returns whether the given Inst is a root node of the CFG + { CF.isStartPoint(Inst) } -> std::convertible_to; + + /// Returns whether the given Inst is a leaf node of the CFG + { CF.isExitInst(Inst) } -> std::convertible_to; + + requires InstructionClassifier; +}; + +template +concept BidiCFG = + CFG && requires(const T &CF, typename T::n_t Inst, typename T::f_t Fun) { + /// Returns an iterable range of all predecessor instructions of Inst in + /// the CFG + { CF.getPredsOf(Inst) } -> psr::is_iterable_over_v; + + /// Returns an iterable range of all exit instructions (often return + /// instructions) of the given function. For a backward-CFG, this is + /// typically a singleton range + { CF.getExitPointsOf(Fun) } -> psr::is_iterable_over_v; + }; + +template +concept CFGDump = requires(const T &CF, typename T::n_t Inst, + typename T::f_t Fun, llvm::raw_ostream &OS) { + { CF.getStatementId(Inst) } -> psr::is_string_like_v; + { CF.getFunctionName(Fun) } -> psr::is_string_like_v; + { CF.getDemangledFunctionName(Fun) } -> psr::is_string_like_v; + CF.print(Fun, OS); +}; + +template +concept CFGEdgesProvider = requires(const T &CF, typename T::f_t Fun) { + { + CF.getAllControlFlowEdges(Fun) + } -> psr::is_iterable_over_v>; +}; +} // namespace psr diff --git a/include/phasar/ControlFlow/CFGBase.h b/include/phasar/ControlFlow/CFGBase.h index 3523600428..28fdd7c995 100644 --- a/include/phasar/ControlFlow/CFGBase.h +++ b/include/phasar/ControlFlow/CFGBase.h @@ -10,6 +10,7 @@ #ifndef PHASAR_CONTROLFLOW_CFGBASE_H #define PHASAR_CONTROLFLOW_CFGBASE_H +#include "phasar/ControlFlow/CFG.h" #include "phasar/Utils/ByRef.h" #include "phasar/Utils/CRTPUtils.h" #include "phasar/Utils/TypeTraits.h" @@ -139,9 +140,9 @@ template class CFGBase : public CRTPBase { template // NOLINTNEXTLINE(readability-identifier-naming) -concept is_cfg_v = is_crtp_base_of_v && - std::is_same_v && - std::is_same_v; +concept is_cfg_v = BidiCFG && CFGDump && CFGEdgesProvider && + std::same_as && + std::same_as; } // namespace psr diff --git a/include/phasar/ControlFlow/CallGraphBase.h b/include/phasar/ControlFlow/CallGraphBase.h index e4788fd3f5..796a31c286 100644 --- a/include/phasar/ControlFlow/CallGraphBase.h +++ b/include/phasar/ControlFlow/CallGraphBase.h @@ -14,7 +14,54 @@ #include "phasar/Utils/CRTPUtils.h" #include "phasar/Utils/TypeTraits.h" +#include +#include + namespace psr { + +template +concept IsCallGraph = + requires(const T &CG, typename T::n_t Inst, typename T::f_t Fun) { + typename T::n_t; + typename T::f_t; + + /// Returns an iterable range of all possible callee candidates at the + /// given call-site induced by the used call-graph. + /// + /// NOTE: This function is typically called in a hot part of the analysis + /// and should therefore be very fast + { + CG.getCalleesOfCallAt(Inst) + } -> psr::is_iterable_over_v; + + /// Returns an iterable range of all possible call-site candidates that + /// may call the given function induced by the used call-graph. + { CG.getCallersOf(Fun) } -> psr::is_iterable_over_v; + + /// A range of all functions that are vertices in the call-graph. The + /// number of vertex functions can be retrieved by + /// getNumVertexFunctions(). + { + CG.getAllVertexFunctions() + } -> psr::is_iterable_over_v; + + /// A range of all call-sites that are vertices in the call-graph. The + /// number of vertex-callsites can be retrived by getNumVertexCallSites(). + { + CG.getAllVertexCallSites() + } -> psr::is_iterable_over_v; + + { CG.getNumVertexFunctions() } -> std::convertible_to; + { CG.getNumVertexCallSites() } -> std::convertible_to; + + /// Same as getNumVertexFunctions() + { CG.size() } noexcept -> std::convertible_to; + { CG.empty() } noexcept -> std::convertible_to; + }; + +template +concept IsCallGraphRef = IsCallGraph>; + template struct CGTraits { // using n_t // using f_t diff --git a/include/phasar/ControlFlow/ICFG.h b/include/phasar/ControlFlow/ICFG.h new file mode 100644 index 0000000000..d3660fe11f --- /dev/null +++ b/include/phasar/ControlFlow/ICFG.h @@ -0,0 +1,64 @@ +/****************************************************************************** + * Copyright (c) 2026 Fabian Schiebel. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of LICENSE.txt. + * + * Contributors: + * Fabian Schiebel and others + *****************************************************************************/ +#pragma once + +#include "phasar/ControlFlow/CallGraphBase.h" +#include "phasar/Utils/Nullable.h" +#include "phasar/Utils/TypeTraits.h" + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/raw_ostream.h" + +#include + +namespace psr { +template +concept ICFG = requires(const T &ICF, llvm::StringRef Name, + typename T::n_t Inst, typename T::f_t Fun) { + typename T::f_t; + typename T::n_t; + + // TODO: Should not be duplicated with ProjectIRDB + { ICF.getAllFunctions() } -> is_iterable_over_v; + // TODO: Should not be duplicated with ProjectIRDB + { ICF.getFunction(Name) } -> std::convertible_to>; + + { ICF.isIndirectFunctionCall(Inst) } -> std::convertible_to; + { ICF.isVirtualFunctionCall(Inst) } -> std::convertible_to; + + /// Gets the underlying call-graph + { ICF.getCallGraph() } -> psr::IsCallGraphRef; + /// Returns an iterable range of all possible callee candidates at the given + /// call-site induced by the used call-graph. Same as + /// getCallGraph().getCalleesOfCallAt(Inst) + { ICF.getCalleesOfCallAt(Inst) } -> psr::is_iterable_over_v; + /// Returns an iterable range of all possible call-site candidates that may + /// call the given function induced by the used call-graph. Same as + /// getCallGraph().getCallersOf(Fun) + { ICF.getCallersOf(Fun) } -> psr::is_iterable_over_v; + + /// Returns an iterable range of all call-instruction in the given function + { ICF.getCallsFromWithin(Fun) } -> psr::is_iterable_over_v; + + /// Returns an iterable range of all instructions in all functions of the ICFG + /// that are neither call-sites nor start-points of a function + // TODO: Get rid of this function + { ICF.allNonCallStartNodes() } -> psr::is_iterable_over_v; + + /// The total number of call-sites in the ICFG. Same as + /// getCallGraph().getNumVertexCallSites() + { ICF.getNumCallSites() } noexcept -> std::convertible_to; +}; + +template +concept ICFGDump = requires(const T &ICF, llvm::raw_ostream &OS) { + ICF.print(OS); + ICF.printAsJson(OS); +}; +} // namespace psr diff --git a/include/phasar/ControlFlow/ICFGBase.h b/include/phasar/ControlFlow/ICFGBase.h index a6ff413d0f..4010df04c3 100644 --- a/include/phasar/ControlFlow/ICFGBase.h +++ b/include/phasar/ControlFlow/ICFGBase.h @@ -12,6 +12,7 @@ #include "phasar/ControlFlow/CFGBase.h" #include "phasar/ControlFlow/CallGraphBase.h" +#include "phasar/ControlFlow/ICFG.h" #include "phasar/Utils/CRTPUtils.h" #include "phasar/Utils/TypeTraits.h" @@ -118,7 +119,7 @@ template class ICFGBase : public CRTPBase { /// from the given analysis-Domain template // NOLINTNEXTLINE(readability-identifier-naming) -concept is_icfg_v = is_crtp_base_of_v && +concept is_icfg_v = ICFG && ICFGDump && std::is_same_v && std::is_same_v; diff --git a/include/phasar/DB.h b/include/phasar/DB.h index a9f84201e7..294b4e2bb6 100644 --- a/include/phasar/DB.h +++ b/include/phasar/DB.h @@ -11,6 +11,7 @@ #define PHASAR_DB_H #include "phasar/Config/phasar-config.h" +#include "phasar/DB/ProjectIRDB.h" #include "phasar/DB/ProjectIRDBBase.h" #endif // PHASAR_DB_H diff --git a/include/phasar/DB/ProjectIRDB.h b/include/phasar/DB/ProjectIRDB.h new file mode 100644 index 0000000000..c630be0765 --- /dev/null +++ b/include/phasar/DB/ProjectIRDB.h @@ -0,0 +1,114 @@ +/****************************************************************************** + * Copyright (c) 2026 Fabian Schiebel. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of LICENSE.txt. + * + * Contributors: + * Fabian Schiebel and others + *****************************************************************************/ +#pragma once + +#include "phasar/Utils/Nullable.h" +#include "phasar/Utils/TypeTraits.h" + +#include "llvm/ADT/StringRef.h" + +#include + +namespace psr { + +template +concept ProjectSymbolTable = requires(const T &ST, llvm::StringRef Name, + size_t InstId, typename T::n_t Inst) { + /// Reference to a Instruction/Statement + typename T::n_t; + /// Reference to a function + typename T::f_t; + /// Reference to a program module (potentially containing the whole + /// program) + typename T::m_t; + /// Reference to a Global Variable + typename T::g_t; + + /// Returns the function (declaration or definition) if available, + /// nullptr/nullopt otherwise. + { ST.getFunction(Name) } -> std::convertible_to>; + + /// Returns the function's definition if available, null otherwise. + { + ST.getFunctionDefinition(Name) + } -> std::convertible_to>; + + /// Returns whether the IRDB contains a function (declaration or + /// definition) with the given name. + { ST.hasFunction(Name) } -> std::convertible_to; + + /// Returns the global variable (declaration or definition) if available, + /// nullptr/nullopt otherwise. + { + ST.getGlobalVariable(Name) + } -> std::convertible_to>; + + /// Returns the global variable's definition if available, nullptr/nullopt + /// otherwise. + { + ST.getGlobalVariableDefinition(Name) + } -> std::convertible_to>; + + /// Returns the instruction to the corresponding Id. Returns + /// nullptr/nullopt, if there is no instruction for this Id + { + ST.getInstruction(InstId) + } -> std::convertible_to>; + + /// Returns an instruction's Id. The instruction must belong to the managed + /// module for this function to work. + /// + /// You can expect the instruction-ids to be sequential in the interval [0, + /// N), where N is the total number of managed instructions. + { ST.getInstructionId(Inst) } -> std::convertible_to; +}; + +/// This concept describes the minimum requirements for a project-IR-database. +/// Each phasar-analysis works on a program that is managed by a ProjectIRDB. +template +concept ProjectIRDB = + requires(const T &DB, typename T::n_t Inst, typename T::f_t Fun) { + /// Returns the managed module + { DB.getModule() } noexcept -> std::convertible_to; + + /// Check if debug information are available. + { DB.debugInfoAvailable() } -> std::convertible_to; + + /// Returns a range of all function definitions and declarations available + { DB.getAllFunctions() } -> psr::is_iterable_over_v; + + /// Returns the number of functions in the managed module. + { DB.getNumFunctions() } -> std::convertible_to; + + /// Returns a range of all global variables (and global constants, e.g, + /// string literals) in the managed module + { DB.getAllGlobals() } -> psr::is_iterable_over_v; + + /// Returns the number of global variables (and global constants) in the + /// managed module. + { DB.getNumGlobals() } -> std::convertible_to; + + /// Returns a range of all instructions available. + { DB.getAllInstructions() } -> psr::is_iterable_over_v; + + /// Returns the number of instruction in the managed module. + { DB.getNumInstructions() } -> std::convertible_to; + + /// Returns the function that contains the given instruction Inst. + { DB.getFunctionOf(Inst) } -> std::convertible_to; + + /// Returns an iterable range of all instructions of the given function + /// that are part of the control-flow graph. + { + DB.getAllInstructionsOf(Fun) + } -> psr::is_iterable_over_v; + + requires ProjectSymbolTable; + }; +} // namespace psr diff --git a/include/phasar/DB/ProjectIRDBBase.h b/include/phasar/DB/ProjectIRDBBase.h index 60e08cd2ab..c30fffd342 100644 --- a/include/phasar/DB/ProjectIRDBBase.h +++ b/include/phasar/DB/ProjectIRDBBase.h @@ -37,7 +37,10 @@ template struct ProjectIRDBTraits { /// /// \remark XXX Once we have upgraded to C++20, we might want to use a concept /// instead... -template class ProjectIRDBBase { +template +class LLVM_DEPRECATED( + "This CRTP mixin is deprecated in favor of the ProjectIRDB-concept", + "Use ProjectIRDB instead") ProjectIRDBBase { public: using n_t = typename ProjectIRDBTraits::n_t; using f_t = typename ProjectIRDBTraits::f_t; @@ -81,7 +84,7 @@ template class ProjectIRDBBase { return self().hasFunctionImpl(FunctionName); } - /// Returns the global variable's definition if available, nullptr/nullopt + /// Returns the global variable if available, nullptr/nullopt /// otherwise. [[nodiscard]] Nullable getGlobalVariable(llvm::StringRef GlobalVariableName) const { diff --git a/include/phasar/DataFlow/IfdsIde/EntryPointUtils.h b/include/phasar/DataFlow/IfdsIde/EntryPointUtils.h index d5626a2e0d..b449f7794e 100644 --- a/include/phasar/DataFlow/IfdsIde/EntryPointUtils.h +++ b/include/phasar/DataFlow/IfdsIde/EntryPointUtils.h @@ -10,8 +10,8 @@ #ifndef PHASAR_DATAFLOW_IFDSIDE_ENTRYPOINTUTILS_H #define PHASAR_DATAFLOW_IFDSIDE_ENTRYPOINTUTILS_H -#include "phasar/ControlFlow/CFGBase.h" -#include "phasar/DB/ProjectIRDBBase.h" +#include "phasar/ControlFlow/CFG.h" +#include "phasar/DB/ProjectIRDB.h" #include "phasar/Domain/BinaryDomain.h" #include "llvm/ADT/STLExtras.h" @@ -22,8 +22,8 @@ namespace psr { namespace detail { -template -void forallStartingPoints(const EntryRange &EntryPoints, const CFGBase &CFG, +template +void forallStartingPoints(const EntryRange &EntryPoints, const C &CFG, HandlerFn Handler) { for (const auto &EntryPointFn : EntryPoints) { if constexpr (std::is_convertible_v, @@ -38,10 +38,9 @@ void forallStartingPoints(const EntryRange &EntryPoints, const CFGBase &CFG, } } -template +template void forallStartingPoints(const EntryRange &EntryPoints, const ICFGorIRDB *ICDB, - const CFGBase &CFG, HandlerFn Handler) { + const C &CFG, HandlerFn Handler) { if (llvm::hasSingleElement(EntryPoints) && *llvm::adl_begin(EntryPoints) == "__ALL__") { @@ -57,10 +56,9 @@ void forallStartingPoints(const EntryRange &EntryPoints, const ICFGorIRDB *ICDB, } // namespace detail -template -void forallStartingPoints(const EntryRange &EntryPoints, - const ProjectIRDBBase *IRDB, - const CFGBase &CFG, HandlerFn Handler) { +template +void forallStartingPoints(const EntryRange &EntryPoints, const DB *IRDB, + const C &CFG, HandlerFn Handler) { return detail::forallStartingPoints(EntryPoints, IRDB, CFG, std::move(Handler)); } @@ -71,14 +69,13 @@ void forallStartingPoints(const EntryRange &EntryPoints, const I *ICF, detail::forallStartingPoints(EntryPoints, ICF, *ICF, std::move(Handler)); } -template requires(std::is_convertible_v && std::is_convertible_v) -void addSeedsForStartingPoints(const EntryRange &EntryPoints, - const ProjectIRDBBase *IRDB, - const CFGBase &CFG, SeedsT &Seeds, - const D &ZeroValue, const L &BottomValue) { +void addSeedsForStartingPoints(const EntryRange &EntryPoints, const DB *IRDB, + const C &CFG, SeedsT &Seeds, const D &ZeroValue, + const L &BottomValue) { forallStartingPoints(EntryPoints, IRDB, CFG, [&Seeds, &ZeroValue, &BottomValue](const auto &SP) { Seeds.addSeed(SP, ZeroValue, BottomValue); @@ -99,13 +96,12 @@ void addSeedsForStartingPoints(const EntryRange &EntryPoints, const I *ICF, } /// Simplification for IFDS, passing BinaryDomain::BOTTOM as L -template requires(std::is_same_v && std::is_convertible_v) -void addSeedsForStartingPoints(const EntryRange &EntryPoints, - const ProjectIRDBBase *IRDB, - const CFGBase &CFG, SeedsT &Seeds, +void addSeedsForStartingPoints(const EntryRange &EntryPoints, const DB *IRDB, + const C &CFG, SeedsT &Seeds, const D &ZeroValue) { addSeedsForStartingPoints(EntryPoints, IRDB, CFG, Seeds, ZeroValue, BinaryDomain::BOTTOM); diff --git a/include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h b/include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h index b722ca7ae3..3868fcf24d 100644 --- a/include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h +++ b/include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h @@ -10,12 +10,12 @@ #ifndef PHASAR_DATAFLOW_IFDSIDE_IDETABULATIONPROBLEM_H_ #define PHASAR_DATAFLOW_IFDSIDE_IDETABULATIONPROBLEM_H_ -#include "phasar/DB/ProjectIRDBBase.h" #include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h" #include "phasar/DataFlow/IfdsIde/EdgeFunctions.h" #include "phasar/DataFlow/IfdsIde/EntryPointUtils.h" #include "phasar/DataFlow/IfdsIde/FlowFunctions.h" #include "phasar/DataFlow/IfdsIde/IFDSIDESolverConfig.h" +#include "phasar/DataFlow/IfdsIde/IfdsIdeDomain.h" #include "phasar/DataFlow/IfdsIde/InitialSeeds.h" #include "phasar/DataFlow/IfdsIde/Solver/GenericSolverResults.h" #include "phasar/Utils/DefaultAnalysisPrinterSelector.h" @@ -39,14 +39,14 @@ namespace psr { struct HasNoConfigurationType; -template class AllTopFnProvider { +template class AllTopFnProvider { public: virtual ~AllTopFnProvider() = default; /// Returns an edge function that represents the top element of the analysis. virtual EdgeFunction allTopFunction() = 0; }; -template +template requires HasJoinLatticeTraits class AllTopFnProvider { public: @@ -63,7 +63,7 @@ class AllTopFnProvider { /// /// For more information on how to write an IDE analysis, see [Writing an IDE /// Analysis](https://github.com/secure-software-engineering/phasar/wiki/Writing-an-IDE-analysis) -template > class IDETabulationProblem : public FlowFunctions, public EdgeFunctions, @@ -95,7 +95,7 @@ class IDETabulationProblem : public FlowFunctions, /// Λ). If not provided here, you must set it via \link initializeZeroValue() /// \endlink. explicit IDETabulationProblem( - const ProjectIRDBBase *IRDB, std::vector EntryPoints, + const db_t *IRDB, std::vector EntryPoints, std::optional ZeroValue) noexcept(std::is_nothrow_move_constructible_v) : IRDB(IRDB), EntryPoints(std::move(EntryPoints)), @@ -175,9 +175,7 @@ class IDETabulationProblem : public FlowFunctions, /// the level of soundness is ignored. Otherwise, true. virtual bool setSoundness(Soundness /*S*/) { return false; } - [[nodiscard]] const ProjectIRDBBase *getProjectIRDB() const noexcept { - return IRDB; - } + [[nodiscard]] const db_t *getProjectIRDB() const noexcept { return IRDB; } protected: typename FlowFunctions::FlowFunctionPtrType @@ -215,7 +213,7 @@ class IDETabulationProblem : public FlowFunctions, return Seeds; } - const ProjectIRDBBase *IRDB{}; + const db_t *IRDB{}; std::vector EntryPoints; std::optional ZeroValue; diff --git a/include/phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h b/include/phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h index 723f0acce3..acdaf99458 100644 --- a/include/phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h +++ b/include/phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h @@ -12,6 +12,7 @@ #include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h" #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" +#include "phasar/DataFlow/IfdsIde/IfdsIdeDomain.h" #include "phasar/Domain/AnalysisDomain.h" #include @@ -25,7 +26,7 @@ namespace psr { /// /// For more information on how to write an IFDS analysis, see [Writing an IFDS /// Analysis](https://github.com/secure-software-engineering/phasar/wiki/Writing-an-IFDS-analysis) -template > class IFDSTabulationProblem : public IDETabulationProblem, @@ -55,7 +56,7 @@ class IFDSTabulationProblem /// @param[in] ZeroValue Provides the special tautological zero value (aka. /// Λ). /// \endlink. - explicit IFDSTabulationProblem(const ProjectIRDBBase *IRDB, + explicit IFDSTabulationProblem(const db_t *IRDB, std::vector EntryPoints, d_t ZeroValue) : Base(IRDB, std::move(EntryPoints), std::move(ZeroValue)) {} diff --git a/include/phasar/DataFlow/IfdsIde/IfdsIdeDomain.h b/include/phasar/DataFlow/IfdsIde/IfdsIdeDomain.h new file mode 100644 index 0000000000..bb48c770f7 --- /dev/null +++ b/include/phasar/DataFlow/IfdsIde/IfdsIdeDomain.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * Copyright (c) 2026 Fabian Schiebel. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of LICENSE.txt. + * + * Contributors: + * Fabian Schiebel and others + *****************************************************************************/ +#pragma once + +#include "phasar/ControlFlow/ICFG.h" +#include "phasar/Domain/AnalysisDomain.h" +#include "phasar/Utils/TypeTraits.h" + +#include + +namespace psr { + +// XXX: More constraints to be added +template +concept IsDataFlowFact = + std::is_copy_constructible_v && psr::IsEqualityComparable && + psr::is_std_hashable_v; + +// XXX: More constraints to be added +template +concept IsEdgeValue = + std::is_move_constructible_v && psr::IsEqualityComparable; + +template +concept IfdsAnalysisDomain = IsAnalysisDomain && requires() { + typename T::d_t; + typename T::i_t; + + requires IsDataFlowFact; + requires ICFG; +}; + +template +concept IdeAnalysisDomain = IfdsAnalysisDomain && requires() { + typename T::l_t; + requires IsEdgeValue; +}; +} // namespace psr diff --git a/include/phasar/DataFlow/IfdsIde/Solver/Compressor.h b/include/phasar/DataFlow/IfdsIde/Solver/Compressor.h index fdeef7e304..7479bbd0c9 100644 --- a/include/phasar/DataFlow/IfdsIde/Solver/Compressor.h +++ b/include/phasar/DataFlow/IfdsIde/Solver/Compressor.h @@ -1,7 +1,6 @@ #ifndef PHASAR_DATAFLOW_IFDSIDE_SOLVER_COMPRESSOR_H #define PHASAR_DATAFLOW_IFDSIDE_SOLVER_COMPRESSOR_H -#include "phasar/DB/ProjectIRDBBase.h" #include "phasar/Utils/ByRef.h" #include "phasar/Utils/Compressor.h" @@ -39,8 +38,8 @@ class LLVMProjectIRDB; template struct NodeCompressorTraits { using type = Compressor; - static type create(const ProjectIRDBBase - * /*IRDB*/) noexcept(noexcept(type())) { + static type + create(const LLVMProjectIRDB * /*IRDB*/) noexcept(noexcept(type())) { return type(); } }; diff --git a/include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h b/include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h index f105e3558a..50f3629745 100644 --- a/include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h +++ b/include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h @@ -54,6 +54,7 @@ #include "nlohmann/json.hpp" +#include #include #include #include @@ -87,7 +88,7 @@ class IDESolver using t_t = typename AnalysisDomainTy::t_t; using v_t = typename AnalysisDomainTy::v_t; - template + template I> IDESolver(IDETabulationProblem &Problem, const I *ICF) : IDEProblem(Problem), ZeroValue(Problem.getZeroValue()), @@ -99,11 +100,7 @@ class IDESolver assert(ICF != nullptr); if constexpr (has_getSparseCFG_v) { - NextUserOrNullCB = [](const void *SVFG, ByConstRef Fun, - ByConstRef d3, ByConstRef n) { - auto &&SCFG = static_cast(SVFG)->getSparseCFG(Fun, d3); - return SCFG.nextUserOrNull(n); - }; + NextUserOrNullCB = &nextUserOrNullThunk; } } @@ -1775,6 +1772,13 @@ class IDESolver } private: + template + static auto nextUserOrNullThunk(const void *SVFG, ByConstRef Fun, + ByConstRef d3, ByConstRef n) { + auto &&SCFG = static_cast(SVFG)->getSparseCFG(Fun, d3); + return SCFG.nextUserOrNull(n); + }; + /// @brief: Allows less-than comparison based on the statement ID. struct StmtLess { const i_t *ICF; @@ -1937,8 +1941,10 @@ template OwningSolverResults -solveIDEProblem(IDETabulationProblem &Problem, - const typename AnalysisDomainTy::i_t &ICF) { +solveIDEProblem( + IDETabulationProblem &Problem, + const std::convertible_to auto + &ICF) { IDESolver Solver(&Problem, &ICF); Solver.solve(); return Solver.consumeSolverResults(); diff --git a/include/phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h b/include/phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h index 76c51ce29e..59055acdb3 100644 --- a/include/phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h +++ b/include/phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h @@ -46,11 +46,14 @@ class IFDSSolver using n_t = typename AnalysisDomainTy::n_t; using i_t = typename AnalysisDomainTy::i_t; - template IfdsDomainTy, typename I> + template IfdsDomainTy, + std::convertible_to I> IFDSSolver(IFDSTabulationProblem &IFDSProblem, const I *ICF) : IDESolver>(IFDSProblem, ICF) {} - template IfdsDomainTy, typename I> + + template IfdsDomainTy, + std::convertible_to I> IFDSSolver(IFDSTabulationProblem *IFDSProblem, const I *ICF) : IDESolver>(IFDSProblem, ICF) {} @@ -122,8 +125,10 @@ using IFDSSolver_P = IFDSSolver OwningSolverResults -solveIFDSProblem(IFDSTabulationProblem &Problem, - const typename AnalysisDomainTy::i_t &ICF) { +solveIFDSProblem( + IFDSTabulationProblem &Problem, + const std::convertible_to auto + &ICF) { IFDSSolver Solver(Problem, &ICF); Solver.solve(); return Solver.consumeSolverResults(); diff --git a/include/phasar/DataFlow/IfdsIde/Solver/JumpFunctions.h b/include/phasar/DataFlow/IfdsIde/Solver/JumpFunctions.h index 85a80fe604..003c264ef1 100644 --- a/include/phasar/DataFlow/IfdsIde/Solver/JumpFunctions.h +++ b/include/phasar/DataFlow/IfdsIde/Solver/JumpFunctions.h @@ -18,6 +18,7 @@ #define PHASAR_DATAFLOW_IFDSIDE_SOLVER_JUMPFUNCTIONS_H #include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h" +#include "phasar/DataFlow/IfdsIde/IfdsIdeDomain.h" #include "phasar/Utils/ByRef.h" #include "phasar/Utils/Logger.h" #include "phasar/Utils/Table.h" @@ -35,7 +36,7 @@ namespace psr { // Forward declare the IDETabulationProblem as we require its toString // functionality. -template +template class IDETabulationProblem; template class JumpFunctions { diff --git a/include/phasar/DataFlow/Mono/InterMonoProblem.h b/include/phasar/DataFlow/Mono/InterMonoProblem.h index 326cf9df91..ced2906107 100644 --- a/include/phasar/DataFlow/Mono/InterMonoProblem.h +++ b/include/phasar/DataFlow/Mono/InterMonoProblem.h @@ -17,7 +17,7 @@ #ifndef PHASAR_DATAFLOW_MONO_INTERMONOPROBLEM_H #define PHASAR_DATAFLOW_MONO_INTERMONOPROBLEM_H -#include "phasar/ControlFlow/ICFGBase.h" +#include "phasar/ControlFlow/ICFG.h" #include "phasar/DataFlow/Mono/IntraMonoProblem.h" #include "phasar/Pointer/AliasInfo.h" #include "phasar/Utils/BitVectorSet.h" @@ -28,13 +28,16 @@ namespace psr { -template class TypeHierarchy; -template class ICFG; +template +concept InterMonoAnalysisDomain = MonoAnalysisDomain && requires() { + typename T::i_t; + requires ICFG; +}; /// \brief The analysis problem interface for interprocedural monotone problems /// (solvable by the InterMonoSolver). Create a subclass from this and override /// all pure-virtual functions to create your own inter-mono analysis. -template +template class InterMonoProblem : public IntraMonoProblem { public: using n_t = typename AnalysisDomainTy::n_t; @@ -58,15 +61,10 @@ class InterMonoProblem : public IntraMonoProblem { /// @param[in] CF A control flow graph based on the given IRDB. /// @param[in] PT Points-to information based on the given IRDB. /// @param[in] EntryPoints A vector of entry points. Provide at least one. - InterMonoProblem(const ProjectIRDBBase *IRDB, - const TypeHierarchy *TH, const i_t *ICF, - AliasInfoRef PT, + InterMonoProblem(const db_t *IRDB, const i_t *ICF, AliasInfoRef PT, std::vector EntryPoints = {}) - : IntraMonoProblem(IRDB, TH, ICF, PT, EntryPoints), - ICF(ICF) { - static_assert(is_icfg_v, - "Type parameter i_t must implement the ICFG interface!"); - } + : IntraMonoProblem(IRDB, ICF, PT, EntryPoints), + ICF(ICF) {} ~InterMonoProblem() override = default; InterMonoProblem(const InterMonoProblem &Other) = delete; diff --git a/include/phasar/DataFlow/Mono/IntraMonoProblem.h b/include/phasar/DataFlow/Mono/IntraMonoProblem.h index 954d2913a8..fddc862997 100644 --- a/include/phasar/DataFlow/Mono/IntraMonoProblem.h +++ b/include/phasar/DataFlow/Mono/IntraMonoProblem.h @@ -17,8 +17,8 @@ #ifndef PHASAR_DATAFLOW_MONO_INTRAMONOPROBLEM_H #define PHASAR_DATAFLOW_MONO_INTRAMONOPROBLEM_H -#include "phasar/ControlFlow/CFGBase.h" -#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" +#include "phasar/ControlFlow/CFG.h" +#include "phasar/Domain/AnalysisDomain.h" #include "phasar/Pointer/AliasInfo.h" #include "phasar/Utils/Printer.h" #include "phasar/Utils/Soundness.h" @@ -32,13 +32,15 @@ namespace psr { struct HasNoConfigurationType; -template class TypeHierarchy; -template class CFG; +template +concept MonoAnalysisDomain = IsAnalysisDomain && BidiCFG && + CFGEdgesProvider && + requires() { typename T::mono_container_t; }; /// \brief The analysis problem interface for intraprocedural monotone problems /// (solvable by the IntraMonoSolver). Create a subclass from this and override /// all pure-virtual functions to create your own mono analysis. -template class IntraMonoProblem { +template class IntraMonoProblem { public: using n_t = typename AnalysisDomainTy::n_t; using d_t = typename AnalysisDomainTy::d_t; @@ -53,9 +55,8 @@ template class IntraMonoProblem { using ProblemAnalysisDomain = AnalysisDomainTy; protected: - const ProjectIRDBBase *IRDB; - const TypeHierarchy *TH; - const CFGBase *CF; + const db_t *IRDB; + const c_t *CF; AliasInfoRef PT; std::vector EntryPoints; [[maybe_unused]] Soundness S = Soundness::Soundy; @@ -71,12 +72,9 @@ template class IntraMonoProblem { /// @param[in] CF A control flow graph based on the given IRDB. /// @param[in] PT Points-to information based on the given IRDB. /// @param[in] EntryPoints A vector of entry points. Provide at least one. - IntraMonoProblem(const ProjectIRDBBase *IRDB, - const TypeHierarchy *TH, const CFGBase *CF, - AliasInfoRef PT, + IntraMonoProblem(const db_t *IRDB, const c_t *CF, AliasInfoRef PT, std::vector EntryPoints = {}) - : IRDB(IRDB), TH(TH), CF(CF), PT(PT), - EntryPoints(std::move(EntryPoints)) {} + : IRDB(IRDB), CF(CF), PT(PT), EntryPoints(std::move(EntryPoints)) {} virtual ~IntraMonoProblem() = default; @@ -96,15 +94,9 @@ template class IntraMonoProblem { return EntryPoints; } - [[nodiscard]] const ProjectIRDBBase *getProjectIRDB() const { - return IRDB; - } - - [[nodiscard]] const TypeHierarchy *getTypeHierarchy() const { - return TH; - } + [[nodiscard]] const db_t *getProjectIRDB() const { return IRDB; } - [[nodiscard]] const CFGBase *getCFG() const { return CF; } + [[nodiscard]] const c_t *getCFG() const { return CF; } [[nodiscard]] AliasInfoRef getPointstoInfo() const { return PT; } diff --git a/include/phasar/DataFlow/Mono/Solver/IntraMonoSolver.h b/include/phasar/DataFlow/Mono/Solver/IntraMonoSolver.h index ed5b1f449d..fbe48992bc 100644 --- a/include/phasar/DataFlow/Mono/Solver/IntraMonoSolver.h +++ b/include/phasar/DataFlow/Mono/Solver/IntraMonoSolver.h @@ -49,7 +49,7 @@ template class IntraMonoSolver { ProblemTy &IMProblem; std::deque> Worklist; std::unordered_map Analysis; - const CFGBase *CFG; + const c_t *CFG; void initialize() { const auto &EntryPoints = IMProblem.getEntryPoints(); diff --git a/include/phasar/Domain.h b/include/phasar/Domain.h index 33adee8fc3..a11551c97e 100644 --- a/include/phasar/Domain.h +++ b/include/phasar/Domain.h @@ -12,6 +12,7 @@ #include "phasar/Domain/AnalysisDomain.h" #include "phasar/Domain/BinaryDomain.h" +#include "phasar/Domain/IRDomain.h" #include "phasar/Domain/LatticeDomain.h" #endif // PHASAR_DOMAIN_H diff --git a/include/phasar/Domain/AnalysisDomain.h b/include/phasar/Domain/AnalysisDomain.h index a4622695a8..6715ad0554 100644 --- a/include/phasar/Domain/AnalysisDomain.h +++ b/include/phasar/Domain/AnalysisDomain.h @@ -10,10 +10,29 @@ #ifndef PHASAR_DOMAIN_ANALYSISDOMAIN_H #define PHASAR_DOMAIN_ANALYSISDOMAIN_H +#include "phasar/ControlFlow/CFG.h" +#include "phasar/Domain/IRDomain.h" + #include namespace psr { +/// Minimum requirements of an analysis domain. Analyses may add extra +/// requirements. +template +concept IsAnalysisDomain = IRDomain && requires() { + typename T::ir_t; + requires IRDomain; + requires std::same_as; + requires std::same_as; + requires std::same_as; + requires std::same_as; + requires std::same_as; + + typename T::c_t; + requires CFG; +}; + /// AnalysisDomain - This class should be specialized by different static /// analyses types... which is why the default version declares all analysis /// domains as aliases of void. @@ -30,6 +49,8 @@ namespace psr { /// conduct an analysis but not correctly set, it will statically report an /// error and ask for the missing piece of information. struct AnalysisDomain { + /// Program IR + using ir_t = void; /// Data-flow fact --- Specifies the type of an individual data-flow fact that /// is propagated through the program under analysis. using d_t = void; diff --git a/include/phasar/Domain/IRDomain.h b/include/phasar/Domain/IRDomain.h new file mode 100644 index 0000000000..66a214ac87 --- /dev/null +++ b/include/phasar/Domain/IRDomain.h @@ -0,0 +1,37 @@ +/****************************************************************************** + * Copyright (c) 2026 Fabian Schiebel. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of LICENSE.txt. + * + * Contributors: + * Fabian Schiebel and others + *****************************************************************************/ +#pragma once + +#include "phasar/DB/ProjectIRDB.h" + +namespace psr { +/// Describes useful properties of the program intermediate representation (IR). +template +concept IRDomain = requires() { + /// (Control-flow) Node --- Specifies the type of a node in the + /// (inter-procedural) control-flow graph and can be though of as an + /// individual statement or instruction of the target program. + typename T::n_t; + + /// Function --- Specifies the type of functions/procedures in the target + /// program. + typename T::f_t; + + /// (Pointer) value --- Specifies the type of pointers. + typename T::v_t; + + /// (User-defined) type --- Specifies the type of a user-defined (i.e. struct + /// or class) data type. + typename T::t_t; + + /// The ProjectIRDB type --- Provides access to the IR. + typename T::db_t; + requires ProjectIRDB; +}; +} // namespace psr diff --git a/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h b/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h index d079bbd9db..13c3f1f5d5 100644 --- a/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h +++ b/include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h @@ -18,6 +18,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" +#include "llvm/IR/InstIterator.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" @@ -38,7 +39,10 @@ template <> struct ProjectIRDBTraits { }; /// \brief Project IR Database that manages a LLVM IR module. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" class LLVMProjectIRDB : public ProjectIRDBBase { +#pragma GCC diagnostic pop friend ProjectIRDBBase; public: @@ -142,6 +146,31 @@ class LLVMProjectIRDB : public ProjectIRDBBase { /// called twice for the same function. Use with care! void insertFunction(llvm::Function *F, bool DoPreprocessing = true); + /// Returns the function that contains the given instruction Inst. + /// + /// \remark This function should eventually replace + /// LLVMBasedCFG::getFunctionOf() + [[nodiscard]] f_t getFunctionOf(n_t Inst) const { + return Inst ? Inst->getFunction() : nullptr; + } + + /// Returns an iterable range of all instructions of the given function that + /// are part of the control-flow graph. + /// + /// \remark This function should eventually replace + /// LLVMBasedCFG::getAllInstructionsOf() + [[nodiscard]] auto getAllInstructionsOf(f_t Fun) const { + return llvm::map_range(llvm::instructions(Fun), + Ref2PointerConverter{}); + } + + /// Returns a range of all global variables (and global constants, e.g, string + /// literals) in the managed module + [[nodiscard]] auto getAllGlobals() const { + return llvm::map_range(std::as_const(*Mod).globals(), + Ref2PointerConverter{}); + } + explicit operator bool() const noexcept { return isValid(); } private: diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultAliasAwareIDEProblem.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultAliasAwareIDEProblem.h index fbe5e3d14e..2050e6e1c5 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultAliasAwareIDEProblem.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultAliasAwareIDEProblem.h @@ -10,6 +10,8 @@ #ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDEALIASINFOTABULATIONPROBLEM_H #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDEALIASINFOTABULATIONPROBLEM_H +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" @@ -77,7 +79,7 @@ class DefaultAliasAwareIDEProblem /// \note It is useful to use an instance of FilteredAliasSet for the alias /// information to lower suprious aliases explicit DefaultAliasAwareIDEProblem( - const ProjectIRDBBase *IRDB, LLVMAliasIteratorRef AS, + const db_t *IRDB, LLVMAliasIteratorRef AS, std::vector EntryPoints, std::optional ZeroValue) noexcept(std::is_nothrow_move_constructible_v) @@ -124,7 +126,7 @@ class DefaultAliasAwareIFDSProblem /// \note It is useful to use an instance of FilteredAliasSet for the alias /// information to lower suprious aliases explicit DefaultAliasAwareIFDSProblem( - const ProjectIRDBBase *IRDB, LLVMAliasIteratorRef AS, + const db_t *IRDB, LLVMAliasIteratorRef AS, std::vector EntryPoints, d_t ZeroValue) noexcept(std::is_nothrow_move_constructible_v) : IFDSTabulationProblem(IRDB, std::move(EntryPoints), ZeroValue), diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h index 19c00ac008..74ee0666de 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h @@ -13,6 +13,8 @@ #include "phasar/DataFlow/IfdsIde/FlowFunctions.h" #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" namespace llvm { diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultReachableAllocationSitesIDEProblem.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultReachableAllocationSitesIDEProblem.h index 783df3c193..5101f6d728 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultReachableAllocationSitesIDEProblem.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultReachableAllocationSitesIDEProblem.h @@ -10,6 +10,8 @@ #ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_DEFAULTREACHABLEALLOCATIONSITESIDEPROBLEM_H #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_DEFAULTREACHABLEALLOCATIONSITESIDEPROBLEM_H +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" #include "phasar/PhasarLLVM/Pointer/LLVMPointsToInfo.h" @@ -77,7 +79,7 @@ class DefaultReachableAllocationSitesIDEProblem /// \note It is useful to use an instance of FilteredAliasSet for the alias /// information to lower suprious aliases explicit DefaultReachableAllocationSitesIDEProblem( - const ProjectIRDBBase *IRDB, LLVMPointsToIteratorRef AS, + const db_t *IRDB, LLVMPointsToIteratorRef AS, std::vector EntryPoints, std::optional ZeroValue) noexcept(std::is_nothrow_move_constructible_v) @@ -125,7 +127,7 @@ class DefaultReachableAllocationSitesIFDSProblem /// \note It is useful to use an instance of FilteredAliasSet for the alias /// information to lower suprious aliases explicit DefaultReachableAllocationSitesIFDSProblem( - const ProjectIRDBBase *IRDB, LLVMPointsToIteratorRef AS, + const db_t *IRDB, LLVMPointsToIteratorRef AS, std::vector EntryPoints, d_t ZeroValue) noexcept(std::is_nothrow_move_constructible_v) : IFDSTabulationProblem(IRDB, std::move(EntryPoints), ZeroValue), diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h index d33ebfca72..f91866af7f 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEExtendedTaintAnalysis.h @@ -12,6 +12,7 @@ #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" #include "phasar/Domain/LatticeDomain.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" #include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/ExtendedTaintAnalysis/AbstractMemoryLocation.h" @@ -41,8 +42,6 @@ namespace psr { -class LLVMBasedICFG; - struct IDEExtendedTaintAnalysisDomain : public LLVMAnalysisDomainDefault { using d_t = AbstractMemoryLocation; /// Nullptr means tainted, nonnull llvm::Instruction* refers to a diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h index 9c4498190f..f1e28fb426 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h @@ -13,7 +13,9 @@ #include "phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h" #include "phasar/DataFlow/IfdsIde/EdgeFunction.h" #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" #include "phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" #include "phasar/Utils/BitVectorSet.h" @@ -36,7 +38,6 @@ class GlobalVariable; } // namespace llvm namespace psr { -class LLVMProjectIRDB; struct IDEFeatureTaintEdgeFact { llvm::SmallBitVector Taints; diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.h index 0b1de3088b..608933f3a1 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCA.h @@ -12,6 +12,7 @@ #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" #include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/EdgeValueSet.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/IDEGeneralizedLCADomain.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.h index 01518d555e..0e14c90f54 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEInstInteractionAnalysis.h @@ -1115,11 +1115,11 @@ class IDEInstInteractionAnalysisT // // Emit only IR code, function name and module info // OS << "\nWARNING: No Debug Info available - emiting results without " // "source code mapping!\n"; - for (const auto *f : this->ICF->getAllFunctions()) { + for (const auto *f : this->IRDB->getAllFunctions()) { std::string FunName = getFunctionNameFromIR(f); OS << "\nFunction: " << FunName << "\n----------" << std::string(FunName.size(), '-') << '\n'; - for (const auto *Inst : this->ICF->getAllInstructionsOf(f)) { + for (const auto *Inst : this->IRDB->getAllInstructionsOf(f)) { auto Results = SR.resultsAt(Inst, true); stripBottomResults(Results); if (!Results.empty()) { diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h index 30c8ed8b58..7407473e40 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDELinearConstantAnalysis.h @@ -12,6 +12,8 @@ #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" #include "phasar/Domain/LatticeDomain.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "llvm/Support/raw_ostream.h" @@ -35,8 +37,6 @@ struct IDELinearConstantAnalysisDomain : public LLVMAnalysisDomainDefault { using l_t = LatticeDomain; }; -class LLVMBasedICFG; - // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class IDELinearConstantAnalysis : public IDETabulationProblem { diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEProtoAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEProtoAnalysis.h index c4b9ab965c..4122eacb0e 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEProtoAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEProtoAnalysis.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IDEPROTOANALYSIS_H #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h index 2141946dd7..e02d0a3981 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESecureHeapPropagation.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IDESECUREHEAPPROPAGATION_H #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.h index 3c1736fb58..7685aa910b 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDESolverTest.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IDESOLVERTEST_H #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h index 390b1e2427..b01abd38fd 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h @@ -15,6 +15,7 @@ #include "phasar/DataFlow/IfdsIde/FlowFunctions.h" #include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h" #include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" #include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h index 73f9355ce6..55f266df6b 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSConstAnalysis.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IFDSCONSTANALYSIS_H #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" @@ -30,8 +32,6 @@ class Value; namespace psr { -class LLVMBasedICFG; - /** * This IFDS analysis will compute possibly mutable memory * locations (stack and heap). LLVM's virtual register diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSProtoAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSProtoAnalysis.h index fb1db483c9..e753cbc256 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSProtoAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSProtoAnalysis.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IFDSPROTOANALYSIS_H #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSignAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSignAnalysis.h index 54338de635..e320c30150 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSignAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSignAnalysis.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IFDSSIGNANALYSIS_H #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSolverTest.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSolverTest.h index edf176f775..b611e05d53 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSolverTest.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSSolverTest.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IFDSSOLVERTEST_H #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysis.h index c9e03340ab..27def5e527 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysis.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IFDSTAINTANALYSIS_H #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMFunctionDataFlowFacts.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.h index 8f5c8c04fb..c557ce2e44 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTypeAnalysis.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IFDSTYPEANALYSIS_H #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSUninitializedVariables.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSUninitializedVariables.h index 10046e0782..99696e85ac 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSUninitializedVariables.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSUninitializedVariables.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IFDSUNINITIALIZEDVARIABLES_H #include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include diff --git a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoFullConstantPropagation.h b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoFullConstantPropagation.h index d1e1ffce70..caca5a1990 100644 --- a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoFullConstantPropagation.h +++ b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoFullConstantPropagation.h @@ -12,6 +12,7 @@ #include "phasar/DataFlow/Mono/InterMonoProblem.h" #include "phasar/Domain/LatticeDomain.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" #include "phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoFullConstantPropagation.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" @@ -48,7 +49,6 @@ class InterMonoFullConstantPropagation using mono_container_t = IntraMonoFullConstantPropagation::mono_container_t; InterMonoFullConstantPropagation(const LLVMProjectIRDB *IRDB, - const DIBasedTypeHierarchy *TH, const LLVMBasedICFG *ICF, LLVMAliasInfoRef PT, std::vector EntryPoints = {}); diff --git a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoSolverTest.h b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoSolverTest.h index a280365a53..06d8cf76e0 100644 --- a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoSolverTest.h +++ b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoSolverTest.h @@ -18,6 +18,9 @@ #define PHASAR_PHASARLLVM_DATAFLOW_MONO_PROBLEMS_INTERMONOSOLVERTEST_H #include "phasar/DataFlow/Mono/InterMonoProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" #include "phasar/Utils/BitVectorSet.h" @@ -52,8 +55,7 @@ class InterMonoSolverTest : public InterMonoProblem { using i_t = InterMonoSolverTestDomain::i_t; using mono_container_t = InterMonoSolverTestDomain::mono_container_t; - InterMonoSolverTest(const LLVMProjectIRDB *IRDB, - const DIBasedTypeHierarchy *TH, const LLVMBasedICFG *ICF, + InterMonoSolverTest(const LLVMProjectIRDB *IRDB, const LLVMBasedICFG *ICF, LLVMAliasInfoRef PT, std::vector EntryPoints = {}); diff --git a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoTaintAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoTaintAnalysis.h index 7a78746ecf..e7391fc1e9 100644 --- a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoTaintAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/InterMonoTaintAnalysis.h @@ -19,6 +19,7 @@ #include "phasar/DataFlow/Mono/InterMonoProblem.h" #include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" #include "phasar/PhasarLLVM/TaintConfig/LLVMTaintConfig.h" @@ -55,10 +56,8 @@ class InterMonoTaintAnalysis using mono_container_t = InterMonoTaintAnalysisDomain::mono_container_t; using ConfigurationTy = LLVMTaintConfig; - InterMonoTaintAnalysis(const LLVMProjectIRDB *IRDB, - const DIBasedTypeHierarchy *TH, - const LLVMBasedICFG *ICF, LLVMAliasInfoRef PT, - const LLVMTaintConfig &Config, + InterMonoTaintAnalysis(const LLVMProjectIRDB *IRDB, const LLVMBasedICFG *ICF, + LLVMAliasInfoRef PT, const LLVMTaintConfig &Config, std::vector EntryPoints = {}); ~InterMonoTaintAnalysis() override = default; diff --git a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoFullConstantPropagation.h b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoFullConstantPropagation.h index 0bebfc4e68..9600657ed5 100644 --- a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoFullConstantPropagation.h +++ b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoFullConstantPropagation.h @@ -19,6 +19,8 @@ #include "phasar/DataFlow/Mono/IntraMonoProblem.h" #include "phasar/Domain/LatticeDomain.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" #include "phasar/Utils/BitVectorSet.h" @@ -81,7 +83,6 @@ class IntraMonoFullConstantPropagation public: IntraMonoFullConstantPropagation(const LLVMProjectIRDB *IRDB, - const DIBasedTypeHierarchy *TH, const LLVMBasedCFG *CF, LLVMAliasInfoRef PT, std::vector EntryPoints = {}); diff --git a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoSolverTest.h b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoSolverTest.h index 75e31f25ef..cc664a6b54 100644 --- a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoSolverTest.h +++ b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoSolverTest.h @@ -18,6 +18,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_MONO_PROBLEMS_INTRAMONOSOLVERTEST_H #include "phasar/DataFlow/Mono/IntraMonoProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" #include "phasar/Utils/BitVectorSet.h" @@ -54,8 +56,7 @@ class IntraMonoSolverTest using i_t = IntraMonoSolverTestAnalysisDomain::i_t; using mono_container_t = IntraMonoSolverTestAnalysisDomain::mono_container_t; - IntraMonoSolverTest(const LLVMProjectIRDB *IRDB, - const DIBasedTypeHierarchy *TH, const LLVMBasedCFG *CF, + IntraMonoSolverTest(const LLVMProjectIRDB *IRDB, const LLVMBasedCFG *CF, LLVMAliasInfoRef PT, std::vector EntryPoints = {}); diff --git a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoUninitVariables.h b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoUninitVariables.h index b08b91179c..d7894565f2 100644 --- a/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoUninitVariables.h +++ b/include/phasar/PhasarLLVM/DataFlow/Mono/Problems/IntraMonoUninitVariables.h @@ -11,6 +11,8 @@ #define PHASAR_PHASARLLVM_DATAFLOW_MONO_PROBLEMS_INTRAMONOUNINITVARIABLES_H #include "phasar/DataFlow/Mono/IntraMonoProblem.h" +#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h" +#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" #include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h" @@ -47,9 +49,8 @@ class IntraMonoUninitVariables using i_t = IntraMonoUninitVariablesDomain::i_t; using mono_container_t = IntraMonoUninitVariablesDomain::mono_container_t; - IntraMonoUninitVariables(const LLVMProjectIRDB *IRDB, - const DIBasedTypeHierarchy *TH, - const LLVMBasedCFG *CF, LLVMAliasInfoRef PT, + IntraMonoUninitVariables(const LLVMProjectIRDB *IRDB, const LLVMBasedCFG *CF, + LLVMAliasInfoRef PT, std::vector EntryPoints = {}); ~IntraMonoUninitVariables() override = default; diff --git a/include/phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h b/include/phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h index 80aadd85f9..45bf95f948 100644 --- a/include/phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h +++ b/include/phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h @@ -28,17 +28,27 @@ class LLVMProjectIRDB; class LLVMBasedICFG; class LLVMBasedCFG; +struct LLVMIRDomain { + using n_t = const llvm::Instruction *; + using f_t = const llvm::Function *; + using v_t = const llvm::Value *; + using t_t = const llvm::DIType *; + using db_t = LLVMProjectIRDB; +}; + /// \brief An AnalysisDomain that specializes sensible defaults for LLVM-based /// analysis struct LLVMAnalysisDomainDefault : public AnalysisDomain { + using ir_t = LLVMIRDomain; + using n_t = typename ir_t::n_t; + using f_t = typename ir_t::f_t; + using t_t = typename ir_t::t_t; + using v_t = typename ir_t::v_t; + using db_t = typename ir_t::db_t; + using d_t = const llvm::Value *; - using n_t = const llvm::Instruction *; - using f_t = const llvm::Function *; - using t_t = const llvm::DIType *; - using v_t = const llvm::Value *; using c_t = LLVMBasedCFG; using i_t = LLVMBasedICFG; - using db_t = LLVMProjectIRDB; }; /// \brief An AnalysisDomain that specializes sensible defaults for LLVM-based diff --git a/include/phasar/PhasarLLVM/SimpleAnalysisConstructor.h b/include/phasar/PhasarLLVM/SimpleAnalysisConstructor.h index e6e80094a9..ebc62aa065 100644 --- a/include/phasar/PhasarLLVM/SimpleAnalysisConstructor.h +++ b/include/phasar/PhasarLLVM/SimpleAnalysisConstructor.h @@ -57,6 +57,11 @@ ProblemTy createAnalysisProblem(HelperAnalyses &HA, ArgTys &&...Args) { return ProblemTy(&HA.getProjectIRDB(), &HA.getTypeHierarchy(), &HA.getICFG(), &HA.getAliasInfo(), std::forward(Args)...); + } else if constexpr (std::is_constructible_v< + ProblemTy, const LLVMProjectIRDB *, + const LLVMBasedCFG *, LLVMAliasSet *, ArgTys...>) { + return ProblemTy(&HA.getProjectIRDB(), &HA.getCFG(), &HA.getAliasInfo(), + std::forward(Args)...); } else { static_assert( std::is_constructible_v, diff --git a/include/phasar/Utils/TypeTraits.h b/include/phasar/Utils/TypeTraits.h index ffff49c225..579bb1c5a4 100644 --- a/include/phasar/Utils/TypeTraits.h +++ b/include/phasar/Utils/TypeTraits.h @@ -145,7 +145,7 @@ concept is_variant_v = is_variant::value; // NOLINT template // NOLINTNEXTLINE -concept is_string_like_v = std::is_convertible_v; +concept is_string_like_v = std::is_convertible_v; template