diff --git a/clang/include/clang/AST/ComparisonCategories.h b/clang/include/clang/AST/ComparisonCategories.h --- a/clang/include/clang/AST/ComparisonCategories.h +++ b/clang/include/clang/AST/ComparisonCategories.h @@ -19,6 +19,7 @@ #include "llvm/ADT/DenseMap.h" #include #include +#include namespace llvm { class StringRef; diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h --- a/llvm/include/llvm/ADT/ArrayRef.h +++ b/llvm/include/llvm/ADT/ArrayRef.h @@ -26,6 +26,8 @@ namespace llvm { + template struct DenseMapInfo; + /// ArrayRef - Represent a constant reference to an array (0 or more elements /// consecutively in memory), i.e. a start pointer and a length. It allows /// various APIs to take consecutive elements easily and conveniently. @@ -569,6 +571,35 @@ return hash_combine_range(S.begin(), S.end()); } + // Provide DenseMapInfo for ArrayRefs. + template struct DenseMapInfo> { + static inline ArrayRef getEmptyKey() { + return ArrayRef( + reinterpret_cast(~static_cast(0)), size_t(0)); + } + + static inline ArrayRef getTombstoneKey() { + return ArrayRef( + reinterpret_cast(~static_cast(1)), size_t(0)); + } + + static unsigned getHashValue(ArrayRef 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 bool isEqual(ArrayRef LHS, ArrayRef RHS) { + if (RHS.data() == getEmptyKey().data()) + return LHS.data() == getEmptyKey().data(); + if (RHS.data() == getTombstoneKey().data()) + return LHS.data() == getTombstoneKey().data(); + return LHS == RHS; + } + }; + } // end namespace llvm #endif // LLVM_ADT_ARRAYREF_H diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -13,9 +13,7 @@ #ifndef LLVM_ADT_DENSEMAPINFO_H #define LLVM_ADT_DENSEMAPINFO_H -#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/StringRef.h" #include #include #include @@ -284,62 +282,6 @@ } }; -// Provide DenseMapInfo for StringRefs. -template <> struct DenseMapInfo { - static inline StringRef getEmptyKey() { - return StringRef(reinterpret_cast(~static_cast(0)), - 0); - } - - static inline StringRef getTombstoneKey() { - return StringRef(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 bool isEqual(StringRef LHS, StringRef RHS) { - if (RHS.data() == getEmptyKey().data()) - return LHS.data() == getEmptyKey().data(); - if (RHS.data() == getTombstoneKey().data()) - return LHS.data() == getTombstoneKey().data(); - return LHS == RHS; - } -}; - -// Provide DenseMapInfo for ArrayRefs. -template struct DenseMapInfo> { - static inline ArrayRef getEmptyKey() { - return ArrayRef(reinterpret_cast(~static_cast(0)), - size_t(0)); - } - - static inline ArrayRef getTombstoneKey() { - return ArrayRef(reinterpret_cast(~static_cast(1)), - size_t(0)); - } - - static unsigned getHashValue(ArrayRef 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 bool isEqual(ArrayRef LHS, ArrayRef RHS) { - if (RHS.data() == getEmptyKey().data()) - return LHS.data() == getEmptyKey().data(); - if (RHS.data() == getTombstoneKey().data()) - return LHS.data() == getTombstoneKey().data(); - return LHS == RHS; - } -}; - template <> struct DenseMapInfo { static inline hash_code getEmptyKey() { return hash_code(-1); } static inline hash_code getTombstoneKey() { return hash_code(-2); } diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h --- a/llvm/include/llvm/ADT/StringRef.h +++ b/llvm/include/llvm/ADT/StringRef.h @@ -35,6 +35,7 @@ class APInt; class hash_code; template class SmallVectorImpl; + template struct DenseMapInfo; class StringRef; /// Helper functions for StringRef::getAsInteger. @@ -925,6 +926,35 @@ LLVM_NODISCARD hash_code hash_value(StringRef S); + // Provide DenseMapInfo for StringRefs. + template <> struct DenseMapInfo { + static inline StringRef getEmptyKey() { + return StringRef( + reinterpret_cast(~static_cast(0)), 0); + } + + static inline StringRef getTombstoneKey() { + return StringRef( + 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 bool isEqual(StringRef LHS, StringRef RHS) { + if (RHS.data() == getEmptyKey().data()) + return LHS.data() == getEmptyKey().data(); + if (RHS.data() == getTombstoneKey().data()) + return LHS.data() == getTombstoneKey().data(); + return LHS == RHS; + } + }; + } // end namespace llvm #endif // LLVM_ADT_STRINGREF_H diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h --- a/llvm/include/llvm/IR/PassInstrumentation.h +++ b/llvm/include/llvm/IR/PassInstrumentation.h @@ -54,6 +54,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include +#include namespace llvm { diff --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h --- a/llvm/include/llvm/Support/Threading.h +++ b/llvm/include/llvm/Support/Threading.h @@ -17,6 +17,7 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #include "llvm/Support/Compiler.h" #include // So we can check the C++ standard lib macros. diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.h b/llvm/lib/CodeGen/AsmPrinter/WinException.h --- a/llvm/lib/CodeGen/AsmPrinter/WinException.h +++ b/llvm/lib/CodeGen/AsmPrinter/WinException.h @@ -14,6 +14,7 @@ #define LLVM_LIB_CODEGEN_ASMPRINTER_WIN64EXCEPTION_H #include "EHStreamer.h" +#include namespace llvm { class GlobalValue; diff --git a/llvm/lib/CodeGen/MBFIWrapper.cpp b/llvm/lib/CodeGen/MBFIWrapper.cpp --- a/llvm/lib/CodeGen/MBFIWrapper.cpp +++ b/llvm/lib/CodeGen/MBFIWrapper.cpp @@ -11,8 +11,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/MBFIWrapper.h" +#include "llvm/ADT/Optional.h" #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" +#include "llvm/CodeGen/MBFIWrapper.h" using namespace llvm; diff --git a/llvm/lib/MC/StringTableBuilder.cpp b/llvm/lib/MC/StringTableBuilder.cpp --- a/llvm/lib/MC/StringTableBuilder.cpp +++ b/llvm/lib/MC/StringTableBuilder.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/StringTableBuilder.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/CachedHashString.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp --- a/llvm/lib/Support/SmallPtrSet.cpp +++ b/llvm/lib/Support/SmallPtrSet.cpp @@ -13,8 +13,9 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/DenseMapInfo.h" -#include "llvm/Support/MathExtras.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Support/MemAlloc.h" #include #include #include diff --git a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h --- a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUGLOBALISELUTILS_H #define LLVM_LIB_TARGET_AMDGPU_AMDGPUGLOBALISELUTILS_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/CodeGen/Register.h" #include diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp --- a/llvm/tools/llvm-c-test/echo.cpp +++ b/llvm/tools/llvm-c-test/echo.cpp @@ -18,6 +18,7 @@ #include "llvm-c/DebugInfo.h" #include "llvm-c/Target.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/ErrorHandling.h" #include diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h --- a/mlir/include/mlir/IR/AffineExpr.h +++ b/mlir/include/mlir/IR/AffineExpr.h @@ -17,6 +17,7 @@ #include "mlir/Support/LLVM.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/Casting.h" +#include #include namespace mlir { diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h --- a/mlir/include/mlir/IR/DialectInterface.h +++ b/mlir/include/mlir/IR/DialectInterface.h @@ -11,6 +11,7 @@ #include "mlir/Support/TypeID.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/STLExtras.h" namespace mlir { class Dialect; diff --git a/mlir/include/mlir/Support/InterfaceSupport.h b/mlir/include/mlir/Support/InterfaceSupport.h --- a/mlir/include/mlir/Support/InterfaceSupport.h +++ b/mlir/include/mlir/Support/InterfaceSupport.h @@ -14,6 +14,7 @@ #define MLIR_SUPPORT_INTERFACESUPPORT_H #include "mlir/Support/TypeID.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/TypeName.h" diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h --- a/mlir/include/mlir/Support/StorageUniquer.h +++ b/mlir/include/mlir/Support/StorageUniquer.h @@ -12,7 +12,9 @@ #include "mlir/Support/LLVM.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Support/TypeID.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" namespace mlir {