Skip to content

Commit 91b510a

Browse files
authored
Merge branch 'development' into f-FixRPath
2 parents 58d25d7 + 6744331 commit 91b510a

89 files changed

Lines changed: 3193 additions & 3863 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BreakingChanges.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## development HEAD
44

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

2533
## v1222
@@ -32,4 +40,4 @@
3240
- The type `WholeProgramAnalysis` has been removed. Use `AnalysisController` instead.
3341
- The IFDS and IDE TabulationProblems no longer take all of `LLVMProjectIRDB*`, `LLVMTypeHierarchy*`, `LLVMPointsToInfo*` and `LLVMBasedICFG*` as an argument. Instead, they only get what they need.
3442
- The `IFDSSolver` and `IDESolver` now take an instance of the `ICFGBase` interface as additional argument to their ctor (because the analysis problems now not necessarily store a reference to it anymore).
35-
- The `IDETabulationProblem` is now a base class of `IFDSTabulationProblem` (and not vice versa as it was previously). In their ctors they only take the bare minimum of arguments: The IRDB, the entrypoints and optionally the special zero-value. If the zero-value is not passed in the ctor (as it was previously), it has to be set from within the client analysis' ctor. You may use te new function `initializeZeroValue(d_t)` for this.
43+
- The `IDETabulationProblem` is now a base class of `IFDSTabulationProblem` (and not vice versa as it was previously). In their ctors they only take the bare minimum of arguments: The IRDB, the entrypoints and optionally the special zero-value. If the zero-value is not passed in the ctor (as it was previously), it has to be set from within the client analysis' ctor. You may use the new function `initializeZeroValue(d_t)` for this.

