LLVM  4.0.0
TypeDatabase.h
Go to the documentation of this file.
1 //===- TypeDatabase.h - A collection of CodeView type records ---*- 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_TYPEDATABASE_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASE_H
12 
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/ADT/StringRef.h"
17 #include "llvm/Support/Allocator.h"
19 
20 namespace llvm {
21 namespace codeview {
22 class TypeDatabase {
23 public:
24  TypeDatabase() : TypeNameStorage(Allocator) {}
25 
26  /// Gets the type index for the next type record.
28 
29  /// Records the name of a type, and reserves its type index.
30  void recordType(StringRef Name, CVType Data);
31 
32  /// Saves the name in a StringSet and creates a stable StringRef.
34 
35  StringRef getTypeName(TypeIndex Index) const;
36 
37  bool containsTypeIndex(TypeIndex Index) const;
38 
39  uint32_t size() const;
40 
41 private:
42  BumpPtrAllocator Allocator;
43 
44  /// All user defined type records in .debug$T live in here. Type indices
45  /// greater than 0x1000 are user defined. Subtract 0x1000 from the index to
46  /// index into this vector.
47  SmallVector<StringRef, 10> CVUDTNames;
48  SmallVector<CVType, 10> TypeRecords;
49 
50  StringSaver TypeNameStorage;
51 };
52 }
53 }
54 
55 #endif
StringRef getTypeName(TypeIndex Index) const
StringRef saveTypeName(StringRef TypeName)
Saves the name in a StringSet and creates a stable StringRef.
TypeIndex getNextTypeIndex() const
Gets the type index for the next type record.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
bool containsTypeIndex(TypeIndex Index) const
A 32-bit type reference.
Definition: TypeIndex.h:89
void recordType(StringRef Name, CVType Data)
Records the name of a type, and reserves its type index.
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
Saves strings in the inheritor's stable storage and returns a StringRef with a stable character point...
Definition: StringSaver.h:21
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47