Files
swift-mirror/include/swift/Basic/LLVMExtras.h
Evan Wilde 309aed4925 Add SmallSetVector replacement
llvm::SmallSetVector changed semantics
(https://reviews.llvm.org/D152497) resulting in build failures in Swift.
The old semantics allowed usage of types that did not have an
`operator==` because `SmallDenseSet` uses `DenseSetInfo<T>::isEqual` to
determine equality. The new implementation switched to using
`std::find`, which internally uses `operator==`. This type is used
pretty frequently with `swift::Type`, which intentionally deletes
`operator==` as it is not the canonical type and therefore cannot be
compared in normal circumstances.

This patch adds a new type-alias to the Swift namespace that provides
the old semantic behavior for `SmallSetVector`. I've also gone through
and replaced usages of `llvm::SmallSetVector` with the
`Swift::SmallSetVector` in places where we're storing a type that
doesn't implement or explicitly deletes `operator==`. The changes to
`llvm::SmallSetVector` should improve compile-time performance, so I
left the `llvm::SmallSetVector` where possible.
2023-07-25 12:28:27 -07:00

37 lines
1.2 KiB
C++

//===--- LLVMExtras.h -----------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file provides additional functionality on top of LLVM types
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_LLVMEXTRAS_H
#define SWIFT_BASIC_LLVMEXTRAS_H
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
namespace swift {
/// A SetVector that does no allocations under the specified size
///
/// swift::SmallSetVector provides the old SmallSetVector semantics that allow
/// storing types that don't have `operator==`.
template <typename T, unsigned N>
using SmallSetVector = llvm::SetVector<T, llvm::SmallVector<T, N>,
llvm::SmallDenseSet<T, N, llvm::DenseMapInfo<T>>>;
} // namespace swift
#endif // SWIFT_BASIC_LLVMEXTRAS_H