]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/XRay/LogBuilderConsumer.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / XRay / LogBuilderConsumer.cpp
1 //===- 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
11 namespace llvm {
12 namespace xray {
13
14 Error 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
23 Error 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