forked from OSchip/llvm-project
Avoid including FileSystem.h from MemoryBuffer.h
Lots of headers pass around MemoryBuffer objects, but very few open them. Let those that do include FileSystem.h. Saves ~250 includes of Chrono.h & FileSystem.h: $ diff -u thedeps-before.txt thedeps-after.txt | grep '^[-+] ' | sort | uniq -c | sort -nr 254 - ../llvm/include/llvm/Support/FileSystem.h 253 - ../llvm/include/llvm/Support/Chrono.h 237 - ../llvm/include/llvm/Support/NativeFormatting.h 237 - ../llvm/include/llvm/Support/FormatProviders.h 192 - ../llvm/include/llvm/ADT/StringSwitch.h 190 - ../llvm/include/llvm/Support/FormatVariadicDetails.h ... This requires duplicating the file_t typedef, which is unfortunate. I sunk the choice of mapping mode down into the cpp file using variable template specializations instead of class members in headers.
This commit is contained in:
parent
798e661567
commit
af450eabb9
|
@ -22,6 +22,7 @@
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Bitstream/BitCodes.h"
|
#include "llvm/Bitstream/BitCodes.h"
|
||||||
#include "llvm/Bitstream/BitstreamReader.h"
|
#include "llvm/Bitstream/BitstreamReader.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "clang/Basic/CharInfo.h"
|
#include "clang/Basic/CharInfo.h"
|
||||||
#include "clang/Basic/Diagnostic.h"
|
#include "clang/Basic/Diagnostic.h"
|
||||||
#include "clang/Lex/LexDiagnostic.h"
|
#include "clang/Lex/LexDiagnostic.h"
|
||||||
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/StringSwitch.h"
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "clang/Driver/Driver.h"
|
#include "clang/Driver/Driver.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/MD5.h"
|
#include "llvm/Support/MD5.h"
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
#include "llvm/Support/Program.h"
|
#include "llvm/Support/Program.h"
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/TableGen/Error.h"
|
#include "llvm/TableGen/Error.h"
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
|
|
||||||
#include "llvm/ADT/APInt.h"
|
#include "llvm/ADT/APInt.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/TableGen/Error.h"
|
#include "llvm/TableGen/Error.h"
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#ifndef LLVM_SUPPORT_MSGPACKREADER_H
|
#ifndef LLVM_SUPPORT_MSGPACKREADER_H
|
||||||
#define LLVM_SUPPORT_MSGPACKREADER_H
|
#define LLVM_SUPPORT_MSGPACKREADER_H
|
||||||
|
|
||||||
|
#include "llvm/Support/Error.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/Bitstream/BitCodes.h"
|
#include "llvm/Bitstream/BitCodes.h"
|
||||||
#include "llvm/Support/Endian.h"
|
#include "llvm/Support/Endian.h"
|
||||||
|
#include "llvm/Support/Error.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/CBindingWrapping.h"
|
#include "llvm/Support/CBindingWrapping.h"
|
||||||
#include "llvm/Support/ErrorOr.h"
|
#include "llvm/Support/ErrorOr.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -28,6 +27,18 @@ namespace llvm {
|
||||||
|
|
||||||
class MemoryBufferRef;
|
class MemoryBufferRef;
|
||||||
|
|
||||||
|
namespace sys {
|
||||||
|
namespace fs {
|
||||||
|
// Duplicated from FileSystem.h to avoid a dependency.
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// A Win32 HANDLE is a typedef of void*
|
||||||
|
using file_t = void *;
|
||||||
|
#else
|
||||||
|
using file_t = int;
|
||||||
|
#endif
|
||||||
|
} // namespace fs
|
||||||
|
} // namespace sys
|
||||||
|
|
||||||
/// This interface provides simple read-only access to a block of memory, and
|
/// This interface provides simple read-only access to a block of memory, and
|
||||||
/// provides simple methods for reading files and standard input into a memory
|
/// provides simple methods for reading files and standard input into a memory
|
||||||
/// buffer. In addition to basic access to the characters in the file, this
|
/// buffer. In addition to basic access to the characters in the file, this
|
||||||
|
@ -48,9 +59,6 @@ protected:
|
||||||
void init(const char *BufStart, const char *BufEnd,
|
void init(const char *BufStart, const char *BufEnd,
|
||||||
bool RequiresNullTerminator);
|
bool RequiresNullTerminator);
|
||||||
|
|
||||||
static constexpr sys::fs::mapped_file_region::mapmode Mapmode =
|
|
||||||
sys::fs::mapped_file_region::readonly;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MemoryBuffer(const MemoryBuffer &) = delete;
|
MemoryBuffer(const MemoryBuffer &) = delete;
|
||||||
MemoryBuffer &operator=(const MemoryBuffer &) = delete;
|
MemoryBuffer &operator=(const MemoryBuffer &) = delete;
|
||||||
|
@ -156,9 +164,6 @@ class WritableMemoryBuffer : public MemoryBuffer {
|
||||||
protected:
|
protected:
|
||||||
WritableMemoryBuffer() = default;
|
WritableMemoryBuffer() = default;
|
||||||
|
|
||||||
static constexpr sys::fs::mapped_file_region::mapmode Mapmode =
|
|
||||||
sys::fs::mapped_file_region::priv;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using MemoryBuffer::getBuffer;
|
using MemoryBuffer::getBuffer;
|
||||||
using MemoryBuffer::getBufferEnd;
|
using MemoryBuffer::getBufferEnd;
|
||||||
|
@ -218,9 +223,6 @@ class WriteThroughMemoryBuffer : public MemoryBuffer {
|
||||||
protected:
|
protected:
|
||||||
WriteThroughMemoryBuffer() = default;
|
WriteThroughMemoryBuffer() = default;
|
||||||
|
|
||||||
static constexpr sys::fs::mapped_file_region::mapmode Mapmode =
|
|
||||||
sys::fs::mapped_file_region::readwrite;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using MemoryBuffer::getBuffer;
|
using MemoryBuffer::getBuffer;
|
||||||
using MemoryBuffer::getBufferEnd;
|
using MemoryBuffer::getBufferEnd;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/BinaryFormat/AMDGPUMetadataVerifier.h"
|
#include "llvm/BinaryFormat/AMDGPUMetadataVerifier.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/Support/AMDGPUMetadata.h"
|
#include "llvm/Support/AMDGPUMetadata.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
|
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/Config/llvm-config.h"
|
#include "llvm/Config/llvm-config.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
#include "llvm/IR/LLVMContext.h"
|
#include "llvm/IR/LLVMContext.h"
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "llvm/IR/DiagnosticInfo.h"
|
#include "llvm/IR/DiagnosticInfo.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
#include "llvm/IR/GlobalValue.h"
|
#include "llvm/IR/GlobalValue.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,20 @@ MemoryBuffer::getFileSlice(const Twine &FilePath, uint64_t MapSize,
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
template <typename MB>
|
||||||
|
constexpr sys::fs::mapped_file_region::mapmode Mapmode =
|
||||||
|
sys::fs::mapped_file_region::readonly;
|
||||||
|
template <>
|
||||||
|
constexpr sys::fs::mapped_file_region::mapmode Mapmode<MemoryBuffer> =
|
||||||
|
sys::fs::mapped_file_region::readonly;
|
||||||
|
template <>
|
||||||
|
constexpr sys::fs::mapped_file_region::mapmode Mapmode<WritableMemoryBuffer> =
|
||||||
|
sys::fs::mapped_file_region::priv;
|
||||||
|
template <>
|
||||||
|
constexpr sys::fs::mapped_file_region::mapmode
|
||||||
|
Mapmode<WriteThroughMemoryBuffer> = sys::fs::mapped_file_region::readwrite;
|
||||||
|
|
||||||
/// Memory maps a file descriptor using sys::fs::mapped_file_region.
|
/// Memory maps a file descriptor using sys::fs::mapped_file_region.
|
||||||
///
|
///
|
||||||
/// This handles converting the offset into a legal offset on the platform.
|
/// This handles converting the offset into a legal offset on the platform.
|
||||||
|
@ -184,7 +198,7 @@ class MemoryBufferMMapFile : public MB {
|
||||||
public:
|
public:
|
||||||
MemoryBufferMMapFile(bool RequiresNullTerminator, sys::fs::file_t FD, uint64_t Len,
|
MemoryBufferMMapFile(bool RequiresNullTerminator, sys::fs::file_t FD, uint64_t Len,
|
||||||
uint64_t Offset, std::error_code &EC)
|
uint64_t Offset, std::error_code &EC)
|
||||||
: MFR(FD, MB::Mapmode, getLegalMapSize(Len, Offset),
|
: MFR(FD, Mapmode<MB>, getLegalMapSize(Len, Offset),
|
||||||
getLegalMapOffset(Offset), EC) {
|
getLegalMapOffset(Offset), EC) {
|
||||||
if (!EC) {
|
if (!EC) {
|
||||||
const char *Start = getStart(Len, Offset);
|
const char *Start = getStart(Len, Offset);
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class Error;
|
||||||
|
|
||||||
namespace exegesis {
|
namespace exegesis {
|
||||||
|
|
||||||
struct InstructionBenchmarkKey {
|
struct InstructionBenchmarkKey {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace exegesis {
|
namespace exegesis {
|
||||||
|
|
|
@ -35,8 +35,10 @@
|
||||||
|
|
||||||
#include "llvm/ADT/ArrayRef.h"
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
|
#include "llvm/Support/Error.h"
|
||||||
#include "llvm/Support/SMLoc.h"
|
#include "llvm/Support/SMLoc.h"
|
||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "llvm/ProfileData/SampleProfWriter.h"
|
#include "llvm/ProfileData/SampleProfWriter.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/Support/ErrorOr.h"
|
#include "llvm/Support/ErrorOr.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "llvm/ADT/BitmaskEnum.h"
|
#include "llvm/ADT/BitmaskEnum.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/Support/Endian.h"
|
#include "llvm/Support/Endian.h"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "../CodeGenInstruction.h"
|
#include "../CodeGenInstruction.h"
|
||||||
|
|
||||||
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/ScopedPrinter.h"
|
#include "llvm/Support/ScopedPrinter.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "OptEmitter.h"
|
#include "OptEmitter.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/TableGen/Error.h"
|
#include "llvm/TableGen/Error.h"
|
||||||
#include "llvm/TableGen/Record.h"
|
#include "llvm/TableGen/Record.h"
|
||||||
|
|
Loading…
Reference in New Issue