Skip to content

Commit b58174d

Browse files
author
serge-sans-paille
committed
Cleanup headers for BinaryFormat
A few header removal, some forward declarations. As usual, this can break your build due to false dependencies, the most notable change are: - "llvm/BinaryFormat/AMDGPUMetadataVerifier.h" no longer includes "llvm/BinaryFormat/MsgPackDocument.h" The impact on generated preprocessed lines for LLVMBinaryFormat is pretty nice: $ clang++ -E -Iinclude -I../llvm/include ../llvm/lib/BinaryFormat/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l before this patch: 705281 after this patch: 751456 Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup
1 parent e6ce2c0 commit b58174d

File tree

9 files changed

+29
-13
lines changed

9 files changed

+29
-13
lines changed

llvm/include/llvm/BinaryFormat/AMDGPUMetadataVerifier.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@
1616
#ifndef LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
1717
#define LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
1818

19-
#include "llvm/BinaryFormat/MsgPackDocument.h"
19+
#include "llvm/ADT/None.h"
20+
#include "llvm/ADT/Optional.h"
21+
#include "llvm/ADT/STLFunctionalExtras.h"
22+
#include "llvm/ADT/StringRef.h"
23+
#include "llvm/BinaryFormat/MsgPackReader.h"
24+
25+
#include <cstddef>
2026

2127
namespace llvm {
28+
29+
namespace msgpack {
30+
class DocNode;
31+
class MapDocNode;
32+
}
33+
2234
namespace AMDGPU {
2335
namespace HSAMD {
2436
namespace V3 {

llvm/include/llvm/BinaryFormat/Dwarf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#ifndef LLVM_BINARYFORMAT_DWARF_H
2020
#define LLVM_BINARYFORMAT_DWARF_H
2121

22-
#include "llvm/ADT/Optional.h"
2322
#include "llvm/Support/Compiler.h"
2423
#include "llvm/Support/DataTypes.h"
2524
#include "llvm/Support/ErrorHandling.h"
@@ -31,9 +30,11 @@
3130

3231
namespace llvm {
3332
class StringRef;
33+
template<typename T> class Optional;
3434

3535
namespace dwarf {
3636

37+
3738
//===----------------------------------------------------------------------===//
3839
// DWARF constants as gleaned from the DWARF Debugging Information Format V.5
3940
// reference manual http://www.dwarfstd.org/.

llvm/include/llvm/BinaryFormat/ELF.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "llvm/ADT/StringRef.h"
2323
#include <cstdint>
2424
#include <cstring>
25-
#include <string>
2625

2726
namespace llvm {
2827
namespace ELF {

llvm/include/llvm/BinaryFormat/MsgPackReader.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
#define LLVM_BINARYFORMAT_MSGPACKREADER_H
3535

3636
#include "llvm/Support/Error.h"
37-
#include "llvm/Support/MemoryBuffer.h"
38-
#include "llvm/Support/raw_ostream.h"
37+
#include "llvm/Support/MemoryBufferRef.h"
3938
#include <cstdint>
4039

4140
namespace llvm {

llvm/include/llvm/BinaryFormat/MsgPackWriter.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
#ifndef LLVM_BINARYFORMAT_MSGPACKWRITER_H
2929
#define LLVM_BINARYFORMAT_MSGPACKWRITER_H
3030

31-
#include "llvm/BinaryFormat/MsgPack.h"
3231
#include "llvm/Support/EndianStream.h"
33-
#include "llvm/Support/MemoryBuffer.h"
34-
#include "llvm/Support/raw_ostream.h"
32+
#include "llvm/Support/MemoryBufferRef.h"
3533

3634
namespace llvm {
35+
36+
class raw_ostream;
37+
3738
namespace msgpack {
3839

3940
/// Writes MessagePack objects to an output stream, one at a time.

llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "llvm/BinaryFormat/AMDGPUMetadataVerifier.h"
15+
16+
#include "llvm/ADT/STLExtras.h"
17+
#include "llvm/ADT/STLForwardCompat.h"
1518
#include "llvm/ADT/StringSwitch.h"
16-
#include "llvm/Support/AMDGPUMetadata.h"
19+
#include "llvm/BinaryFormat/MsgPackDocument.h"
20+
21+
#include <map>
22+
#include <utility>
1723

1824
namespace llvm {
1925
namespace AMDGPU {

llvm/lib/BinaryFormat/ELF.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/BinaryFormat/ELF.h"
10-
#include "llvm/ADT/DenseMap.h"
10+
#include "llvm/ADT/DenseMapInfo.h"
1111
#include "llvm/ADT/StringSwitch.h"
12-
#include "llvm/Support/Error.h"
1312

1413
using namespace llvm;
1514
using namespace ELF;

llvm/lib/BinaryFormat/Magic.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
#include "llvm/ADT/StringRef.h"
1111
#include "llvm/ADT/Twine.h"
1212
#include "llvm/BinaryFormat/COFF.h"
13-
#include "llvm/BinaryFormat/ELF.h"
1413
#include "llvm/BinaryFormat/MachO.h"
1514
#include "llvm/Support/Endian.h"
16-
#include "llvm/Support/FileSystem.h"
1715
#include "llvm/Support/MemoryBuffer.h"
1816

1917
#if !defined(_MSC_VER) && !defined(__MINGW32__)

llvm/tools/llvm-readobj/ELFDumper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "llvm/ADT/Twine.h"
3232
#include "llvm/BinaryFormat/AMDGPUMetadataVerifier.h"
3333
#include "llvm/BinaryFormat/ELF.h"
34+
#include "llvm/BinaryFormat/MsgPackDocument.h"
3435
#include "llvm/Demangle/Demangle.h"
3536
#include "llvm/Object/Archive.h"
3637
#include "llvm/Object/ELF.h"

0 commit comments

Comments
 (0)