Move endian constant from Host.h to SwapByteOrder.h, prune include
authorReid Kleckner <rnk@google.com>
Sat, 19 Oct 2019 00:48:11 +0000 (00:48 +0000)
committerReid Kleckner <rnk@google.com>
Sat, 19 Oct 2019 00:48:11 +0000 (00:48 +0000)
Works on this dependency chain:
  ArrayRef.h ->
  Hashing.h -> --CUT--
  Host.h ->
  StringMap.h / StringRef.h

ArrayRef is very popular, but Host.h is rarely needed. Move the
IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are
more likely to need it.

llvm-svn: 375316

19 files changed:
clang-tools-extra/clangd/FileDistance.h
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/Arch/PPC.cpp
clang/lib/Driver/ToolChains/Arch/X86.cpp
lld/include/lld/Common/LLVM.h
lld/include/lld/Core/File.h
lld/lib/ReaderWriter/MachO/DebugInfo.h
lld/tools/lld/lld.cpp
lldb/include/lldb/Utility/UUID.h
llvm/include/llvm/ADT/Hashing.h
llvm/include/llvm/BinaryFormat/Wasm.h
llvm/include/llvm/Support/Host.h
llvm/include/llvm/Support/SHA1.h
llvm/include/llvm/Support/SwapByteOrder.h
llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
llvm/lib/Support/Windows/WindowsSupport.h
llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
llvm/tools/llvm-exegesis/lib/RegisterValue.cpp

index e7174bc..88bb30c 100644 (file)
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Path.h"
index 35d11f4..3a5fe6d 100644 (file)
@@ -12,6 +12,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
index b99a1b4..68a5731 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
index 59ff7cb..3e02e57 100644 (file)
@@ -13,6 +13,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
index 34be226..d2b97bf 100644 (file)
@@ -13,6 +13,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
index f7ed1d7..34b7b0d 100644 (file)
@@ -17,6 +17,7 @@
 // This should be the only #include, force #includes of all the others on
 // clients.
 #include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include <utility>
 
index 492f359..df01466 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <functional>
 #include <memory>
index 959e10f..591dd1e 100644 (file)
@@ -12,6 +12,7 @@
 #include "lld/Core/Atom.h"
 #include <vector>
 
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 
index 37ef260..14dcc95 100644 (file)
@@ -33,6 +33,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include <cstdlib>
index cb2e051..0284357 100644 (file)
@@ -9,14 +9,11 @@
 #ifndef LLDB_UTILITY_UUID_H
 #define LLDB_UTILITY_UUID_H
 
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
 #include <stddef.h>
 #include <stdint.h>
 #include <string>
-#include "llvm/ADT/ArrayRef.h"
-
-namespace llvm {
-  class StringRef;
-}
 
 namespace lldb_private {
 
index 008188b..b22606b 100644 (file)
@@ -45,7 +45,6 @@
 #define LLVM_ADT_HASHING_H
 
 #include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Host.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/type_traits.h"
 #include <algorithm>
index e2c94a1..f550d88 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
 namespace wasm {
index b37cc51..44f543c 100644 (file)
 
 #include "llvm/ADT/StringMap.h"
 
-#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
-#include <endian.h>
-#elif defined(_AIX)
-#include <sys/machine.h>
-#elif defined(__sun)
-/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */
-#include <sys/types.h>
-#define BIG_ENDIAN 4321
-#define LITTLE_ENDIAN 1234
-#if defined(_BIG_ENDIAN)
-#define BYTE_ORDER BIG_ENDIAN
-#else
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-#else
-#if !defined(BYTE_ORDER) && !defined(_WIN32)
-#include <machine/endian.h>
-#endif
-#endif
-
 #include <string>
 
 namespace llvm {
 namespace sys {
 
-#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
-constexpr bool IsBigEndianHost = true;
-#else
-constexpr bool IsBigEndianHost = false;
-#endif
-
-  static const bool IsLittleEndianHost = !IsBigEndianHost;
-
   /// getDefaultTargetTriple() - Return the default target triple the compiler
   /// has been configured to produce code for.
   ///
index 87fe94b..2cfbd21 100644 (file)
 #define LLVM_SUPPORT_SHA1_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
 
 #include <array>
 #include <cstdint>
 
 namespace llvm {
 template <typename T> class ArrayRef;
-class StringRef;
 
 /// A class that wrap the SHA1 algorithm.
 class SHA1 {
index ec60a21..6cec870 100644 (file)
 #include <stdlib.h>
 #endif
 
+#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
+#include <endian.h>
+#elif defined(_AIX)
+#include <sys/machine.h>
+#elif defined(__sun)
+/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */
+#include <sys/types.h>
+#define BIG_ENDIAN 4321
+#define LITTLE_ENDIAN 1234
+#if defined(_BIG_ENDIAN)
+#define BYTE_ORDER BIG_ENDIAN
+#else
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+#else
+#if !defined(BYTE_ORDER) && !defined(_WIN32)
+#include <machine/endian.h>
+#endif
+#endif
+
 namespace llvm {
 namespace sys {
 
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
+constexpr bool IsBigEndianHost = true;
+#else
+constexpr bool IsBigEndianHost = false;
+#endif
+
+static const bool IsLittleEndianHost = !IsBigEndianHost;
+
 /// SwapByteOrder_16 - This function returns a byte-swapped representation of
 /// the 16-bit argument.
 inline uint16_t SwapByteOrder_16(uint16_t value) {
index 359ef99..1d3e6db 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
 
+#include "llvm/Support/Host.h"
 #include "llvm/Support/TargetRegistry.h"
 
 namespace llvm {
index fed9b2f..2e2e974 100644 (file)
@@ -38,6 +38,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/config.h" // Get build system configuration settings
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Chrono.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/VersionTuple.h"
index a241362..e287f66 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
+#include "X86DisassemblerDecoder.h"
+#include "llvm/ADT/StringRef.h"
+
 #include <cstdarg> /* for va_*()       */
 #include <cstdio>  /* for vsnprintf()  */
 #include <cstdlib> /* for exit()       */
 #include <cstring> /* for memset()     */
 
-#include "X86DisassemblerDecoder.h"
-
 using namespace llvm::X86Disassembler;
 
 /// Specifies whether a ModR/M byte is needed and (if so) which
index e83b73e..f881aa6 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "RegisterValue.h"
 #include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
 namespace exegesis {