LLVM  8.0.1
CVSymbolVisitor.cpp
Go to the documentation of this file.
1 //===- CVSymbolVisitor.cpp --------------------------------------*- 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 
11 
14 
15 using namespace llvm;
16 using namespace llvm::codeview;
17 
19  : Callbacks(Callbacks) {}
20 
21 template <typename T>
23  SymbolVisitorCallbacks &Callbacks) {
24  SymbolRecordKind RK = static_cast<SymbolRecordKind>(Record.Type);
25  T KnownRecord(RK);
26  if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord))
27  return EC;
28  return Error::success();
29 }
30 
32  SymbolVisitorCallbacks &Callbacks) {
33  switch (Record.Type) {
34  default:
35  if (auto EC = Callbacks.visitUnknownSymbol(Record))
36  return EC;
37  break;
38 #define SYMBOL_RECORD(EnumName, EnumVal, Name) \
39  case EnumName: { \
40  if (auto EC = visitKnownRecord<Name>(Record, Callbacks)) \
41  return EC; \
42  break; \
43  }
44 #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) \
45  SYMBOL_RECORD(EnumVal, EnumVal, AliasName)
46 #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
47  }
48 
49  if (auto EC = Callbacks.visitSymbolEnd(Record))
50  return EC;
51 
52  return Error::success();
53 }
54 
56  if (auto EC = Callbacks.visitSymbolBegin(Record))
57  return EC;
58  return finishVisitation(Record, Callbacks);
59 }
60 
62  if (auto EC = Callbacks.visitSymbolBegin(Record, Offset))
63  return EC;
64  return finishVisitation(Record, Callbacks);
65 }
66 
68  for (auto I : Symbols) {
69  if (auto EC = visitSymbolRecord(I))
70  return EC;
71  }
72  return Error::success();
73 }
74 
76  uint32_t InitialOffset) {
77  for (auto I : Symbols) {
78  if (auto EC = visitSymbolRecord(I, InitialOffset + Symbols.skew()))
79  return EC;
80  InitialOffset += I.length();
81  }
82  return Error::success();
83 }
SymbolRecordKind
Distinguishes individual records in the Symbols subsection of a .debug$S section. ...
Definition: CodeView.h:41
This class represents lattice values for constants.
Definition: AllocatorList.h:24
virtual Error visitUnknownSymbol(CVSymbol &Record)
Action to take on unknown symbols. By default, they are ignored.
Error visitSymbolRecord(CVSymbol &Record)
virtual Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset)
Paired begin/end actions for all symbols.
CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks)
virtual Error visitSymbolEnd(CVSymbol &Record)
static Error visitKnownRecord(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks)
static ErrorSuccess success()
Create a success value.
Definition: Error.h:327
Error visitSymbolStream(const CVSymbolArray &Symbols)
#define I(x, y, z)
Definition: MD5.cpp:58
static Error finishVisitation(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks)
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158