From 5f290c090a2404238a5b0ae4233f3ae9daec319e Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 24 Jan 2022 05:57:09 -0500 Subject: [PATCH] Move STLFunctionalExtras out of STLExtras Only using that change in StringRef already decreases the number of preoprocessed lines from 7837621 to 7776151 for LLVMSupport Perhaps more interestingly, it shows that many files were relying on the inclusion of StringRef.h to have the declaration from STLExtras.h. This patch tries hard to patch relevant part of llvm-project impacted by this hidden dependency removal. Potential impact: - "llvm/ADT/StringRef.h" no longer includes , "llvm/ADT/Optional.h" nor "llvm/ADT/STLExtras.h" Related Discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831 --- clang/include/clang/Basic/DirectoryEntry.h | 1 + clang/tools/diagtool/DiagTool.cpp | 1 + lld/ELF/Relocations.h | 1 + lldb/include/lldb/Utility/UserIDResolver.h | 1 + llvm/include/llvm/ADT/CombinationGenerator.h | 2 +- llvm/include/llvm/ADT/STLExtras.h | 61 +-------------- llvm/include/llvm/ADT/STLFunctionalExtras.h | 76 +++++++++++++++++++ llvm/include/llvm/ADT/SmallSet.h | 1 + llvm/include/llvm/ADT/SparseMultiSet.h | 2 +- llvm/include/llvm/ADT/SparseSet.h | 2 +- llvm/include/llvm/ADT/StringMap.h | 1 + llvm/include/llvm/ADT/StringMapEntry.h | 2 + llvm/include/llvm/ADT/StringRef.h | 11 +-- llvm/include/llvm/ADT/StringSwitch.h | 1 + llvm/include/llvm/ADT/identity.h | 34 +++++++++ .../ExecutionEngine/JITLink/MemoryFlags.h | 1 + llvm/include/llvm/IR/LLVMContext.h | 1 + llvm/include/llvm/MC/SubtargetFeature.h | 1 + .../llvm/Support/CrashRecoveryContext.h | 2 +- llvm/include/llvm/Support/JSON.h | 1 + llvm/include/llvm/Support/TimeProfiler.h | 1 + llvm/include/llvm/Support/Timer.h | 1 + llvm/include/llvm/Support/VirtualFileSystem.h | 1 + llvm/include/llvm/Support/raw_ostream.h | 1 + .../llvm/Testing/Support/Annotations.h | 2 + llvm/lib/CodeGen/NonRelocatableStringpool.cpp | 1 + llvm/lib/Support/CommandLine.cpp | 2 +- llvm/lib/Support/StringRef.cpp | 8 ++ llvm/lib/Support/TimeProfiler.cpp | 2 +- llvm/lib/Target/AMDGPU/AMDGPULibFunc.h | 1 + llvm/unittests/ADT/SequenceTest.cpp | 1 + llvm/unittests/ADT/SimpleIListTest.cpp | 1 + llvm/unittests/ADT/SmallPtrSetTest.cpp | 1 + llvm/unittests/ADT/StringMapTest.cpp | 1 + llvm/unittests/ADT/StringSetTest.cpp | 1 + .../Support/ReverseIterationTest.cpp | 1 + .../mlir/Conversion/GPUCommon/GPUCommonPass.h | 1 + mlir/lib/Parser/Token.h | 1 + 38 files changed, 158 insertions(+), 73 deletions(-) create mode 100644 llvm/include/llvm/ADT/STLFunctionalExtras.h create mode 100644 llvm/include/llvm/ADT/identity.h diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h index edb8031a20b8..ac8e790230fc 100644 --- a/clang/include/clang/Basic/DirectoryEntry.h +++ b/clang/include/clang/Basic/DirectoryEntry.h @@ -19,6 +19,7 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorOr.h" namespace clang { diff --git a/clang/tools/diagtool/DiagTool.cpp b/clang/tools/diagtool/DiagTool.cpp index 81d4e7e44ccc..99abe5755f71 100644 --- a/clang/tools/diagtool/DiagTool.cpp +++ b/clang/tools/diagtool/DiagTool.cpp @@ -12,6 +12,7 @@ #include "DiagTool.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/STLExtras.h" #include using namespace diagtool; diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h index f9909f236d12..73f6970b80f1 100644 --- a/lld/ELF/Relocations.h +++ b/lld/ELF/Relocations.h @@ -11,6 +11,7 @@ #include "lld/Common/LLVM.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/STLExtras.h" #include #include diff --git a/lldb/include/lldb/Utility/UserIDResolver.h b/lldb/include/lldb/Utility/UserIDResolver.h index e0f7b69cc075..15afafd65a1a 100644 --- a/lldb/include/lldb/Utility/UserIDResolver.h +++ b/lldb/include/lldb/Utility/UserIDResolver.h @@ -10,6 +10,7 @@ #define LLDB_UTILITY_USERIDRESOLVER_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include diff --git a/llvm/include/llvm/ADT/CombinationGenerator.h b/llvm/include/llvm/ADT/CombinationGenerator.h index ab6afd555726..a0bec68eaad6 100644 --- a/llvm/include/llvm/ADT/CombinationGenerator.h +++ b/llvm/include/llvm/ADT/CombinationGenerator.h @@ -28,7 +28,7 @@ #define LLVM_ADT_COMBINATIONGENERATOR_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/SmallVector.h" #include #include diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index ed5321821a3a..c3200c926518 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -16,8 +16,10 @@ #ifndef LLVM_ADT_STLEXTRAS_H #define LLVM_ADT_STLEXTRAS_H +#include "llvm/ADT/identity.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/STLForwardCompat.h" +#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Config/abi-breaking.h" @@ -199,65 +201,6 @@ struct FirstIndexOfType : std::integral_constant {}; template using TypeAtIndex = std::tuple_element_t>; -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -template struct identity { - using argument_type = Ty; - - Ty &operator()(Ty &self) const { - return self; - } - const Ty &operator()(const Ty &self) const { - return self; - } -}; - -/// An efficient, type-erasing, non-owning reference to a callable. This is -/// intended for use as the type of a function parameter that is not used -/// after the function in question returns. -/// -/// This class does not own the callable, so it is not in general safe to store -/// a function_ref. -template class function_ref; - -template -class function_ref { - Ret (*callback)(intptr_t callable, Params ...params) = nullptr; - intptr_t callable; - - template - static Ret callback_fn(intptr_t callable, Params ...params) { - return (*reinterpret_cast(callable))( - std::forward(params)...); - } - -public: - function_ref() = default; - function_ref(std::nullptr_t) {} - - template - function_ref( - Callable &&callable, - // This is not the copy-constructor. - std::enable_if_t, - function_ref>::value> * = nullptr, - // Functor must be callable and return a suitable type. - std::enable_if_t::value || - std::is_convertible()( - std::declval()...)), - Ret>::value> * = nullptr) - : callback(callback_fn::type>), - callable(reinterpret_cast(&callable)) {} - - Ret operator()(Params ...params) const { - return callback(callable, std::forward(params)...); - } - - explicit operator bool() const { return callback; } -}; - //===----------------------------------------------------------------------===// // Extra additions to //===----------------------------------------------------------------------===// diff --git a/llvm/include/llvm/ADT/STLFunctionalExtras.h b/llvm/include/llvm/ADT/STLFunctionalExtras.h new file mode 100644 index 000000000000..ebe1b1521a5d --- /dev/null +++ b/llvm/include/llvm/ADT/STLFunctionalExtras.h @@ -0,0 +1,76 @@ +//===- llvm/ADT/STLFunctionalExtras.h - Extras for -*- 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 +// +//===----------------------------------------------------------------------===// +// +// This file contains some extension to . +// +// No library is required when using these functions. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_STLFUNCTIONALEXTRAS_H +#define LLVM_ADT_STLFUNCTIONALEXTRAS_H + +#include "llvm/ADT/STLForwardCompat.h" + +#include +#include +#include + +namespace llvm { + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +/// An efficient, type-erasing, non-owning reference to a callable. This is +/// intended for use as the type of a function parameter that is not used +/// after the function in question returns. +/// +/// This class does not own the callable, so it is not in general safe to store +/// a function_ref. +template class function_ref; + +template +class function_ref { + Ret (*callback)(intptr_t callable, Params ...params) = nullptr; + intptr_t callable; + + template + static Ret callback_fn(intptr_t callable, Params ...params) { + return (*reinterpret_cast(callable))( + std::forward(params)...); + } + +public: + function_ref() = default; + function_ref(std::nullptr_t) {} + + template + function_ref( + Callable &&callable, + // This is not the copy-constructor. + std::enable_if_t, + function_ref>::value> * = nullptr, + // Functor must be callable and return a suitable type. + std::enable_if_t::value || + std::is_convertible()( + std::declval()...)), + Ret>::value> * = nullptr) + : callback(callback_fn::type>), + callable(reinterpret_cast(&callable)) {} + + Ret operator()(Params ...params) const { + return callback(callable, std::forward(params)...); + } + + explicit operator bool() const { return callback; } +}; + +} // end namespace llvm + +#endif // LLVM_ADT_STLFUNCTIONALEXTRAS_H diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h index 0600e528ee69..fe4f74eac85d 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h @@ -16,6 +16,7 @@ #include "llvm/ADT/None.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/iterator.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/type_traits.h" diff --git a/llvm/include/llvm/ADT/SparseMultiSet.h b/llvm/include/llvm/ADT/SparseMultiSet.h index fec0a70a0bef..f63cef936433 100644 --- a/llvm/include/llvm/ADT/SparseMultiSet.h +++ b/llvm/include/llvm/ADT/SparseMultiSet.h @@ -20,7 +20,7 @@ #ifndef LLVM_ADT_SPARSEMULTISET_H #define LLVM_ADT_SPARSEMULTISET_H -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/identity.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SparseSet.h" #include diff --git a/llvm/include/llvm/ADT/SparseSet.h b/llvm/include/llvm/ADT/SparseSet.h index d8acf1ee2f3a..e66d76ad88e1 100644 --- a/llvm/include/llvm/ADT/SparseSet.h +++ b/llvm/include/llvm/ADT/SparseSet.h @@ -19,7 +19,7 @@ #ifndef LLVM_ADT_SPARSESET_H #define LLVM_ADT_SPARSESET_H -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/identity.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/AllocatorBase.h" #include diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h index 669956d41e0c..562a2ff1a192 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -14,6 +14,7 @@ #define LLVM_ADT_STRINGMAP_H #include "llvm/ADT/StringMapEntry.h" +#include "llvm/ADT/iterator.h" #include "llvm/Support/AllocatorBase.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h index 8bfad5540230..120d4f3ca4bc 100644 --- a/llvm/include/llvm/ADT/StringMapEntry.h +++ b/llvm/include/llvm/ADT/StringMapEntry.h @@ -15,7 +15,9 @@ #ifndef LLVM_ADT_STRINGMAPENTRY_H #define LLVM_ADT_STRINGMAPENTRY_H +#include "llvm/ADT/None.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/STLFunctionalExtras.h" namespace llvm { diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h index 9f64250c58a3..118def2f43e1 100644 --- a/llvm/include/llvm/ADT/StringRef.h +++ b/llvm/include/llvm/ADT/StringRef.h @@ -9,7 +9,8 @@ #ifndef LLVM_ADT_STRINGREF_H #define LLVM_ADT_STRINGREF_H -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Compiler.h" #include @@ -978,13 +979,7 @@ namespace llvm { reinterpret_cast(~static_cast(1)), 0); } - static unsigned getHashValue(StringRef Val) { - assert(Val.data() != getEmptyKey().data() && - "Cannot hash the empty key!"); - assert(Val.data() != getTombstoneKey().data() && - "Cannot hash the tombstone key!"); - return (unsigned)(hash_value(Val)); - } + static unsigned getHashValue(StringRef Val); static bool isEqual(StringRef LHS, StringRef RHS) { if (RHS.data() == getEmptyKey().data()) diff --git a/llvm/include/llvm/ADT/StringSwitch.h b/llvm/include/llvm/ADT/StringSwitch.h index 726d67c8f24a..4b7882d7ca10 100644 --- a/llvm/include/llvm/ADT/StringSwitch.h +++ b/llvm/include/llvm/ADT/StringSwitch.h @@ -12,6 +12,7 @@ #ifndef LLVM_ADT_STRINGSWITCH_H #define LLVM_ADT_STRINGSWITCH_H +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" #include diff --git a/llvm/include/llvm/ADT/identity.h b/llvm/include/llvm/ADT/identity.h new file mode 100644 index 000000000000..f07bb6fb39f6 --- /dev/null +++ b/llvm/include/llvm/ADT/identity.h @@ -0,0 +1,34 @@ +//===- llvm/ADT/Identity.h - Provide std::identity from C++20 ---*- 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 +// +//===----------------------------------------------------------------------===// +// +// This file provides an implementation of std::identity from C++20. +// +// No library is required when using these functions. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_IDENTITY_H +#define LLVM_ADT_IDENTITY_H + + +namespace llvm { + +template struct identity { + using argument_type = Ty; + + Ty &operator()(Ty &self) const { + return self; + } + const Ty &operator()(const Ty &self) const { + return self; + } +}; + +} // end namespace llvm + +#endif // LLVM_ADT_IDENTITY_H diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/MemoryFlags.h b/llvm/include/llvm/ExecutionEngine/JITLink/MemoryFlags.h index 8fdce93ebc56..e9771319ef06 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/MemoryFlags.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/MemoryFlags.h @@ -16,6 +16,7 @@ #include "llvm/ADT/BitmaskEnum.h" #include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/Memory.h" #include "llvm/Support/raw_ostream.h" diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h index 12d3a45171ce..d165a405ce22 100644 --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -15,6 +15,7 @@ #define LLVM_IR_LLVMCONTEXT_H #include "llvm-c/Types.h" +#include "llvm/ADT/Optional.h" #include "llvm/IR/DiagnosticHandler.h" #include "llvm/Support/CBindingWrapping.h" #include diff --git a/llvm/include/llvm/MC/SubtargetFeature.h b/llvm/include/llvm/MC/SubtargetFeature.h index cc36b25a4965..032e2a7df1f2 100644 --- a/llvm/include/llvm/MC/SubtargetFeature.h +++ b/llvm/include/llvm/MC/SubtargetFeature.h @@ -18,6 +18,7 @@ #define LLVM_MC_SUBTARGETFEATURE_H #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" #include #include diff --git a/llvm/include/llvm/Support/CrashRecoveryContext.h b/llvm/include/llvm/Support/CrashRecoveryContext.h index 2604ccb38431..f60e7335e197 100644 --- a/llvm/include/llvm/Support/CrashRecoveryContext.h +++ b/llvm/include/llvm/Support/CrashRecoveryContext.h @@ -9,7 +9,7 @@ #ifndef LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H #define LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLFunctionalExtras.h" namespace llvm { class CrashRecoveryContextCleanup; diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h index 469f50be40e0..719e8b60d0fa 100644 --- a/llvm/include/llvm/Support/JSON.h +++ b/llvm/include/llvm/Support/JSON.h @@ -49,6 +49,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/raw_ostream.h" diff --git a/llvm/include/llvm/Support/TimeProfiler.h b/llvm/include/llvm/Support/TimeProfiler.h index 6141acc99db2..378253dc2ab9 100644 --- a/llvm/include/llvm/Support/TimeProfiler.h +++ b/llvm/include/llvm/Support/TimeProfiler.h @@ -10,6 +10,7 @@ #define LLVM_SUPPORT_TIMEPROFILER_H #include "llvm/Support/Error.h" +#include "llvm/ADT/STLFunctionalExtras.h" namespace llvm { diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h index 5a55491b3276..eb49e805b40d 100644 --- a/llvm/include/llvm/Support/Timer.h +++ b/llvm/include/llvm/Support/Timer.h @@ -13,6 +13,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include +#include #include #include diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h index 305096dff67e..f5dde334b0a7 100644 --- a/llvm/include/llvm/Support/VirtualFileSystem.h +++ b/llvm/include/llvm/Support/VirtualFileSystem.h @@ -19,6 +19,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/Support/Chrono.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h index e288ac27e804..58adb41cb0ef 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -15,6 +15,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Optional.h" #include "llvm/Support/DataTypes.h" #include #include diff --git a/llvm/include/llvm/Testing/Support/Annotations.h b/llvm/include/llvm/Testing/Support/Annotations.h index cc99d1061520..4e442269600d 100644 --- a/llvm/include/llvm/Testing/Support/Annotations.h +++ b/llvm/include/llvm/Testing/Support/Annotations.h @@ -16,6 +16,8 @@ namespace llvm { +class raw_ostream; + /// Annotations lets you mark points and ranges inside source code, for tests: /// /// Annotations Example(R"cpp( diff --git a/llvm/lib/CodeGen/NonRelocatableStringpool.cpp b/llvm/lib/CodeGen/NonRelocatableStringpool.cpp index 9ed3471c0fc9..db5217469fba 100644 --- a/llvm/lib/CodeGen/NonRelocatableStringpool.cpp +++ b/llvm/lib/CodeGen/NonRelocatableStringpool.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/NonRelocatableStringpool.h" +#include "llvm/ADT/STLExtras.h" namespace llvm { diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 481ba56c4077..ed4f01f176c2 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -22,7 +22,7 @@ #include "llvm-c/Support.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index 652303fdb6a0..3ed08ed38661 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/llvm/lib/Support/StringRef.cpp @@ -597,3 +597,11 @@ bool StringRef::getAsDouble(double &Result, bool AllowInexact) const { hash_code llvm::hash_value(StringRef S) { return hash_combine_range(S.begin(), S.end()); } + +unsigned DenseMapInfo::getHashValue(StringRef Val) { + assert(Val.data() != getEmptyKey().data() && + "Cannot hash the empty key!"); + assert(Val.data() != getTombstoneKey().data() && + "Cannot hash the tombstone key!"); + return (unsigned)(hash_value(Val)); +} diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp index a727bfa51731..9380fa01c84a 100644 --- a/llvm/lib/Support/TimeProfiler.cpp +++ b/llvm/lib/Support/TimeProfiler.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/TimeProfiler.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/JSON.h" #include "llvm/Support/ManagedStatic.h" diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h index c97223b047e8..dc0ac72016f3 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h +++ b/llvm/lib/Target/AMDGPU/AMDGPULibFunc.h @@ -10,6 +10,7 @@ #define _AMDGPU_LIBFUNC_H_ #include "llvm/ADT/StringRef.h" +#include namespace llvm { diff --git a/llvm/unittests/ADT/SequenceTest.cpp b/llvm/unittests/ADT/SequenceTest.cpp index 71fae0b56ffd..aec1ea457aeb 100644 --- a/llvm/unittests/ADT/SequenceTest.cpp +++ b/llvm/unittests/ADT/SequenceTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/Sequence.h" +#include "llvm/ADT/STLExtras.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/ADT/SimpleIListTest.cpp b/llvm/unittests/ADT/SimpleIListTest.cpp index 238896eaefbb..17dd140c0a4d 100644 --- a/llvm/unittests/ADT/SimpleIListTest.cpp +++ b/llvm/unittests/ADT/SimpleIListTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/simple_ilist.h" +#include "llvm/ADT/STLExtras.h" #include "gtest/gtest.h" using namespace llvm; diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp index 6f3c94eed273..414298c4e67d 100644 --- a/llvm/unittests/ADT/SmallPtrSetTest.cpp +++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp @@ -12,6 +12,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp index f38a60452e3c..817fec6c37a2 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/DataTypes.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/ADT/StringSetTest.cpp b/llvm/unittests/ADT/StringSetTest.cpp index 0071f5a3775b..413314976ac2 100644 --- a/llvm/unittests/ADT/StringSetTest.cpp +++ b/llvm/unittests/ADT/StringSetTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringSet.h" +#include "llvm/ADT/STLExtras.h" #include "gtest/gtest.h" using namespace llvm; diff --git a/llvm/unittests/Support/ReverseIterationTest.cpp b/llvm/unittests/Support/ReverseIterationTest.cpp index 657368283efc..f199e21a2362 100644 --- a/llvm/unittests/Support/ReverseIterationTest.cpp +++ b/llvm/unittests/Support/ReverseIterationTest.cpp @@ -13,6 +13,7 @@ #include "llvm/Support/ReverseIteration.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/STLExtras.h" #include "gtest/gtest.h" using namespace llvm; diff --git a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h index a87158658d83..c43eb24973bc 100644 --- a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h +++ b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h @@ -10,6 +10,7 @@ #include "mlir/Support/LLVM.h" #include "llvm/ADT/StringRef.h" +#include #include namespace llvm { diff --git a/mlir/lib/Parser/Token.h b/mlir/lib/Parser/Token.h index ad9c23cd60be..c086a0a194b9 100644 --- a/mlir/lib/Parser/Token.h +++ b/mlir/lib/Parser/Token.h @@ -10,6 +10,7 @@ #define MLIR_LIB_PARSER_TOKEN_H #include "mlir/Support/LLVM.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/SMLoc.h"