LLVM  9.0.0svn
CVSymbolVisitor.cpp
Go to the documentation of this file.
1 //===- CVSymbolVisitor.cpp --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
13 
14 using namespace llvm;
15 using namespace llvm::codeview;
16 
18  : Callbacks(Callbacks) {}
19 
20 template <typename T>
22  SymbolVisitorCallbacks &Callbacks) {
23  SymbolRecordKind RK = static_cast<SymbolRecordKind>(Record.Type);
24  T KnownRecord(RK);
25  if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord))
26  return EC;
27  return Error::success();
28 }
29 
31  SymbolVisitorCallbacks &Callbacks) {
32  switch (Record.Type) {
33  default:
34  if (auto EC = Callbacks.visitUnknownSymbol(Record))
35  return EC;
36  break;
37 #define SYMBOL_RECORD(EnumName, EnumVal, Name) \
38  case EnumName: { \
39  if (auto EC = visitKnownRecord<Name>(Record, Callbacks)) \
40  return EC; \
41  break; \
42  }
43 #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) \
44  SYMBOL_RECORD(EnumVal, EnumVal, AliasName)
45 #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
46  }
47 
48  if (auto EC = Callbacks.visitSymbolEnd(Record))
49  return EC;
50 
51  return Error::success();
52 }
53 
55  if (auto EC = Callbacks.visitSymbolBegin(Record))
56  return EC;
57  return finishVisitation(Record, Callbacks);
58 }
59 
61  if (auto EC = Callbacks.visitSymbolBegin(Record, Offset))
62  return EC;
63  return finishVisitation(Record, Callbacks);
64 }
65 
67  for (auto I : Symbols) {
68  if (auto EC = visitSymbolRecord(I))
69  return EC;
70  }
71  return Error::success();
72 }
73 
75  uint32_t InitialOffset) {
76  for (auto I : Symbols) {
77  if (auto EC = visitSymbolRecord(I, InitialOffset + Symbols.skew()))
78  return EC;
79  InitialOffset += I.length();
80  }
81  return Error::success();
82 }
SymbolRecordKind
Distinguishes individual records in the Symbols subsection of a .debug$S section. ...
Definition: CodeView.h:40
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:326
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:157