LCOV - code coverage report
Current view: top level - include/llvm/XRay - FDRLogBuilder.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 4 4 100.0 %
Date: 2018-10-20 13:21:21 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- FDRLogBuilder.h - XRay FDR Log Building Utility --------------------===//
       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             : #ifndef LLVM_INCLUDE_LLVM_XRAY_FDRLOGBUILDER_H_
      10             : #define LLVM_INCLUDE_LLVM_XRAY_FDRLOGBUILDER_H_
      11             : 
      12             : #include "llvm/XRay/FDRRecords.h"
      13             : 
      14             : namespace llvm {
      15             : namespace xray {
      16             : 
      17             : /// The LogBuilder class allows for creating ad-hoc collections of records
      18             : /// through the `add<...>(...)` function. An example use of this API is in
      19             : /// crafting arbitrary sequences of records:
      20             : ///
      21             : ///   auto Records = LogBuilder()
      22             : ///       .add<BufferExtents>(256)
      23             : ///       .add<NewBufferRecord>(1)
      24             : ///       .consume();
      25             : ///
      26          20 : class LogBuilder {
      27             :   std::vector<std::unique_ptr<Record>> Records;
      28             : 
      29             : public:
      30           2 :   template <class R, class... T> LogBuilder &add(T &&... A) {
      31           2 :     Records.emplace_back(new R(std::forward<T>(A)...));
      32           2 :     return *this;
      33             :   }
      34             : 
      35             :   std::vector<std::unique_ptr<Record>> consume() { return std::move(Records); }
      36             : };
      37             : 
      38             : } // namespace xray
      39             : } // namespace llvm
      40             : 
      41             : #endif // LLVM_INCLUDE_LLVM_XRAY_FDRLOGBUILDER_H_

Generated by: LCOV version 1.13