LLVM  4.0.0
TypeRecord.cpp
Go to the documentation of this file.
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 
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  if (Idx.isSimple())
26  return true;
27  unsigned MapPos = Idx.getIndex() - TypeIndex::FirstNonSimpleIndex;
28  if (MapPos < IndexMap.size()) {
29  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.
36  return false;
37 }
38 
40  return remapIndex(IndexMap, ModifiedType);
41 }
42 
44  bool Success = true;
45  Success &= remapIndex(IndexMap, ReturnType);
46  Success &= remapIndex(IndexMap, ArgumentList);
47  return Success;
48 }
49 
51  bool Success = true;
52  Success &= remapIndex(IndexMap, ReturnType);
53  Success &= remapIndex(IndexMap, ClassType);
54  Success &= remapIndex(IndexMap, ThisType);
55  Success &= remapIndex(IndexMap, ArgumentList);
56  return Success;
57 }
58 
60  bool Success = true;
61  Success &= remapIndex(IndexMap, ClassType);
62  Success &= remapIndex(IndexMap, FunctionType);
63  return Success;
64 }
65 
67  bool Success = true;
68  for (TypeIndex &Str : StringIndices)
69  Success &= remapIndex(IndexMap, Str);
70  return Success;
71 }
72 
74  return remapIndex(IndexMap, ContainingType);
75 }
76 
78  bool Success = true;
79  Success &= remapIndex(IndexMap, ReferentType);
80  if (isPointerToMember())
81  Success &= MemberInfo->remapTypeIndices(IndexMap);
82  return Success;
83 }
84 
86  return remapIndex(IndexMap, Type);
87 }
88 
90  bool Success = true;
91  Success &= remapIndex(IndexMap, ElementType);
92  Success &= remapIndex(IndexMap, IndexType);
93  return Success;
94 }
95 
97  return remapIndex(IndexMap, FieldList);
98 }
99 
101  bool Success = true;
102  Success &= TagRecord::remapTypeIndices(IndexMap);
103  Success &= remapIndex(IndexMap, DerivationList);
104  Success &= remapIndex(IndexMap, VTableShape);
105  return Success;
106 }
107 
109  bool Success = true;
110  Success &= TagRecord::remapTypeIndices(IndexMap);
111  Success &= remapIndex(IndexMap, UnderlyingType);
112  return Success;
113 }
114 
116  return remapIndex(IndexMap, Type);
117 }
118 
120  return true;
121 }
122 
124  return true;
125 }
126 
128  return remapIndex(IndexMap, Id);
129 }
130 
132  bool Success = true;
133  Success &= remapIndex(IndexMap, ParentScope);
134  Success &= remapIndex(IndexMap, FunctionType);
135  return Success;
136 }
137 
139  bool Success = true;
140  Success &= remapIndex(IndexMap, UDT);
141  Success &= remapIndex(IndexMap, SourceFile);
142  return Success;
143 }
144 
146  bool Success = true;
147  Success &= remapIndex(IndexMap, UDT);
148  Success &= remapIndex(IndexMap, SourceFile);
149  return Success;
150 }
151 
153  bool Success = true;
154  for (TypeIndex &Arg : ArgIndices)
155  Success &= remapIndex(IndexMap, Arg);
156  return Success;
157 }
158 
160  bool Success = true;
161  Success &= remapIndex(IndexMap, CompleteClass);
162  Success &= remapIndex(IndexMap, OverriddenVFTable);
163  return Success;
164 }
165 
167  bool Success = true;
168  Success &= remapIndex(IndexMap, Type);
169  return Success;
170 }
171 
173  bool Success = true;
174  for (OneMethodRecord &Meth : Methods)
175  if ((Success = Meth.remapTypeIndices(IndexMap)))
176  return Success;
177  return Success;
178 }
179 
181  return remapIndex(IndexMap, MethodList);
182 }
183 
185  return remapIndex(IndexMap, Type);
186 }
187 
189  return remapIndex(IndexMap, Type);
190 }
191 
193  return true;
194 }
195 
197  return remapIndex(IndexMap, Type);
198 }
199 
201  return remapIndex(IndexMap, Type);
202 }
203 
205  bool Success = true;
206  Success &= remapIndex(IndexMap, BaseType);
207  Success &= remapIndex(IndexMap, VBPtrType);
208  return Success;
209 }
210 
212  return remapIndex(IndexMap, ContinuationIndex);
213 }
bool isSimple() const
Definition: TypeIndex.h:105
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap. Returns false if a type index is not in the map...
Definition: TypeRecord.cpp:108
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:100
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:184
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:123
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:131
std::vector< TypeIndex > StringIndices
Definition: TypeRecord.h:254
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:119
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:39
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:73
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:59
bool isPointerToMember() const
Definition: TypeRecord.h:319
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:50
Class to represent function types.
Definition: DerivedTypes.h:102
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:91
A 32-bit type reference.
Definition: TypeIndex.h:89
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:85
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:141
uint32_t getIndex() const
Definition: TypeIndex.h:103
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:89
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:166
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
static bool remapIndex(ArrayRef< TypeIndex > IndexMap, TypeIndex &Idx)
Definition: TypeRecord.cpp:23
Optional< MemberPointerInfo > MemberInfo
Definition: TypeRecord.h:338
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:127
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:152
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:196
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:204
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:188
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:200
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:77
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:43
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:138
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:115
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Definition: TypeRecord.cpp:211
#define Success
std::vector< OneMethodRecord > Methods
Definition: TypeRecord.h:762
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:66
SmallVector< TypeIndex, 4 > ArgIndices
Definition: TypeRecord.h:680
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:159
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:172
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Definition: TypeRecord.cpp:145
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:192
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:96
bool remapTypeIndices(ArrayRef< TypeIndex > IndexMap)
Rewrite member type indices with IndexMap.
Definition: TypeRecord.cpp:180