Home | History | Annotate | Download | only in CodeView
      1 //===- ListRecordBuilder.h --------------------------------------*- C++ -*-===//
      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 
     10 #ifndef LLVM_DEBUGINFO_CODEVIEW_LISTRECORDBUILDER_H
     11 #define LLVM_DEBUGINFO_CODEVIEW_LISTRECORDBUILDER_H
     12 
     13 #include "llvm/DebugInfo/CodeView/TypeRecordBuilder.h"
     14 
     15 namespace llvm {
     16 namespace codeview {
     17 class TypeTableBuilder;
     18 
     19 class ListRecordBuilder {
     20 private:
     21   ListRecordBuilder(const ListRecordBuilder &) = delete;
     22   ListRecordBuilder &operator=(const ListRecordBuilder &) = delete;
     23 
     24 protected:
     25   const int MethodKindShift = 2;
     26 
     27   explicit ListRecordBuilder(TypeRecordKind Kind);
     28 
     29 public:
     30   llvm::StringRef str() { return Builder.str(); }
     31 
     32   void reset() {
     33     Builder.reset(Kind);
     34     ContinuationOffsets.clear();
     35     SubrecordStart = 0;
     36   }
     37 
     38   void writeListContinuation(const ListContinuationRecord &R);
     39 
     40   /// Writes this list record as a possible sequence of records.
     41   TypeIndex writeListRecord(TypeTableBuilder &Table);
     42 
     43 protected:
     44   void finishSubRecord();
     45 
     46   TypeRecordBuilder &getBuilder() { return Builder; }
     47 
     48 private:
     49   size_t getLastContinuationStart() const {
     50     return ContinuationOffsets.empty() ? 0 : ContinuationOffsets.back();
     51   }
     52   size_t getLastContinuationEnd() const { return Builder.size(); }
     53   size_t getLastContinuationSize() const {
     54     return getLastContinuationEnd() - getLastContinuationStart();
     55   }
     56 
     57   TypeRecordKind Kind;
     58   TypeRecordBuilder Builder;
     59   SmallVector<size_t, 4> ContinuationOffsets;
     60   size_t SubrecordStart = 0;
     61 };
     62 }
     63 }
     64 
     65 #endif
     66