11#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_UTILS_H
12#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_UTILS_H
14#include "llvm/ADT/ImmutableMap.h"
15#include "llvm/ADT/ImmutableSet.h"
21template <
typename Tag>
struct ID {
32 void Profile(llvm::FoldingSetNodeID &IDBuilder)
const {
33 IDBuilder.AddInteger(
Value);
39static llvm::ImmutableSet<T>
join(llvm::ImmutableSet<T> A,
40 llvm::ImmutableSet<T> B,
41 typename llvm::ImmutableSet<T>::Factory &F) {
42 if (A.getHeight() < B.getHeight())
69template <
typename K,
typename V,
typename Joiner>
70static llvm::ImmutableMap<K, V>
71join(
const llvm::ImmutableMap<K, V> &A,
const llvm::ImmutableMap<K, V> &B,
72 typename llvm::ImmutableMap<K, V>::Factory &F, Joiner JoinValues,
74 if (A.getHeight() < B.getHeight())
75 return join(B, A, F, JoinValues, Kind);
79 llvm::ImmutableMap<K, V> Res = A;
80 for (
const auto &Entry : B) {
81 const K &Key = Entry.first;
82 const V &ValB = Entry.second;
83 Res = F.add(Res, Key, JoinValues(A.lookup(Key), &ValB));
86 for (
const auto &Entry : A) {
87 const K &Key = Entry.first;
88 const V &ValA = Entry.second;
90 Res = F.add(Res, Key, JoinValues(&ValA,
nullptr));
98template <
typename Tag>
99struct DenseMapInfo<
clang::lifetimes::internal::utils::ID<Tag>> {
103 return {DenseMapInfo<uint32_t>::getEmptyKey()};
107 return {DenseMapInfo<uint32_t>::getTombstoneKey()};
111 return DenseMapInfo<uint32_t>::getHashValue(Val.
Value);
114 static bool isEqual(
const ID &LHS,
const ID &RHS) {
return LHS == RHS; }
JoinKind
Describes the strategy for joining two ImmutableMap instances, primarily differing in how they handle...
@ Asymmetric
An asymmetric join preserves keys unique to the first map as-is, while applying the JoinValues operat...
@ Symmetric
A symmetric join applies the JoinValues operation to keys unique to either map, ensuring that values ...
static llvm::ImmutableSet< T > join(llvm::ImmutableSet< T > A, llvm::ImmutableSet< T > B, typename llvm::ImmutableSet< T >::Factory &F)
Computes the union of two ImmutableSets.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
A generic, type-safe wrapper for an ID, distinguished by its Tag type.
ID< Tag > operator++(int)
bool operator!=(const ID< Tag > &Other) const
void Profile(llvm::FoldingSetNodeID &IDBuilder) const
bool operator<(const ID< Tag > &Other) const
bool operator==(const ID< Tag > &Other) const
static bool isEqual(const ID &LHS, const ID &RHS)
clang::lifetimes::internal::utils::ID< Tag > ID
static unsigned getHashValue(const ID &Val)
static ID getTombstoneKey()