aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h
blob: 55bef491c97eddc96eb324da60294fc9dda09663 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//===- DebugSubsectionVisitor.h -----------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H
#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H

#include "llvm/Support/Error.h"
#include <cstdint>

namespace llvm {

namespace codeview {

class DebugChecksumsSubsectionRef;
class DebugSubsectionRecord;
class DebugInlineeLinesSubsectionRef;
class DebugLinesSubsectionRef;
class DebugUnknownSubsectionRef;

class DebugSubsectionVisitor {
public:
  virtual ~DebugSubsectionVisitor() = default;

  virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) {
    return Error::success();
  }
  virtual Error visitLines(DebugLinesSubsectionRef &Lines) {
    return Error::success();
  }

  virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums) {
    return Error::success();
  }

  virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees) {
    return Error::success();
  }

  virtual Error finished() { return Error::success(); }
};

Error visitDebugSubsection(const DebugSubsectionRecord &R,
                           DebugSubsectionVisitor &V);

template <typename T>
Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) {
  for (const auto &L : FragmentRange) {
    if (auto EC = visitDebugSubsection(L, V))
      return EC;
  }
  if (auto EC = V.finished())
    return EC;
  return Error::success();
}

} // end namespace codeview

} // end namespace llvm

#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H