[InstCombine] Signed saturation patterns
[llvm-core.git] / include / llvm / DebugInfo / CodeView / DebugSubsectionVisitor.h
blob720b1b49581fa72c546823b17b383d7ed8d66987
1 //===- DebugSubsectionVisitor.h -----------------------------*- 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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H
10 #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H
12 #include "llvm/DebugInfo/CodeView/CodeView.h"
13 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
14 #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
15 #include "llvm/Support/Error.h"
16 #include <cstdint>
18 namespace llvm {
20 namespace codeview {
22 class DebugChecksumsSubsectionRef;
23 class DebugSubsectionRecord;
24 class DebugInlineeLinesSubsectionRef;
25 class DebugCrossModuleExportsSubsectionRef;
26 class DebugCrossModuleImportsSubsectionRef;
27 class DebugFrameDataSubsectionRef;
28 class DebugLinesSubsectionRef;
29 class DebugStringTableSubsectionRef;
30 class DebugSymbolRVASubsectionRef;
31 class DebugSymbolsSubsectionRef;
32 class DebugUnknownSubsectionRef;
33 class StringsAndChecksumsRef;
35 class DebugSubsectionVisitor {
36 public:
37 virtual ~DebugSubsectionVisitor() = default;
39 virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) {
40 return Error::success();
42 virtual Error visitLines(DebugLinesSubsectionRef &Lines,
43 const StringsAndChecksumsRef &State) = 0;
44 virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums,
45 const StringsAndChecksumsRef &State) = 0;
46 virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees,
47 const StringsAndChecksumsRef &State) = 0;
48 virtual Error
49 visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE,
50 const StringsAndChecksumsRef &State) = 0;
51 virtual Error
52 visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSE,
53 const StringsAndChecksumsRef &State) = 0;
55 virtual Error visitStringTable(DebugStringTableSubsectionRef &ST,
56 const StringsAndChecksumsRef &State) = 0;
58 virtual Error visitSymbols(DebugSymbolsSubsectionRef &CSE,
59 const StringsAndChecksumsRef &State) = 0;
61 virtual Error visitFrameData(DebugFrameDataSubsectionRef &FD,
62 const StringsAndChecksumsRef &State) = 0;
63 virtual Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs,
64 const StringsAndChecksumsRef &State) = 0;
67 Error visitDebugSubsection(const DebugSubsectionRecord &R,
68 DebugSubsectionVisitor &V,
69 const StringsAndChecksumsRef &State);
71 namespace detail {
72 template <typename T>
73 Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
74 StringsAndChecksumsRef &State) {
75 State.initialize(std::forward<T>(FragmentRange));
77 for (const DebugSubsectionRecord &L : FragmentRange) {
78 if (auto EC = visitDebugSubsection(L, V, State))
79 return EC;
81 return Error::success();
83 } // namespace detail
85 template <typename T>
86 Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) {
87 StringsAndChecksumsRef State;
88 return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
89 State);
92 template <typename T>
93 Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
94 const DebugStringTableSubsectionRef &Strings) {
95 StringsAndChecksumsRef State(Strings);
96 return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
97 State);
100 template <typename T>
101 Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,
102 const DebugStringTableSubsectionRef &Strings,
103 const DebugChecksumsSubsectionRef &Checksums) {
104 StringsAndChecksumsRef State(Strings, Checksums);
105 return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,
106 State);
109 } // end namespace codeview
111 } // end namespace llvm
113 #endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H