LLVM  6.0.0svn
TypeRecordBuilder.h
Go to the documentation of this file.
1 //===- TypeRecordBuilder.h --------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDBUILDER_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDBUILDER_H
12 
13 #include "llvm/ADT/SmallVector.h"
19 
20 namespace llvm {
21 namespace codeview {
22 
24 private:
25  TypeRecordBuilder(const TypeRecordBuilder &) = delete;
26  TypeRecordBuilder &operator=(const TypeRecordBuilder &) = delete;
27 
28 public:
29  explicit TypeRecordBuilder(TypeRecordKind Kind);
30 
31  void writeUInt8(uint8_t Value);
32  void writeInt16(int16_t Value);
33  void writeUInt16(uint16_t Value);
34  void writeInt32(int32_t Value);
35  void writeUInt32(uint32_t Value);
36  void writeInt64(int64_t Value);
37  void writeUInt64(uint64_t Value);
38  void writeTypeIndex(TypeIndex TypeInd);
40  void writeEncodedInteger(int64_t Value);
41  void writeEncodedSignedInteger(int64_t Value);
42  void writeEncodedUnsignedInteger(uint64_t Value);
44  void writeGuid(StringRef Guid);
45  void writeBytes(StringRef Value) { Stream << Value; }
46 
48 
49  uint64_t size() const { return Stream.tell(); }
50  TypeRecordKind kind() const { return Kind; }
51 
52  /// Returns the number of bytes remaining before this record is larger than
53  /// the maximum record length. Accounts for the extra two byte size field in
54  /// the header.
55  size_t maxBytesRemaining() const { return MaxRecordLength - size() - 2; }
56 
57  void truncate(uint64_t Size) {
58  // This works because raw_svector_ostream is not buffered.
59  assert(Size < Buffer.size());
60  Buffer.resize(Size);
61  }
62 
64  Buffer.clear();
65  Kind = K;
67  }
68 
69 private:
70  TypeRecordKind Kind;
74 };
75 }
76 }
77 
78 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:136
void writeInt64(int64_t Value)
void writeNullTerminatedString(StringRef Value)
void writeTypeIndex(TypeIndex TypeInd)
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:489
void writeInt32(int32_t Value)
void writeUInt8(uint8_t Value)
void writeEncodedInteger(int64_t Value)
A 32-bit type reference.
Definition: TypeIndex.h:96
TypeRecordKind
Distinguishes individual records in .debug$T section or PDB type stream.
Definition: CodeView.h:27
void writeEncodedSignedInteger(int64_t Value)
void writeTypeRecordKind(TypeRecordKind Kind)
void writeInt16(int16_t Value)
void writeEncodedUnsignedInteger(uint64_t Value)
void writeUInt64(uint64_t Value)
void writeUInt32(uint32_t Value)
void writeGuid(StringRef Guid)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Definition: Value.h:73
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
uint64_t tell() const
tell - Return the current offset with the file.
Definition: raw_ostream.h:98
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
size_t maxBytesRemaining() const
Returns the number of bytes remaining before this record is larger than the maximum record length...
void writeUInt16(uint16_t Value)
void resize(size_type N)
Definition: SmallVector.h:355