LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Native - NativeEnumSymbol.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 22 43 51.2 %
Date: 2018-07-13 00:08:38 Functions: 11 20 55.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- NativeEnumSymbol.cpp - info about enum type --------------*- 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             : #include "llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h"
      11             : 
      12             : #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
      13             : #include "llvm/DebugInfo/CodeView/TypeRecord.h"
      14             : #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
      15             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
      16             : 
      17             : #include <cassert>
      18             : 
      19             : using namespace llvm;
      20             : using namespace llvm::pdb;
      21             : 
      22          18 : NativeEnumSymbol::NativeEnumSymbol(NativeSession &Session, SymIndexId Id,
      23          18 :                                    const codeview::CVType &CVT)
      24             :     : NativeRawSymbol(Session, Id), CV(CVT),
      25          18 :       Record(codeview::TypeRecordKind::Enum) {
      26             :   assert(CV.kind() == codeview::TypeLeafKind::LF_ENUM);
      27          36 :   cantFail(visitTypeRecord(CV, *this));
      28          18 : }
      29             : 
      30          54 : NativeEnumSymbol::~NativeEnumSymbol() {}
      31             : 
      32           9 : std::unique_ptr<NativeRawSymbol> NativeEnumSymbol::clone() const {
      33          18 :   return llvm::make_unique<NativeEnumSymbol>(Session, SymbolId, CV);
      34             : }
      35             : 
      36             : std::unique_ptr<IPDBEnumSymbols>
      37           9 : NativeEnumSymbol::findChildren(PDB_SymType Type) const {
      38           9 :   switch (Type) {
      39             :   case PDB_SymType::Data: {
      40             :     // TODO(amccarth):  Provide an actual implementation.
      41             :     return nullptr;
      42             :   }
      43             :   default:
      44             :     return nullptr;
      45             :   }
      46             : }
      47             : 
      48          18 : Error NativeEnumSymbol::visitKnownRecord(codeview::CVType &CVR,
      49             :                                          codeview::EnumRecord &ER) {
      50          18 :   Record = ER;
      51          18 :   return Error::success();
      52             : }
      53             : 
      54           0 : Error NativeEnumSymbol::visitKnownMember(codeview::CVMemberRecord &CVM,
      55             :                                          codeview::EnumeratorRecord &R) {
      56           0 :   return Error::success();
      57             : }
      58             : 
      59           9 : PDB_SymType NativeEnumSymbol::getSymTag() const { return PDB_SymType::Enum; }
      60             : 
      61           9 : uint32_t NativeEnumSymbol::getClassParentId() const { return 0xFFFFFFFF; }
      62             : 
      63           0 : uint32_t NativeEnumSymbol::getUnmodifiedTypeId() const { return 0; }
      64             : 
      65           0 : bool NativeEnumSymbol::hasConstructor() const {
      66           0 :   return bool(Record.getOptions() &
      67           0 :               codeview::ClassOptions::HasConstructorOrDestructor);
      68             : }
      69             : 
      70           0 : bool NativeEnumSymbol::hasAssignmentOperator() const {
      71           0 :   return bool(Record.getOptions() &
      72           0 :               codeview::ClassOptions::HasOverloadedAssignmentOperator);
      73             : }
      74             : 
      75           0 : bool NativeEnumSymbol::hasCastOperator() const {
      76           0 :   return bool(Record.getOptions() &
      77           0 :               codeview::ClassOptions::HasConversionOperator);
      78             : }
      79             : 
      80           9 : uint64_t NativeEnumSymbol::getLength() const {
      81          18 :   const auto Id = Session.findSymbolByTypeIndex(Record.getUnderlyingType());
      82             :   const auto UnderlyingType =
      83           9 :       Session.getConcreteSymbolById<PDBSymbolTypeBuiltin>(Id);
      84          18 :   return UnderlyingType ? UnderlyingType->getLength() : 0;
      85             : }
      86             : 
      87          36 : std::string NativeEnumSymbol::getName() const { return Record.getName(); }
      88             : 
      89           0 : bool NativeEnumSymbol::isNested() const {
      90           0 :   return bool(Record.getOptions() & codeview::ClassOptions::Nested);
      91             : }
      92             : 
      93           0 : bool NativeEnumSymbol::hasOverloadedOperator() const {
      94           0 :   return bool(Record.getOptions() &
      95           0 :               codeview::ClassOptions::HasOverloadedOperator);
      96             : }
      97             : 
      98           0 : bool NativeEnumSymbol::isPacked() const {
      99           0 :   return bool(Record.getOptions() & codeview::ClassOptions::Packed);
     100             : }
     101             : 
     102           0 : bool NativeEnumSymbol::isScoped() const {
     103           0 :   return bool(Record.getOptions() & codeview::ClassOptions::Scoped);
     104             : }
     105             : 
     106           9 : uint32_t NativeEnumSymbol::getTypeId() const {
     107          18 :   return Session.findSymbolByTypeIndex(Record.getUnderlyingType());
     108             : }

Generated by: LCOV version 1.13