Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:45

0001 //===- FDRRecordConsumer.h - XRay Flight Data Recorder Mode Records -------===//
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 #ifndef LLVM_XRAY_FDRRECORDCONSUMER_H
0009 #define LLVM_XRAY_FDRRECORDCONSUMER_H
0010 
0011 #include "llvm/Support/Error.h"
0012 #include "llvm/XRay/FDRRecords.h"
0013 #include <algorithm>
0014 #include <memory>
0015 #include <vector>
0016 
0017 namespace llvm {
0018 namespace xray {
0019 
0020 class RecordConsumer {
0021 public:
0022   virtual Error consume(std::unique_ptr<Record> R) = 0;
0023   virtual ~RecordConsumer() = default;
0024 };
0025 
0026 // This consumer will collect all the records into a vector of records, in
0027 // arrival order.
0028 class LogBuilderConsumer : public RecordConsumer {
0029   std::vector<std::unique_ptr<Record>> &Records;
0030 
0031 public:
0032   explicit LogBuilderConsumer(std::vector<std::unique_ptr<Record>> &R)
0033       : Records(R) {}
0034 
0035   Error consume(std::unique_ptr<Record> R) override;
0036 };
0037 
0038 // A PipelineConsumer applies a set of visitors to every consumed Record, in the
0039 // order by which the visitors are added to the pipeline in the order of
0040 // appearance.
0041 class PipelineConsumer : public RecordConsumer {
0042   std::vector<RecordVisitor *> Visitors;
0043 
0044 public:
0045   PipelineConsumer(std::initializer_list<RecordVisitor *> V) : Visitors(V) {}
0046 
0047   Error consume(std::unique_ptr<Record> R) override;
0048 };
0049 
0050 } // namespace xray
0051 } // namespace llvm
0052 
0053 #endif // LLVM_XRAY_FDRRECORDCONSUMER_H