| 1 | //===- FDRRecordConsumer.h - XRay Flight Data Recorder Mode Records -------===// |
|---|---|
| 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 | #include "llvm/XRay/FDRRecordConsumer.h" |
| 9 | |
| 10 | namespace llvm { |
| 11 | namespace xray { |
| 12 | |
| 13 | Error LogBuilderConsumer::consume(std::unique_ptr<Record> R) { |
| 14 | if (!R) |
| 15 | return createStringError( |
| 16 | EC: std::make_error_code(e: std::errc::invalid_argument), |
| 17 | S: "Must not call RecordConsumer::consume() with a null pointer."); |
| 18 | Records.push_back(x: std::move(R)); |
| 19 | return Error::success(); |
| 20 | } |
| 21 | |
| 22 | Error PipelineConsumer::consume(std::unique_ptr<Record> R) { |
| 23 | if (!R) |
| 24 | return createStringError( |
| 25 | EC: std::make_error_code(e: std::errc::invalid_argument), |
| 26 | S: "Must not call RecordConsumer::consume() with a null pointer."); |
| 27 | |
| 28 | // We apply all of the visitors in order, and concatenate errors |
| 29 | // appropriately. |
| 30 | Error Result = Error::success(); |
| 31 | for (auto *V : Visitors) |
| 32 | Result = joinErrors(E1: std::move(Result), E2: R->apply(V&: *V)); |
| 33 | return Result; |
| 34 | } |
| 35 | |
| 36 | } // namespace xray |
| 37 | } // namespace llvm |
| 38 |