LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Native - NativeSymbolEnumerator.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 52 52 100.0 %
Date: 2018-10-20 13:21:21 Functions: 14 14 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- NativeSymbolEnumerator.cpp - info about enumerators ------*- 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/NativeSymbolEnumerator.h"
      11             : 
      12             : #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
      13             : #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
      14             : #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
      15             : 
      16             : using namespace llvm;
      17             : using namespace llvm::codeview;
      18             : using namespace llvm::pdb;
      19             : 
      20         166 : NativeSymbolEnumerator::NativeSymbolEnumerator(
      21             :     NativeSession &Session, SymIndexId Id, const NativeTypeEnum &Parent,
      22         166 :     codeview::EnumeratorRecord Record)
      23             :     : NativeRawSymbol(Session, PDB_SymType::Data, Id), Parent(Parent),
      24         166 :       Record(std::move(Record)) {}
      25             : 
      26         332 : NativeSymbolEnumerator::~NativeSymbolEnumerator() {}
      27             : 
      28          90 : void NativeSymbolEnumerator::dump(raw_ostream &OS, int Indent,
      29             :                                   PdbSymbolIdField ShowIdFields,
      30             :                                   PdbSymbolIdField RecurseIdFields) const {
      31          90 :   NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
      32          90 :   dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
      33             :                     PdbSymbolIdField::ClassParent, ShowIdFields,
      34             :                     RecurseIdFields);
      35          90 :   dumpSymbolIdField(OS, "lexicalParentId", getLexicalParentId(), Indent,
      36          90 :                     Session, PdbSymbolIdField::LexicalParent, ShowIdFields,
      37             :                     RecurseIdFields);
      38          90 :   dumpSymbolField(OS, "name", getName(), Indent);
      39          90 :   dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
      40             :                     PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
      41          90 :   dumpSymbolField(OS, "dataKind", getDataKind(), Indent);
      42          90 :   dumpSymbolField(OS, "locationType", getLocationType(), Indent);
      43          90 :   dumpSymbolField(OS, "constType", isConstType(), Indent);
      44          90 :   dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
      45          90 :   dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
      46          90 :   dumpSymbolField(OS, "value", getValue(), Indent);
      47          90 : }
      48             : 
      49          90 : SymIndexId NativeSymbolEnumerator::getClassParentId() const {
      50          90 :   return Parent.getSymIndexId();
      51             : }
      52             : 
      53          90 : SymIndexId NativeSymbolEnumerator::getLexicalParentId() const { return 0; }
      54             : 
      55         178 : std::string NativeSymbolEnumerator::getName() const { return Record.Name; }
      56             : 
      57          90 : SymIndexId NativeSymbolEnumerator::getTypeId() const {
      58          90 :   return Parent.getTypeId();
      59             : }
      60             : 
      61         178 : PDB_DataKind NativeSymbolEnumerator::getDataKind() const {
      62         178 :   return PDB_DataKind::Constant;
      63             : }
      64             : 
      65          90 : PDB_LocType NativeSymbolEnumerator::getLocationType() const {
      66          90 :   return PDB_LocType::Constant;
      67             : }
      68             : 
      69          90 : bool NativeSymbolEnumerator::isConstType() const { return false; }
      70             : 
      71          90 : bool NativeSymbolEnumerator::isVolatileType() const { return false; }
      72             : 
      73          90 : bool NativeSymbolEnumerator::isUnalignedType() const { return false; }
      74             : 
      75         178 : Variant NativeSymbolEnumerator::getValue() const {
      76         178 :   const NativeTypeBuiltin &BT = Parent.getUnderlyingBuiltinType();
      77             : 
      78         178 :   switch (BT.getBuiltinType()) {
      79         146 :   case PDB_BuiltinType::Int:
      80             :   case PDB_BuiltinType::Long:
      81             :   case PDB_BuiltinType::Char: {
      82             :     assert(Record.Value.isSignedIntN(BT.getLength() * 8));
      83             :     int64_t N = Record.Value.getSExtValue();
      84         146 :     switch (BT.getLength()) {
      85           6 :     case 1:
      86           6 :       return Variant{static_cast<int8_t>(N)};
      87           6 :     case 2:
      88           6 :       return Variant{static_cast<int16_t>(N)};
      89         128 :     case 4:
      90         128 :       return Variant{static_cast<int32_t>(N)};
      91             :     case 8:
      92             :       return Variant{static_cast<int64_t>(N)};
      93             :     }
      94             :     break;
      95             :   }
      96          28 :   case PDB_BuiltinType::UInt:
      97             :   case PDB_BuiltinType::ULong: {
      98             :     assert(Record.Value.isIntN(BT.getLength() * 8));
      99             :     uint64_t U = Record.Value.getZExtValue();
     100          28 :     switch (BT.getLength()) {
     101           4 :     case 1:
     102           4 :       return Variant{static_cast<uint8_t>(U)};
     103          12 :     case 2:
     104          12 :       return Variant{static_cast<uint16_t>(U)};
     105           8 :     case 4:
     106           8 :       return Variant{static_cast<uint32_t>(U)};
     107             :     case 8:
     108             :       return Variant{static_cast<uint64_t>(U)};
     109             :     }
     110             :     break;
     111             :   }
     112           4 :   case PDB_BuiltinType::Bool: {
     113             :     assert(Record.Value.isIntN(BT.getLength() * 8));
     114             :     uint64_t U = Record.Value.getZExtValue();
     115           4 :     return Variant{static_cast<bool>(U)};
     116             :   }
     117             :   default:
     118             :     assert(false && "Invalid enumeration type");
     119             :     break;
     120             :   }
     121             : 
     122             :   return Variant{Record.Value.getSExtValue()};
     123             : }

Generated by: LCOV version 1.13