blob: 88b7d2d728b1eb8f5819dbd316d7a6448d3de9e8 [file] [log] [blame]
Dean Michael Berris65574472018-08-31 08:04:56 +00001//===- FDRRecordConsumer.h - XRay Flight Data Recorder Mode Records -------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#include "llvm/XRay/FDRRecordConsumer.h"
10
11namespace llvm {
12namespace xray {
13
14Error LogBuilderConsumer::consume(std::unique_ptr<Record> R) {
15 if (!R)
16 return createStringError(
17 std::make_error_code(std::errc::invalid_argument),
18 "Must not call RecordConsumer::consume() with a null pointer.");
19 Records.push_back(std::move(R));
20 return Error::success();
21}
22
23Error PipelineConsumer::consume(std::unique_ptr<Record> R) {
24 if (!R)
25 return createStringError(
26 std::make_error_code(std::errc::invalid_argument),
27 "Must not call RecordConsumer::consume() with a null pointer.");
28
29 // We apply all of the visitors in order, and concatenate errors
30 // appropriately.
31 Error Result = Error::success();
32 for (auto *V : Visitors)
33 Result = joinErrors(std::move(Result), R->apply(*V));
34 return Result;
35}
36
37} // namespace xray
38} // namespace llvm