LLVM  6.0.0svn
DebugStringTableSubsection.h
Go to the documentation of this file.
1 //===- DebugStringTableSubsection.h - CodeView String Table -----*- 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_DEBUGSTRINGTABLESUBSECTION_H
11 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
12 
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/Error.h"
19 #include <cstdint>
20 
21 namespace llvm {
22 
23 class BinaryStreamReader;
24 
25 namespace codeview {
26 
27 /// Represents a read-only view of a CodeView string table. This is a very
28 /// simple flat buffer consisting of null-terminated strings, where strings
29 /// are retrieved by their offset in the buffer. DebugStringTableSubsectionRef
30 /// does not own the underlying storage for the buffer.
32 public:
34 
35  static bool classof(const DebugSubsectionRef *S) {
37  }
38 
41 
43 
44  bool valid() const { return Stream.valid(); }
45 
46  BinaryStreamRef getBuffer() const { return Stream; }
47 
48 private:
49  BinaryStreamRef Stream;
50 };
51 
52 /// Represents a read-write view of a CodeView string table.
53 /// DebugStringTableSubsection owns the underlying storage for the table, and is
54 /// capable of serializing the string table into a format understood by
55 /// DebugStringTableSubsectionRef.
57 public:
59 
60  static bool classof(const DebugSubsection *S) {
62  }
63 
64  // If string S does not exist in the string table, insert it.
65  // Returns the ID for S.
66  uint32_t insert(StringRef S);
67 
68  // Return the ID for string S. Assumes S exists in the table.
69  uint32_t getStringId(StringRef S) const;
70 
71  uint32_t calculateSerializedSize() const override;
72  Error commit(BinaryStreamWriter &Writer) const override;
73 
74  uint32_t size() const;
75 
76  StringMap<uint32_t>::const_iterator begin() const { return Strings.begin(); }
77 
78  StringMap<uint32_t>::const_iterator end() const { return Strings.end(); }
79 
80 private:
81  StringMap<uint32_t> Strings;
82  uint32_t StringSize = 1;
83 };
84 
85 } // end namespace codeview
86 
87 } // end namespace llvm
88 
89 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Expected< StringRef > getString(uint32_t Offset) const
StringMap< uint32_t >::const_iterator end() const
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
StringMap< uint32_t >::const_iterator begin() const
Provides write only access to a subclass of WritableBinaryStream.
Represents a read-write view of a CodeView string table.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
static bool classof(const DebugSubsectionRef *S)
DebugSubsectionKind kind() const
Represents a read-only view of a CodeView string table.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:224
iterator begin()
Definition: StringMap.h:319
static bool classof(const DebugSubsection *S)
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
DebugSubsectionKind kind() const
iterator end()
Definition: StringMap.h:322