Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:40

0001 //===- TypeVisitorCallbackPipeline.h ----------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H
0011 
0012 #include "llvm/DebugInfo/CodeView/CodeView.h"
0013 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
0014 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
0015 #include "llvm/Support/Error.h"
0016 #include <vector>
0017 
0018 namespace llvm {
0019 namespace codeview {
0020 
0021 class TypeVisitorCallbackPipeline : public TypeVisitorCallbacks {
0022 public:
0023   TypeVisitorCallbackPipeline() = default;
0024 
0025   Error visitUnknownType(CVRecord<TypeLeafKind> &Record) override {
0026     for (auto *Visitor : Pipeline) {
0027       if (auto EC = Visitor->visitUnknownType(Record))
0028         return EC;
0029     }
0030     return Error::success();
0031   }
0032 
0033   Error visitUnknownMember(CVMemberRecord &Record) override {
0034     for (auto *Visitor : Pipeline) {
0035       if (auto EC = Visitor->visitUnknownMember(Record))
0036         return EC;
0037     }
0038     return Error::success();
0039   }
0040 
0041   Error visitTypeBegin(CVType &Record) override {
0042     for (auto *Visitor : Pipeline) {
0043       if (auto EC = Visitor->visitTypeBegin(Record))
0044         return EC;
0045     }
0046     return Error::success();
0047   }
0048 
0049   Error visitTypeBegin(CVType &Record, TypeIndex Index) override {
0050     for (auto *Visitor : Pipeline) {
0051       if (auto EC = Visitor->visitTypeBegin(Record, Index))
0052         return EC;
0053     }
0054     return Error::success();
0055   }
0056 
0057   Error visitTypeEnd(CVType &Record) override {
0058     for (auto *Visitor : Pipeline) {
0059       if (auto EC = Visitor->visitTypeEnd(Record))
0060         return EC;
0061     }
0062     return Error::success();
0063   }
0064 
0065   Error visitMemberBegin(CVMemberRecord &Record) override {
0066     for (auto *Visitor : Pipeline) {
0067       if (auto EC = Visitor->visitMemberBegin(Record))
0068         return EC;
0069     }
0070     return Error::success();
0071   }
0072 
0073   Error visitMemberEnd(CVMemberRecord &Record) override {
0074     for (auto *Visitor : Pipeline) {
0075       if (auto EC = Visitor->visitMemberEnd(Record))
0076         return EC;
0077     }
0078     return Error::success();
0079   }
0080 
0081   void addCallbackToPipeline(TypeVisitorCallbacks &Callbacks) {
0082     Pipeline.push_back(&Callbacks);
0083   }
0084 
0085 #define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
0086   Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
0087     return visitKnownRecordImpl(CVR, Record);                                  \
0088   }
0089 #define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
0090   Error visitKnownMember(CVMemberRecord &CVMR, Name##Record &Record)           \
0091       override {                                                               \
0092     return visitKnownMemberImpl(CVMR, Record);                                 \
0093   }
0094 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
0095 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
0096 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
0097 
0098 private:
0099   template <typename T> Error visitKnownRecordImpl(CVType &CVR, T &Record) {
0100     for (auto *Visitor : Pipeline) {
0101       if (auto EC = Visitor->visitKnownRecord(CVR, Record))
0102         return EC;
0103     }
0104     return Error::success();
0105   }
0106 
0107   template <typename T>
0108   Error visitKnownMemberImpl(CVMemberRecord &CVMR, T &Record) {
0109     for (auto *Visitor : Pipeline) {
0110       if (auto EC = Visitor->visitKnownMember(CVMR, Record))
0111         return EC;
0112     }
0113     return Error::success();
0114   }
0115   std::vector<TypeVisitorCallbacks *> Pipeline;
0116 };
0117 
0118 } // end namespace codeview
0119 } // end namespace llvm
0120 
0121 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H