LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - TypeRecord.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 107 122 87.7 %
Date: 2017-03-23 04:51:17 Functions: 27 32 84.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- TypeRecord.cpp ------------------------------------------*- 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/CodeView/TypeRecord.h"
      11             : #include "llvm/DebugInfo/CodeView/RecordSerialization.h"
      12             : #include "llvm/DebugInfo/CodeView/TypeIndex.h"
      13             : #include "llvm/Support/BinaryByteStream.h"
      14             : #include "llvm/Support/BinaryStreamReader.h"
      15             : 
      16             : using namespace llvm;
      17             : using namespace llvm::codeview;
      18             : 
      19             : //===----------------------------------------------------------------------===//
      20             : // Type index remapping
      21             : //===----------------------------------------------------------------------===//
      22             : 
      23             : static bool remapIndex(ArrayRef<TypeIndex> IndexMap, TypeIndex &Idx) {
      24             :   // Simple types are unchanged.
      25         904 :   if (Idx.isSimple())
      26             :     return true;
      27         590 :   unsigned MapPos = Idx.getIndex() - TypeIndex::FirstNonSimpleIndex;
      28         590 :   if (MapPos < IndexMap.size()) {
      29        1180 :     Idx = IndexMap[MapPos];
      30             :     return true;
      31             :   }
      32             : 
      33             :   // This type index is invalid. Remap this to "not translated by cvpack",
      34             :   // and return failure.
      35           0 :   Idx = TypeIndex(SimpleTypeKind::NotTranslated, SimpleTypeMode::Direct);
      36             :   return false;
      37             : }
      38             : 
      39           8 : bool ModifierRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      40          16 :   return remapIndex(IndexMap, ModifiedType);
      41             : }
      42             : 
      43          14 : bool ProcedureRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      44          14 :   bool Success = true;
      45          28 :   Success &= remapIndex(IndexMap, ReturnType);
      46          28 :   Success &= remapIndex(IndexMap, ArgumentList);
      47          14 :   return Success;
      48             : }
      49             : 
      50          49 : bool MemberFunctionRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      51          49 :   bool Success = true;
      52          98 :   Success &= remapIndex(IndexMap, ReturnType);
      53          98 :   Success &= remapIndex(IndexMap, ClassType);
      54          98 :   Success &= remapIndex(IndexMap, ThisType);
      55          98 :   Success &= remapIndex(IndexMap, ArgumentList);
      56          49 :   return Success;
      57             : }
      58             : 
      59           8 : bool MemberFuncIdRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      60           8 :   bool Success = true;
      61          16 :   Success &= remapIndex(IndexMap, ClassType);
      62          16 :   Success &= remapIndex(IndexMap, FunctionType);
      63           8 :   return Success;
      64             : }
      65             : 
      66          40 : bool ArgListRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      67          40 :   bool Success = true;
      68         221 :   for (TypeIndex &Arg : ArgIndices)
      69          61 :     Success &= remapIndex(IndexMap, Arg);
      70          40 :   return Success;
      71             : }
      72             : 
      73           8 : bool StringListRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      74           8 :   bool Success = true;
      75          40 :   for (TypeIndex &Str : StringIndices)
      76           8 :     Success &= remapIndex(IndexMap, Str);
      77           8 :   return Success;
      78             : }
      79             : 
      80           0 : bool MemberPointerInfo::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      81           0 :   return remapIndex(IndexMap, ContainingType);
      82             : }
      83             : 
      84          51 : bool PointerRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      85          51 :   bool Success = true;
      86         102 :   Success &= remapIndex(IndexMap, ReferentType);
      87          51 :   if (isPointerToMember())
      88           0 :     Success &= MemberInfo->remapTypeIndices(IndexMap);
      89          51 :   return Success;
      90             : }
      91             : 
      92          17 : bool NestedTypeRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      93          34 :   return remapIndex(IndexMap, Type);
      94             : }
      95             : 
      96           4 : bool ArrayRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
      97           4 :   bool Success = true;
      98           8 :   Success &= remapIndex(IndexMap, ElementType);
      99           8 :   Success &= remapIndex(IndexMap, IndexType);
     100           4 :   return Success;
     101             : }
     102             : 
     103          67 : bool TagRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     104         134 :   return remapIndex(IndexMap, FieldList);
     105             : }
     106             : 
     107          48 : bool ClassRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     108          48 :   bool Success = true;
     109          48 :   Success &= TagRecord::remapTypeIndices(IndexMap);
     110          96 :   Success &= remapIndex(IndexMap, DerivationList);
     111          96 :   Success &= remapIndex(IndexMap, VTableShape);
     112          48 :   return Success;
     113             : }
     114             : 
     115          17 : bool EnumRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     116          17 :   bool Success = true;
     117          17 :   Success &= TagRecord::remapTypeIndices(IndexMap);
     118          34 :   Success &= remapIndex(IndexMap, UnderlyingType);
     119          17 :   return Success;
     120             : }
     121             : 
     122           0 : bool BitFieldRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     123           0 :   return remapIndex(IndexMap, Type);
     124             : }
     125             : 
     126           3 : bool VFTableShapeRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     127           3 :   return true;
     128             : }
     129             : 
     130           0 : bool TypeServer2Record::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     131           0 :   return true;
     132             : }
     133             : 
     134          58 : bool StringIdRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     135         116 :   return remapIndex(IndexMap, Id);
     136             : }
     137             : 
     138          15 : bool FuncIdRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     139          15 :   bool Success = true;
     140          30 :   Success &= remapIndex(IndexMap, ParentScope);
     141          30 :   Success &= remapIndex(IndexMap, FunctionType);
     142          15 :   return Success;
     143             : }
     144             : 
     145          41 : bool UdtSourceLineRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     146          41 :   bool Success = true;
     147          82 :   Success &= remapIndex(IndexMap, UDT);
     148          82 :   Success &= remapIndex(IndexMap, SourceFile);
     149          41 :   return Success;
     150             : }
     151             : 
     152           0 : bool UdtModSourceLineRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     153           0 :   bool Success = true;
     154           0 :   Success &= remapIndex(IndexMap, UDT);
     155           0 :   Success &= remapIndex(IndexMap, SourceFile);
     156           0 :   return Success;
     157             : }
     158             : 
     159           9 : bool BuildInfoRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     160           9 :   bool Success = true;
     161          72 :   for (TypeIndex &Arg : ArgIndices)
     162          45 :     Success &= remapIndex(IndexMap, Arg);
     163           9 :   return Success;
     164             : }
     165             : 
     166           2 : bool VFTableRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     167           2 :   bool Success = true;
     168           4 :   Success &= remapIndex(IndexMap, CompleteClass);
     169           4 :   Success &= remapIndex(IndexMap, OverriddenVFTable);
     170           2 :   return Success;
     171             : }
     172             : 
     173          28 : bool OneMethodRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     174          28 :   bool Success = true;
     175          56 :   Success &= remapIndex(IndexMap, Type);
     176          28 :   return Success;
     177             : }
     178             : 
     179          16 : bool MethodOverloadListRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     180          16 :   bool Success = true;
     181          64 :   for (OneMethodRecord &Meth : Methods)
     182          16 :     if ((Success = Meth.remapTypeIndices(IndexMap)))
     183             :       return Success;
     184             :   return Success;
     185             : }
     186             : 
     187          16 : bool OverloadedMethodRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     188          32 :   return remapIndex(IndexMap, MethodList);
     189             : }
     190             : 
     191          57 : bool DataMemberRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     192         114 :   return remapIndex(IndexMap, Type);
     193             : }
     194             : 
     195           1 : bool StaticDataMemberRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     196           2 :   return remapIndex(IndexMap, Type);
     197             : }
     198             : 
     199         114 : bool EnumeratorRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     200         114 :   return true;
     201             : }
     202             : 
     203           1 : bool VFPtrRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     204           2 :   return remapIndex(IndexMap, Type);
     205             : }
     206             : 
     207           3 : bool BaseClassRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     208           6 :   return remapIndex(IndexMap, Type);
     209             : }
     210             : 
     211           3 : bool VirtualBaseClassRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     212           3 :   bool Success = true;
     213           6 :   Success &= remapIndex(IndexMap, BaseType);
     214           6 :   Success &= remapIndex(IndexMap, VBPtrType);
     215           3 :   return Success;
     216             : }
     217             : 
     218           0 : bool ListContinuationRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
     219           0 :   return remapIndex(IndexMap, ContinuationIndex);
     220             : }

Generated by: LCOV version 1.13