Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h =================================================================== --- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h +++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h @@ -26,10 +26,12 @@ #include "clang/Tooling/Inclusions/StandardLibrary.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseMapInfoVariant.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include #include +#include #include namespace llvm { Index: llvm/include/llvm/ADT/DenseMapInfo.h =================================================================== --- llvm/include/llvm/ADT/DenseMapInfo.h +++ llvm/include/llvm/ADT/DenseMapInfo.h @@ -20,7 +20,6 @@ #include #include #include -#include namespace llvm { @@ -234,6 +233,14 @@ SecondInfo::getHashValue(PairVal.second)); } + // Expose an additional function intended to be used by other + // specializations of DenseMapInfo without needing to know how + // to combine hash values manually + static unsigned getHashValuePiecewise(const T& First, const U& Second) { + return detail::combineHashValue(FirstInfo::getHashValue(First), + SecondInfo::getHashValue(Second)); + } + static bool isEqual(const Pair &LHS, const Pair &RHS) { return FirstInfo::isEqual(LHS.first, RHS.first) && SecondInfo::isEqual(LHS.second, RHS.second); @@ -290,37 +297,6 @@ } }; -// Provide DenseMapInfo for variants whose all alternatives have DenseMapInfo. -template struct DenseMapInfo> { - using Variant = std::variant; - using FirstT = std::variant_alternative_t<0, Variant>; - - static inline Variant getEmptyKey() { - return Variant(std::in_place_index<0>, DenseMapInfo::getEmptyKey()); - } - - static inline Variant getTombstoneKey() { - return Variant(std::in_place_index<0>, - DenseMapInfo::getTombstoneKey()); - } - - static unsigned getHashValue(const Variant &Val) { - return std::visit( - [&Val](auto &&Alternative) { - using T = std::decay_t; - // Include index in hash to make sure same value as different - // alternatives don't collide. - return detail::combineHashValue( - DenseMapInfo::getHashValue(Val.index()), - DenseMapInfo::getHashValue(Alternative)); - }, - Val); - } - - static bool isEqual(const Variant &LHS, const Variant &RHS) { - return LHS == RHS; - } -}; } // end namespace llvm #endif // LLVM_ADT_DENSEMAPINFO_H Index: llvm/include/llvm/ADT/DenseMapInfoVariant.h =================================================================== --- /dev/null +++ llvm/include/llvm/ADT/DenseMapInfoVariant.h @@ -0,0 +1,56 @@ +//===- DenseMapInfoVariant.h - Type traits for DenseMap *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// This file defines DenseMapInfo traits for DenseMap>. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_DENSEMAPINFOVARIANT_H +#define LLVM_ADT_DENSEMAPINFOVARIANT_H + +#include "llvm/ADT/DenseMapInfo.h" +#include +#include + +namespace llvm { + +// Provide DenseMapInfo for variants whose all alternatives have DenseMapInfo. +template struct DenseMapInfo> { + using Variant = std::variant; + using FirstT = std::variant_alternative_t<0, Variant>; + + static inline Variant getEmptyKey() { + return Variant(std::in_place_index<0>, DenseMapInfo::getEmptyKey()); + } + + static inline Variant getTombstoneKey() { + return Variant(std::in_place_index<0>, + DenseMapInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const Variant &Val) { + return std::visit( + [&Val](auto &&Alternative) { + using T = std::decay_t; + // Include index in hash to make sure same value as different + // alternatives don't collide. + return DenseMapInfo>::getHashValuePiecewise( + Val.index(), Alternative); + }, + Val); + } + + static bool isEqual(const Variant &LHS, const Variant &RHS) { + return LHS == RHS; + } +}; + +} // end namespace llvm + +#endif // LLVM_ADT_DENSEMAPINFOVARIANT_H Index: llvm/include/llvm/CodeGen/CallingConvLower.h =================================================================== --- llvm/include/llvm/CodeGen/CallingConvLower.h +++ llvm/include/llvm/CodeGen/CallingConvLower.h @@ -19,6 +19,7 @@ #include "llvm/CodeGen/TargetCallingConv.h" #include "llvm/IR/CallingConv.h" #include "llvm/Support/Alignment.h" +#include namespace llvm { Index: llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h =================================================================== --- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -22,6 +22,7 @@ #include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ThreadPool.h" +#include namespace llvm { namespace orc { Index: llvm/include/llvm/Object/DXContainer.h =================================================================== --- llvm/include/llvm/Object/DXContainer.h +++ llvm/include/llvm/Object/DXContainer.h @@ -21,6 +21,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBufferRef.h" #include "llvm/TargetParser/Triple.h" +#include namespace llvm { namespace object { Index: llvm/include/llvm/Transforms/Scalar/SROA.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/SROA.h +++ llvm/include/llvm/Transforms/Scalar/SROA.h @@ -21,6 +21,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/ValueHandle.h" +#include #include namespace llvm { Index: mlir/include/mlir/IR/AsmState.h =================================================================== --- mlir/include/mlir/IR/AsmState.h +++ mlir/include/mlir/IR/AsmState.h @@ -20,6 +20,7 @@ #include "llvm/ADT/StringMap.h" #include +#include namespace mlir { class AsmResourcePrinter;