LogBuilderConsumer.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. namespace llvm {
  10. namespace xray {
  11. Error LogBuilderConsumer::consume(std::unique_ptr<Record> R) {
  12. if (!R)
  13. return createStringError(
  14. std::make_error_code(std::errc::invalid_argument),
  15. "Must not call RecordConsumer::consume() with a null pointer.");
  16. Records.push_back(std::move(R));
  17. return Error::success();
  18. }
  19. Error PipelineConsumer::consume(std::unique_ptr<Record> R) {
  20. if (!R)
  21. return createStringError(
  22. std::make_error_code(std::errc::invalid_argument),
  23. "Must not call RecordConsumer::consume() with a null pointer.");
  24. // We apply all of the visitors in order, and concatenate errors
  25. // appropriately.
  26. Error Result = Error::success();
  27. for (auto *V : Visitors)
  28. Result = joinErrors(std::move(Result), R->apply(*V));
  29. return Result;
  30. }
  31. } // namespace xray
  32. } // namespace llvm