include/phasar/Config/Configuration.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class PhasarConfig {
3737
public:
3838
/// Current Phasar version
3939
// NOLINTNEXTLINE(readability-identifier-naming)
40-
[[nodiscard]] static constexpr llvm::StringRef PhasarVersion() noexcept {
41-
return XSTR(PHASAR_VERSION);
42-
}
40+
[[nodiscard]] static llvm::StringRef PhasarVersion() noexcept;
4341

4442
/// Stores the label/ tag with which we annotate the LLVM IR.
4543
// NOLINTNEXTLINE(readability-identifier-naming)
@@ -49,11 +47,9 @@ class PhasarConfig {
4947

5048
/// Specifies the directory in which important configuration files are
5149
/// located.
52-
[[nodiscard]] static constexpr llvm::StringRef
50+
[[nodiscard]] static llvm::StringRef
5351
// NOLINTNEXTLINE(readability-identifier-naming)
54-
GlobalConfigurationDirectory() noexcept {
55-
return PHASAR_CONFIG_DIR;
56-
}
52+
GlobalConfigurationDirectory() noexcept;
5753

5854
[[nodiscard]] static std::optional<llvm::StringRef>
5955
// NOLINTNEXTLINE(readability-identifier-naming)
@@ -75,9 +71,7 @@ class PhasarConfig {
7571

7672
/// Specifies the directory in which Phasar is located.
7773
// NOLINTNEXTLINE(readability-identifier-naming)
78-
[[nodiscard]] static constexpr llvm::StringRef PhasarDirectory() noexcept {
79-
return PHASAR_DIR;
80-
}
74+
[[nodiscard]] static llvm::StringRef PhasarDirectory() noexcept;
8175

8276
/// Name of the file storing all standard header search paths used for
8377
/// compilation.
@@ -95,11 +89,9 @@ class PhasarConfig {
9589
}
9690

9791
/// Default Source- and Sink-Functions path
98-
[[nodiscard]] static constexpr llvm::StringRef
92+
[[nodiscard]] static llvm::StringRef
9993
// NOLINTNEXTLINE(readability-identifier-naming)
100-
DefaultSourceSinkFunctionsPath() noexcept {
101-
return PHASAR_DIR "/config/phasar-source-sink-function.json";
102-
}
94+
DefaultSourceSinkFunctionsPath() noexcept;
10395

10496
// Variables to be used in JSON export format
10597
/// Identifier for call graph export
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/******************************************************************************
2+
* Copyright (c) 2022 Philipp Schubert.
3+
* All rights reserved. This program and the accompanying materials are made
4+
* available under the terms of LICENSE.txt.
5+
*
6+
* Contributors:
7+
* Philipp Schubert and others
8+
*****************************************************************************/
9+
10+
#ifndef PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_DEFAULTEDGEFUNCTIONSINGLETONCACHE_H
11+
#define PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_DEFAULTEDGEFUNCTIONSINGLETONCACHE_H
12+
13+
#include "phasar/DataFlow/IfdsIde/EdgeFunction.h"
14+
#include "phasar/DataFlow/IfdsIde/EdgeFunctionSingletonCache.h"
15+
16+
namespace psr {
17+
18+
/// Default implementation of EdgeFunctionSingletonCache.
19+
///
20+
/// For an edge function EdgeFunctionTy to be cached, it must be hashable, i.e.
21+
/// it must implement the friend- or nonmember function llvm::hash_code
22+
/// hash_value(const EdgeFunctionTy&).
23+
///
24+
/// This cache is *not* thread-safe.
25+
template <typename EdgeFunctionTy, typename = void>
26+
class DefaultEdgeFunctionSingletonCache
27+
: public EdgeFunctionSingletonCache<EdgeFunctionTy> {
28+
public:
29+
DefaultEdgeFunctionSingletonCache() noexcept = default;
30+
31+
DefaultEdgeFunctionSingletonCache(const DefaultEdgeFunctionSingletonCache &) =
32+
delete;
33+
DefaultEdgeFunctionSingletonCache &
34+
operator=(const DefaultEdgeFunctionSingletonCache &) = delete;
35+
36+
DefaultEdgeFunctionSingletonCache(
37+
DefaultEdgeFunctionSingletonCache &&) noexcept = default;
38+
DefaultEdgeFunctionSingletonCache &
39+
operator=(DefaultEdgeFunctionSingletonCache &&) noexcept = delete;
40+
~DefaultEdgeFunctionSingletonCache() override = default;
41+
42+
[[nodiscard]] const void *
43+
lookup(ByConstRef<EdgeFunctionTy> EF) const noexcept override {
44+
return Cache.lookup(&EF);
45+
}
46+
47+
void insert(const EdgeFunctionTy *EF, const void *Mem) override {
48+
assert(EF != nullptr);
49+
auto [It, Inserted] = Cache.try_emplace(EF, Mem);
50+
assert(Inserted);
51+
}
52+
53+
void erase(ByConstRef<EdgeFunctionTy> EF) noexcept override {
54+
Cache.erase(&EF);
55+
}
56+
57+
template <typename... ArgTys>
58+
[[nodiscard]] EdgeFunction<typename EdgeFunctionTy::l_t>
59+
createEdgeFunction(ArgTys &&...Args) {
60+
return CachedEdgeFunction<EdgeFunctionTy>{
61+
EdgeFunctionTy{std::forward<ArgTys>(Args)...}, this};
62+
}
63+
64+
private:
65+
struct DSI : public llvm::DenseMapInfo<const EdgeFunctionTy *> {
66+
static bool isEqual(const EdgeFunctionTy *LHS,
67+
const EdgeFunctionTy *RHS) noexcept {
68+
if (LHS == RHS) {
69+
return true;
70+
}
71+
auto Empty = llvm::DenseMapInfo<const EdgeFunctionTy *>::getEmptyKey();
72+
auto Tombstone =
73+
llvm::DenseMapInfo<const EdgeFunctionTy *>::getTombstoneKey();
74+
if (LHS == Empty || LHS == Tombstone || RHS == Empty ||
75+
RHS == Tombstone) {
76+
return false;
77+
}
78+
79+
return *LHS == *RHS;
80+
}
81+
82+
static auto getHashValue(const EdgeFunctionTy *EF) noexcept {
83+
assert(EF != llvm::DenseMapInfo<const EdgeFunctionTy *>::getEmptyKey());
84+
assert(EF !=
85+
llvm::DenseMapInfo<const EdgeFunctionTy *>::getTombstoneKey());
86+
87+
return hash_value(*EF);
88+
}
89+
};
90+
91+
llvm::DenseMap<const EdgeFunctionTy *, const void *, DSI> Cache;
92+
};
93+
94+
template <typename EdgeFunctionTy>
95+
class DefaultEdgeFunctionSingletonCache<
96+
EdgeFunctionTy,
97+
std::enable_if_t<EdgeFunctionBase::IsSOOCandidate<EdgeFunctionTy>>> {
98+
public:
99+
[[nodiscard]] const void *
100+
lookup(ByConstRef<EdgeFunctionTy> /*EF*/) const noexcept override {
101+
return nullptr;
102+
}
103+
void insert(const EdgeFunctionTy * /*EF*/, const void * /*Mem*/) override {
104+
assert(false && "We should never go here");
105+
}
106+
void erase(ByConstRef<EdgeFunctionTy> /*EF*/) noexcept override {
107+
assert(false && "We should never go here");
108+
}
109+
[[nodiscard]] EdgeFunction<typename EdgeFunctionTy::l_t>
110+
createEdgeFunction(EdgeFunctionTy EF) {
111+
return EF;
112+
}
113+
};
114+
115+
} // namespace psr
116+
117+
#endif // PHASAR_PHASARLLVM_DATAFLOWSOLVER_IFDSIDE_DEFAULTEDGEFUNCTIONSINGLETONCACHE_H

0 commit comments

Comments
 (0)