0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 //===--- DIBuilder.cpp - Debug Information Builder ------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // The LLVM Compiler Infrastructure
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is distributed under the University of Illinois Open Source
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // License. See LICENSE.TXT for details.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // This file implements the DIBuilder.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13
|
77
|
14 #include "llvm/IR/DIBuilder.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 #include "llvm/ADT/STLExtras.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 #include "llvm/IR/Constants.h"
|
77
|
17 #include "llvm/IR/DebugInfo.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 #include "llvm/IR/IntrinsicInst.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 #include "llvm/IR/Module.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 #include "llvm/Support/Debug.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 #include "llvm/Support/Dwarf.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 using namespace llvm;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 using namespace llvm::dwarf;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25
|
83
|
26 namespace {
|
|
27 class HeaderBuilder {
|
|
28 /// \brief Whether there are any fields yet.
|
|
29 ///
|
|
30 /// Note that this is not equivalent to \c Chars.empty(), since \a concat()
|
|
31 /// may have been called already with an empty string.
|
|
32 bool IsEmpty;
|
|
33 SmallVector<char, 256> Chars;
|
|
34
|
|
35 public:
|
|
36 HeaderBuilder() : IsEmpty(true) {}
|
|
37 HeaderBuilder(const HeaderBuilder &X) : IsEmpty(X.IsEmpty), Chars(X.Chars) {}
|
|
38 HeaderBuilder(HeaderBuilder &&X)
|
|
39 : IsEmpty(X.IsEmpty), Chars(std::move(X.Chars)) {}
|
|
40
|
|
41 template <class Twineable> HeaderBuilder &concat(Twineable &&X) {
|
|
42 if (IsEmpty)
|
|
43 IsEmpty = false;
|
|
44 else
|
|
45 Chars.push_back(0);
|
|
46 Twine(X).toVector(Chars);
|
|
47 return *this;
|
|
48 }
|
|
49
|
|
50 MDString *get(LLVMContext &Context) const {
|
|
51 return MDString::get(Context, StringRef(Chars.begin(), Chars.size()));
|
|
52 }
|
|
53
|
|
54 static HeaderBuilder get(unsigned Tag) {
|
|
55 return HeaderBuilder().concat("0x" + Twine::utohexstr(Tag));
|
|
56 }
|
|
57 };
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59
|
83
|
60 DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes)
|
95
|
61 : M(m), VMContext(M.getContext()), CUNode(nullptr),
|
83
|
62 DeclareFn(nullptr), ValueFn(nullptr),
|
|
63 AllowUnresolvedNodes(AllowUnresolvedNodes) {}
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64
|
83
|
65 void DIBuilder::trackIfUnresolved(MDNode *N) {
|
|
66 if (!N)
|
|
67 return;
|
|
68 if (N->isResolved())
|
|
69 return;
|
|
70
|
|
71 assert(AllowUnresolvedNodes && "Cannot handle unresolved nodes");
|
|
72 UnresolvedNodes.emplace_back(N);
|
|
73 }
|
|
74
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 void DIBuilder::finalize() {
|
95
|
76 if (!CUNode) {
|
|
77 assert(!AllowUnresolvedNodes &&
|
|
78 "creating type nodes without a CU is not supported");
|
|
79 return;
|
|
80 }
|
|
81
|
|
82 CUNode->replaceEnumTypes(MDTuple::get(VMContext, AllEnumTypes));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83
|
83
|
84 SmallVector<Metadata *, 16> RetainValues;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 // Declarations and definitions of the same type may be retained. Some
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 // clients RAUW these pairs, leaving duplicates in the retained types
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 // list. Use a set to remove the duplicates while we transform the
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 // TrackingVHs back into Values.
|
83
|
89 SmallPtrSet<Metadata *, 16> RetainSet;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)
|
83
|
91 if (RetainSet.insert(AllRetainTypes[I]).second)
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 RetainValues.push_back(AllRetainTypes[I]);
|
95
|
93
|
|
94 if (!RetainValues.empty())
|
|
95 CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96
|
95
|
97 DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
|
|
98 if (!AllSubprograms.empty())
|
|
99 CUNode->replaceSubprograms(SPs.get());
|
|
100
|
|
101 for (auto *SP : SPs) {
|
|
102 if (MDTuple *Temp = SP->getVariables().get()) {
|
83
|
103 const auto &PV = PreservedVariables.lookup(SP);
|
|
104 SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
|
95
|
105 DINodeArray AV = getOrCreateArray(Variables);
|
|
106 TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109
|
95
|
110 if (!AllGVs.empty())
|
|
111 CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112
|
95
|
113 if (!AllImportedModules.empty())
|
|
114 CUNode->replaceImportedEntities(MDTuple::get(
|
|
115 VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),
|
|
116 AllImportedModules.end())));
|
83
|
117
|
|
118 // Now that all temp nodes have been replaced or deleted, resolve remaining
|
|
119 // cycles.
|
|
120 for (const auto &N : UnresolvedNodes)
|
|
121 if (N && !N->isResolved())
|
|
122 N->resolveCycles();
|
|
123 UnresolvedNodes.clear();
|
|
124
|
|
125 // Can't handle unresolved nodes anymore.
|
|
126 AllowUnresolvedNodes = false;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128
|
83
|
129 /// If N is compile unit return NULL otherwise return N.
|
95
|
130 static DIScope *getNonCompileUnitScope(DIScope *N) {
|
|
131 if (!N || isa<DICompileUnit>(N))
|
77
|
132 return nullptr;
|
95
|
133 return cast<DIScope>(N);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135
|
95
|
136 DICompileUnit *DIBuilder::createCompileUnit(
|
|
137 unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer,
|
|
138 bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
|
|
139 DebugEmissionKind Kind, uint64_t DWOId, bool EmitDebugInfo) {
|
77
|
140
|
83
|
141 assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 "Invalid Language tag");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 assert(!Filename.empty() &&
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 "Unable to create compile unit without filename");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146
|
95
|
147 assert(!CUNode && "Can only make one compile unit per DIBuilder instance");
|
|
148 CUNode = DICompileUnit::getDistinct(
|
|
149 VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer,
|
|
150 isOptimized, Flags, RunTimeVer, SplitName, Kind, nullptr,
|
100
|
151 nullptr, nullptr, nullptr, nullptr, nullptr, DWOId);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 // Create a named metadata so that it is easier to find cu in a module.
|
77
|
154 // Note that we only generate this when the caller wants to actually
|
|
155 // emit debug information. When we are only interested in tracking
|
|
156 // source line locations throughout the backend, we prevent codegen from
|
|
157 // emitting debug info in the final output by not generating llvm.dbg.cu.
|
|
158 if (EmitDebugInfo) {
|
|
159 NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
|
|
160 NMD->addOperand(CUNode);
|
|
161 }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162
|
83
|
163 trackIfUnresolved(CUNode);
|
95
|
164 return CUNode;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166
|
95
|
167 static DIImportedEntity *
|
|
168 createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context,
|
83
|
169 Metadata *NS, unsigned Line, StringRef Name,
|
|
170 SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
|
95
|
171 auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name);
|
|
172 AllImportedModules.emplace_back(M);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
173 return M;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175
|
95
|
176 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
|
|
177 DINamespace *NS,
|
|
178 unsigned Line) {
|
77
|
179 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
|
|
180 Context, NS, Line, StringRef(), AllImportedModules);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182
|
95
|
183 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
|
|
184 DIImportedEntity *NS,
|
|
185 unsigned Line) {
|
77
|
186 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
|
|
187 Context, NS, Line, StringRef(), AllImportedModules);
|
|
188 }
|
|
189
|
95
|
190 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context, DIModule *M,
|
|
191 unsigned Line) {
|
|
192 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
|
|
193 Context, M, Line, StringRef(), AllImportedModules);
|
|
194 }
|
|
195
|
|
196 DIImportedEntity *DIBuilder::createImportedDeclaration(DIScope *Context,
|
|
197 DINode *Decl,
|
|
198 unsigned Line,
|
|
199 StringRef Name) {
|
83
|
200 // Make sure to use the unique identifier based metadata reference for
|
|
201 // types that have one.
|
77
|
202 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
|
95
|
203 Context, DINodeRef::get(Decl), Line, Name,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 AllImportedModules);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206
|
95
|
207 DIFile *DIBuilder::createFile(StringRef Filename, StringRef Directory) {
|
|
208 return DIFile::get(VMContext, Filename, Directory);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
210
|
95
|
211 DIEnumerator *DIBuilder::createEnumerator(StringRef Name, int64_t Val) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 assert(!Name.empty() && "Unable to create enumerator without name");
|
95
|
213 return DIEnumerator::get(VMContext, Val, Name);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215
|
95
|
216 DIBasicType *DIBuilder::createUnspecifiedType(StringRef Name) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 assert(!Name.empty() && "Unable to create type without name");
|
95
|
218 return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220
|
95
|
221 DIBasicType *DIBuilder::createNullPtrType() {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 return createUnspecifiedType("decltype(nullptr)");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224
|
95
|
225 DIBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
|
|
226 uint64_t AlignInBits,
|
|
227 unsigned Encoding) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 assert(!Name.empty() && "Unable to create type without name");
|
95
|
229 return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
|
|
230 AlignInBits, Encoding);
|
|
231 }
|
|
232
|
|
233 DIDerivedType *DIBuilder::createQualifiedType(unsigned Tag, DIType *FromTy) {
|
|
234 return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
|
|
235 DITypeRef::get(FromTy), 0, 0, 0, 0);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
237
|
95
|
238 DIDerivedType *DIBuilder::createPointerType(DIType *PointeeTy,
|
|
239 uint64_t SizeInBits,
|
|
240 uint64_t AlignInBits,
|
|
241 StringRef Name) {
|
|
242 // FIXME: Why is there a name here?
|
|
243 return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
|
|
244 nullptr, 0, nullptr, DITypeRef::get(PointeeTy),
|
|
245 SizeInBits, AlignInBits, 0, 0);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247
|
95
|
248 DIDerivedType *DIBuilder::createMemberPointerType(DIType *PointeeTy,
|
|
249 DIType *Base,
|
|
250 uint64_t SizeInBits,
|
|
251 uint64_t AlignInBits) {
|
|
252 return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
|
|
253 nullptr, 0, nullptr, DITypeRef::get(PointeeTy),
|
|
254 SizeInBits, AlignInBits, 0, 0,
|
|
255 DITypeRef::get(Base));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
256 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
257
|
100
|
258 DIDerivedType *DIBuilder::createReferenceType(unsigned Tag, DIType *RTy,
|
|
259 uint64_t SizeInBits,
|
|
260 uint64_t AlignInBits) {
|
95
|
261 assert(RTy && "Unable to create reference type");
|
|
262 return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
|
100
|
263 DITypeRef::get(RTy), SizeInBits, AlignInBits, 0, 0);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
265
|
95
|
266 DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name,
|
|
267 DIFile *File, unsigned LineNo,
|
|
268 DIScope *Context) {
|
|
269 return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
|
|
270 LineNo,
|
|
271 DIScopeRef::get(getNonCompileUnitScope(Context)),
|
|
272 DITypeRef::get(Ty), 0, 0, 0, 0);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
273 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
274
|
95
|
275 DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) {
|
|
276 assert(Ty && "Invalid type!");
|
|
277 assert(FriendTy && "Invalid friend type!");
|
|
278 return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0,
|
|
279 DITypeRef::get(Ty), DITypeRef::get(FriendTy), 0, 0,
|
|
280 0, 0);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
281 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
282
|
95
|
283 DIDerivedType *DIBuilder::createInheritance(DIType *Ty, DIType *BaseTy,
|
|
284 uint64_t BaseOffset,
|
|
285 unsigned Flags) {
|
|
286 assert(Ty && "Unable to create inheritance");
|
|
287 return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
|
|
288 0, DITypeRef::get(Ty), DITypeRef::get(BaseTy), 0, 0,
|
|
289 BaseOffset, Flags);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
290 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291
|
95
|
292 DIDerivedType *DIBuilder::createMemberType(DIScope *Scope, StringRef Name,
|
|
293 DIFile *File, unsigned LineNumber,
|
|
294 uint64_t SizeInBits,
|
|
295 uint64_t AlignInBits,
|
|
296 uint64_t OffsetInBits,
|
|
297 unsigned Flags, DIType *Ty) {
|
|
298 return DIDerivedType::get(
|
|
299 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
|
|
300 DIScopeRef::get(getNonCompileUnitScope(Scope)), DITypeRef::get(Ty),
|
|
301 SizeInBits, AlignInBits, OffsetInBits, Flags);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
303
|
95
|
304 static ConstantAsMetadata *getConstantOrNull(Constant *C) {
|
83
|
305 if (C)
|
|
306 return ConstantAsMetadata::get(C);
|
|
307 return nullptr;
|
|
308 }
|
|
309
|
95
|
310 DIDerivedType *DIBuilder::createStaticMemberType(DIScope *Scope, StringRef Name,
|
|
311 DIFile *File,
|
|
312 unsigned LineNumber,
|
|
313 DIType *Ty, unsigned Flags,
|
|
314 llvm::Constant *Val) {
|
|
315 Flags |= DINode::FlagStaticMember;
|
|
316 return DIDerivedType::get(
|
|
317 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
|
|
318 DIScopeRef::get(getNonCompileUnitScope(Scope)), DITypeRef::get(Ty), 0, 0,
|
|
319 0, Flags, getConstantOrNull(Val));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
320 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
321
|
95
|
322 DIDerivedType *DIBuilder::createObjCIVar(StringRef Name, DIFile *File,
|
|
323 unsigned LineNumber,
|
|
324 uint64_t SizeInBits,
|
|
325 uint64_t AlignInBits,
|
|
326 uint64_t OffsetInBits, unsigned Flags,
|
|
327 DIType *Ty, MDNode *PropertyNode) {
|
|
328 return DIDerivedType::get(
|
|
329 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
|
|
330 DIScopeRef::get(getNonCompileUnitScope(File)), DITypeRef::get(Ty),
|
|
331 SizeInBits, AlignInBits, OffsetInBits, Flags, PropertyNode);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
332 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
333
|
95
|
334 DIObjCProperty *
|
|
335 DIBuilder::createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
336 StringRef GetterName, StringRef SetterName,
|
95
|
337 unsigned PropertyAttributes, DIType *Ty) {
|
|
338 return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
|
|
339 SetterName, PropertyAttributes,
|
|
340 DITypeRef::get(Ty));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
341 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
342
|
95
|
343 DITemplateTypeParameter *
|
|
344 DIBuilder::createTemplateTypeParameter(DIScope *Context, StringRef Name,
|
|
345 DIType *Ty) {
|
|
346 assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
|
|
347 return DITemplateTypeParameter::get(VMContext, Name, DITypeRef::get(Ty));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
348 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
349
|
95
|
350 static DITemplateValueParameter *
|
83
|
351 createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag,
|
95
|
352 DIScope *Context, StringRef Name, DIType *Ty,
|
|
353 Metadata *MD) {
|
|
354 assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
|
|
355 return DITemplateValueParameter::get(VMContext, Tag, Name, DITypeRef::get(Ty),
|
|
356 MD);
|
83
|
357 }
|
|
358
|
95
|
359 DITemplateValueParameter *
|
|
360 DIBuilder::createTemplateValueParameter(DIScope *Context, StringRef Name,
|
|
361 DIType *Ty, Constant *Val) {
|
83
|
362 return createTemplateValueParameterHelper(
|
|
363 VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
|
|
364 getConstantOrNull(Val));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
365 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
366
|
95
|
367 DITemplateValueParameter *
|
|
368 DIBuilder::createTemplateTemplateParameter(DIScope *Context, StringRef Name,
|
|
369 DIType *Ty, StringRef Val) {
|
83
|
370 return createTemplateValueParameterHelper(
|
|
371 VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
|
|
372 MDString::get(VMContext, Val));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
373 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
374
|
95
|
375 DITemplateValueParameter *
|
|
376 DIBuilder::createTemplateParameterPack(DIScope *Context, StringRef Name,
|
|
377 DIType *Ty, DINodeArray Val) {
|
83
|
378 return createTemplateValueParameterHelper(
|
|
379 VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
|
95
|
380 Val.get());
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
381 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
382
|
95
|
383 DICompositeType *DIBuilder::createClassType(
|
|
384 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
|
|
385 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
|
|
386 unsigned Flags, DIType *DerivedFrom, DINodeArray Elements,
|
|
387 DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
|
|
388 assert((!Context || isa<DIScope>(Context)) &&
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
389 "createClassType should be called with a valid Context");
|
95
|
390
|
|
391 auto *R = DICompositeType::get(
|
|
392 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
|
|
393 DIScopeRef::get(getNonCompileUnitScope(Context)),
|
|
394 DITypeRef::get(DerivedFrom), SizeInBits, AlignInBits, OffsetInBits, Flags,
|
|
395 Elements, 0, DITypeRef::get(VTableHolder),
|
|
396 cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
397 if (!UniqueIdentifier.empty())
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
398 retainType(R);
|
83
|
399 trackIfUnresolved(R);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
400 return R;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
401 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
402
|
95
|
403 DICompositeType *DIBuilder::createStructType(
|
|
404 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
|
|
405 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
|
|
406 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
|
|
407 DIType *VTableHolder, StringRef UniqueIdentifier) {
|
|
408 auto *R = DICompositeType::get(
|
|
409 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
|
|
410 DIScopeRef::get(getNonCompileUnitScope(Context)),
|
|
411 DITypeRef::get(DerivedFrom), SizeInBits, AlignInBits, 0, Flags, Elements,
|
|
412 RunTimeLang, DITypeRef::get(VTableHolder), nullptr, UniqueIdentifier);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
413 if (!UniqueIdentifier.empty())
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
414 retainType(R);
|
83
|
415 trackIfUnresolved(R);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
416 return R;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
417 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
418
|
95
|
419 DICompositeType *DIBuilder::createUnionType(
|
|
420 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
|
|
421 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
|
|
422 DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
|
|
423 auto *R = DICompositeType::get(
|
|
424 VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
|
|
425 DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits,
|
|
426 AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr, nullptr,
|
|
427 UniqueIdentifier);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
428 if (!UniqueIdentifier.empty())
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
429 retainType(R);
|
83
|
430 trackIfUnresolved(R);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
431 return R;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
432 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
433
|
100
|
434 DISubroutineType *DIBuilder::createSubroutineType(DITypeRefArray ParameterTypes,
|
95
|
435 unsigned Flags) {
|
|
436 return DISubroutineType::get(VMContext, Flags, ParameterTypes);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
437 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
438
|
95
|
439 DICompositeType *DIBuilder::createExternalTypeRef(unsigned Tag, DIFile *File,
|
|
440 StringRef UniqueIdentifier) {
|
|
441 assert(!UniqueIdentifier.empty() && "external type ref without uid");
|
|
442 auto *CTy =
|
|
443 DICompositeType::get(VMContext, Tag, "", nullptr, 0, nullptr, nullptr, 0,
|
|
444 0, 0, DINode::FlagExternalTypeRef, nullptr, 0,
|
|
445 nullptr, nullptr, UniqueIdentifier);
|
|
446 // Types with unique IDs need to be in the type map.
|
|
447 retainType(CTy);
|
|
448 return CTy;
|
|
449 }
|
|
450
|
|
451 DICompositeType *DIBuilder::createEnumerationType(
|
|
452 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
|
|
453 uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
|
|
454 DIType *UnderlyingType, StringRef UniqueIdentifier) {
|
|
455 auto *CTy = DICompositeType::get(
|
|
456 VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
|
|
457 DIScopeRef::get(getNonCompileUnitScope(Scope)),
|
|
458 DITypeRef::get(UnderlyingType), SizeInBits, AlignInBits, 0, 0, Elements,
|
|
459 0, nullptr, nullptr, UniqueIdentifier);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
460 AllEnumTypes.push_back(CTy);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
461 if (!UniqueIdentifier.empty())
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
462 retainType(CTy);
|
83
|
463 trackIfUnresolved(CTy);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
464 return CTy;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
465 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
466
|
95
|
467 DICompositeType *DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
|
|
468 DIType *Ty,
|
|
469 DINodeArray Subscripts) {
|
|
470 auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
|
|
471 nullptr, 0, nullptr, DITypeRef::get(Ty), Size,
|
|
472 AlignInBits, 0, 0, Subscripts, 0, nullptr);
|
83
|
473 trackIfUnresolved(R);
|
|
474 return R;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
475 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
476
|
95
|
477 DICompositeType *DIBuilder::createVectorType(uint64_t Size,
|
|
478 uint64_t AlignInBits, DIType *Ty,
|
|
479 DINodeArray Subscripts) {
|
|
480 auto *R =
|
|
481 DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0,
|
|
482 nullptr, DITypeRef::get(Ty), Size, AlignInBits, 0,
|
|
483 DINode::FlagVector, Subscripts, 0, nullptr);
|
83
|
484 trackIfUnresolved(R);
|
|
485 return R;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
486 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
487
|
95
|
488 static DIType *createTypeWithFlags(LLVMContext &Context, DIType *Ty,
|
|
489 unsigned FlagsToSet) {
|
|
490 auto NewTy = Ty->clone();
|
|
491 NewTy->setFlags(NewTy->getFlags() | FlagsToSet);
|
|
492 return MDNode::replaceWithUniqued(std::move(NewTy));
|
83
|
493 }
|
|
494
|
95
|
495 DIType *DIBuilder::createArtificialType(DIType *Ty) {
|
|
496 // FIXME: Restrict this to the nodes where it's valid.
|
|
497 if (Ty->isArtificial())
|
|
498 return Ty;
|
|
499 return createTypeWithFlags(VMContext, Ty, DINode::FlagArtificial);
|
83
|
500 }
|
|
501
|
95
|
502 DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
|
|
503 // FIXME: Restrict this to the nodes where it's valid.
|
|
504 if (Ty->isObjectPointer())
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
505 return Ty;
|
95
|
506 unsigned Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
|
83
|
507 return createTypeWithFlags(VMContext, Ty, Flags);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
508 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
509
|
95
|
510 void DIBuilder::retainType(DIType *T) {
|
|
511 assert(T && "Expected non-null type");
|
|
512 AllRetainTypes.emplace_back(T);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
513 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
514
|
95
|
515 DIBasicType *DIBuilder::createUnspecifiedParameter() { return nullptr; }
|
|
516
|
|
517 DICompositeType *
|
|
518 DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope,
|
|
519 DIFile *F, unsigned Line, unsigned RuntimeLang,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
520 uint64_t SizeInBits, uint64_t AlignInBits,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
521 StringRef UniqueIdentifier) {
|
95
|
522 // FIXME: Define in terms of createReplaceableForwardDecl() by calling
|
|
523 // replaceWithUniqued().
|
|
524 auto *RetTy = DICompositeType::get(
|
|
525 VMContext, Tag, Name, F, Line,
|
|
526 DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits,
|
|
527 AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang, nullptr,
|
|
528 nullptr, UniqueIdentifier);
|
|
529 if (!UniqueIdentifier.empty())
|
|
530 retainType(RetTy);
|
|
531 trackIfUnresolved(RetTy);
|
|
532 return RetTy;
|
|
533 }
|
|
534
|
|
535 DICompositeType *DIBuilder::createReplaceableCompositeType(
|
|
536 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
|
|
537 unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits,
|
|
538 unsigned Flags, StringRef UniqueIdentifier) {
|
|
539 auto *RetTy = DICompositeType::getTemporary(
|
|
540 VMContext, Tag, Name, F, Line,
|
|
541 DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr,
|
|
542 SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang,
|
|
543 nullptr, nullptr, UniqueIdentifier)
|
|
544 .release();
|
77
|
545 if (!UniqueIdentifier.empty())
|
|
546 retainType(RetTy);
|
83
|
547 trackIfUnresolved(RetTy);
|
77
|
548 return RetTy;
|
|
549 }
|
|
550
|
95
|
551 DINodeArray DIBuilder::getOrCreateArray(ArrayRef<Metadata *> Elements) {
|
|
552 return MDTuple::get(VMContext, Elements);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
553 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
554
|
95
|
555 DITypeRefArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) {
|
83
|
556 SmallVector<llvm::Metadata *, 16> Elts;
|
77
|
557 for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
|
|
558 if (Elements[i] && isa<MDNode>(Elements[i]))
|
95
|
559 Elts.push_back(DITypeRef::get(cast<DIType>(Elements[i])));
|
77
|
560 else
|
|
561 Elts.push_back(Elements[i]);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
562 }
|
95
|
563 return DITypeRefArray(MDNode::get(VMContext, Elts));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
564 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
565
|
95
|
566 DISubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
|
|
567 return DISubrange::get(VMContext, Count, Lo);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
568 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
569
|
95
|
570 static void checkGlobalVariableScope(DIScope *Context) {
|
|
571 #ifndef NDEBUG
|
|
572 if (auto *CT =
|
|
573 dyn_cast_or_null<DICompositeType>(getNonCompileUnitScope(Context)))
|
|
574 assert(CT->getIdentifier().empty() &&
|
83
|
575 "Context of a global variable should not be a type with identifier");
|
95
|
576 #endif
|
|
577 }
|
83
|
578
|
95
|
579 DIGlobalVariable *DIBuilder::createGlobalVariable(
|
|
580 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
|
|
581 unsigned LineNumber, DIType *Ty, bool isLocalToUnit, Constant *Val,
|
|
582 MDNode *Decl) {
|
|
583 checkGlobalVariableScope(Context);
|
83
|
584
|
95
|
585 auto *N = DIGlobalVariable::get(VMContext, cast_or_null<DIScope>(Context),
|
|
586 Name, LinkageName, F, LineNumber,
|
|
587 DITypeRef::get(Ty), isLocalToUnit, true, Val,
|
|
588 cast_or_null<DIDerivedType>(Decl));
|
|
589 AllGVs.push_back(N);
|
|
590 return N;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
591 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
592
|
95
|
593 DIGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl(
|
|
594 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
|
|
595 unsigned LineNumber, DIType *Ty, bool isLocalToUnit, Constant *Val,
|
83
|
596 MDNode *Decl) {
|
95
|
597 checkGlobalVariableScope(Context);
|
|
598
|
|
599 return DIGlobalVariable::getTemporary(
|
|
600 VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
|
|
601 LineNumber, DITypeRef::get(Ty), isLocalToUnit, false, Val,
|
|
602 cast_or_null<DIDerivedType>(Decl))
|
|
603 .release();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
604 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
605
|
95
|
606 static DILocalVariable *createLocalVariable(
|
|
607 LLVMContext &VMContext,
|
|
608 DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> &PreservedVariables,
|
|
609 DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
|
|
610 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) {
|
|
611 // FIXME: Why getNonCompileUnitScope()?
|
|
612 // FIXME: Why is "!Context" okay here?
|
|
613 // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
|
|
614 // the only valid scopes)?
|
|
615 DIScope *Context = getNonCompileUnitScope(Scope);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
616
|
95
|
617 auto *Node =
|
|
618 DILocalVariable::get(VMContext, cast_or_null<DILocalScope>(Context), Name,
|
|
619 File, LineNo, DITypeRef::get(Ty), ArgNo, Flags);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
620 if (AlwaysPreserve) {
|
95
|
621 // The optimizer may remove local variables. If there is an interest
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
622 // to preserve variable info in such situation then stash it in a
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
623 // named mdnode.
|
95
|
624 DISubprogram *Fn = getDISubprogram(Scope);
|
83
|
625 assert(Fn && "Missing subprogram for local variable");
|
|
626 PreservedVariables[Fn].emplace_back(Node);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
627 }
|
95
|
628 return Node;
|
|
629 }
|
|
630
|
|
631 DILocalVariable *DIBuilder::createAutoVariable(DIScope *Scope, StringRef Name,
|
|
632 DIFile *File, unsigned LineNo,
|
|
633 DIType *Ty, bool AlwaysPreserve,
|
|
634 unsigned Flags) {
|
|
635 return createLocalVariable(VMContext, PreservedVariables, Scope, Name,
|
|
636 /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve,
|
|
637 Flags);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
638 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
639
|
95
|
640 DILocalVariable *DIBuilder::createParameterVariable(
|
|
641 DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
|
|
642 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) {
|
|
643 assert(ArgNo && "Expected non-zero argument number for parameter");
|
|
644 return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo,
|
|
645 File, LineNo, Ty, AlwaysPreserve, Flags);
|
77
|
646 }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
647
|
95
|
648 DIExpression *DIBuilder::createExpression(ArrayRef<uint64_t> Addr) {
|
|
649 return DIExpression::get(VMContext, Addr);
|
|
650 }
|
|
651
|
|
652 DIExpression *DIBuilder::createExpression(ArrayRef<int64_t> Signed) {
|
83
|
653 // TODO: Remove the callers of this signed version and delete.
|
|
654 SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end());
|
|
655 return createExpression(Addr);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
656 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
657
|
95
|
658 DIExpression *DIBuilder::createBitPieceExpression(unsigned OffsetInBytes,
|
|
659 unsigned SizeInBytes) {
|
|
660 uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes};
|
|
661 return DIExpression::get(VMContext, Addr);
|
83
|
662 }
|
|
663
|
100
|
664 DISubprogram *DIBuilder::createFunction(
|
|
665 DIScopeRef Context, StringRef Name, StringRef LinkageName, DIFile *File,
|
|
666 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
|
|
667 bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
|
|
668 DITemplateParameterArray TParams, DISubprogram *Decl) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
669 // dragonegg does not generate identifier for types, so using an empty map
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
670 // to resolve the context should be fine.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
671 DITypeIdentifierMap EmptyMap;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
672 return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
673 LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
|
100
|
674 Flags, isOptimized, TParams, Decl);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
675 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
676
|
95
|
677 template <class... Ts>
|
|
678 static DISubprogram *getSubprogram(bool IsDistinct, Ts &&... Args) {
|
|
679 if (IsDistinct)
|
|
680 return DISubprogram::getDistinct(std::forward<Ts>(Args)...);
|
|
681 return DISubprogram::get(std::forward<Ts>(Args)...);
|
83
|
682 }
|
|
683
|
100
|
684 DISubprogram *DIBuilder::createFunction(
|
|
685 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
|
|
686 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
|
|
687 bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
|
|
688 DITemplateParameterArray TParams, DISubprogram *Decl) {
|
|
689 auto *Node =
|
|
690 getSubprogram(/* IsDistinct = */ isDefinition, VMContext,
|
|
691 DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
|
|
692 LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition,
|
|
693 ScopeLine, nullptr, 0, 0, Flags, isOptimized, TParams, Decl,
|
|
694 MDTuple::getTemporary(VMContext, None).release());
|
83
|
695
|
95
|
696 if (isDefinition)
|
|
697 AllSubprograms.push_back(Node);
|
|
698 trackIfUnresolved(Node);
|
|
699 return Node;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
700 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
701
|
95
|
702 DISubprogram *DIBuilder::createTempFunctionFwdDecl(
|
|
703 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
|
|
704 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
|
|
705 bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
|
100
|
706 DITemplateParameterArray TParams, DISubprogram *Decl) {
|
95
|
707 return DISubprogram::getTemporary(
|
|
708 VMContext, DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
|
|
709 LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition,
|
100
|
710 ScopeLine, nullptr, 0, 0, Flags, isOptimized, TParams, Decl,
|
95
|
711 nullptr)
|
|
712 .release();
|
83
|
713 }
|
|
714
|
95
|
715 DISubprogram *
|
|
716 DIBuilder::createMethod(DIScope *Context, StringRef Name, StringRef LinkageName,
|
|
717 DIFile *F, unsigned LineNo, DISubroutineType *Ty,
|
|
718 bool isLocalToUnit, bool isDefinition, unsigned VK,
|
|
719 unsigned VIndex, DIType *VTableHolder, unsigned Flags,
|
100
|
720 bool isOptimized, DITemplateParameterArray TParams) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
721 assert(getNonCompileUnitScope(Context) &&
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
722 "Methods should have both a Context and a context that isn't "
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
723 "the compile unit.");
|
95
|
724 // FIXME: Do we want to use different scope/lines?
|
100
|
725 auto *SP = getSubprogram(
|
|
726 /* IsDistinct = */ isDefinition, VMContext,
|
|
727 DIScopeRef::get(cast<DIScope>(Context)), Name, LinkageName, F, LineNo, Ty,
|
|
728 isLocalToUnit, isDefinition, LineNo, DITypeRef::get(VTableHolder), VK,
|
|
729 VIndex, Flags, isOptimized, TParams, nullptr, nullptr);
|
95
|
730
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
731 if (isDefinition)
|
95
|
732 AllSubprograms.push_back(SP);
|
|
733 trackIfUnresolved(SP);
|
|
734 return SP;
|
|
735 }
|
|
736
|
|
737 DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name,
|
|
738 DIFile *File, unsigned LineNo) {
|
|
739 return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
|
|
740 LineNo);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
741 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
742
|
95
|
743 DIModule *DIBuilder::createModule(DIScope *Scope, StringRef Name,
|
|
744 StringRef ConfigurationMacros,
|
|
745 StringRef IncludePath,
|
|
746 StringRef ISysRoot) {
|
|
747 return DIModule::get(VMContext, getNonCompileUnitScope(Scope), Name,
|
|
748 ConfigurationMacros, IncludePath, ISysRoot);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
749 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
750
|
95
|
751 DILexicalBlockFile *DIBuilder::createLexicalBlockFile(DIScope *Scope,
|
|
752 DIFile *File,
|
|
753 unsigned Discriminator) {
|
|
754 return DILexicalBlockFile::get(VMContext, Scope, File, Discriminator);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
755 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
756
|
95
|
757 DILexicalBlock *DIBuilder::createLexicalBlock(DIScope *Scope, DIFile *File,
|
|
758 unsigned Line, unsigned Col) {
|
|
759 // Make these distinct, to avoid merging two lexical blocks on the same
|
|
760 // file/line/column.
|
|
761 return DILexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
|
|
762 File, Line, Col);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
763 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
764
|
83
|
765 static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {
|
|
766 assert(V && "no value passed to dbg intrinsic");
|
|
767 return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
|
|
768 }
|
|
769
|
95
|
770 static Instruction *withDebugLoc(Instruction *I, const DILocation *DL) {
|
|
771 I->setDebugLoc(const_cast<DILocation *>(DL));
|
|
772 return I;
|
|
773 }
|
|
774
|
|
775 Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
|
|
776 DIExpression *Expr, const DILocation *DL,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
777 Instruction *InsertBefore) {
|
95
|
778 assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
|
|
779 assert(DL && "Expected debug loc");
|
|
780 assert(DL->getScope()->getSubprogram() ==
|
|
781 VarInfo->getScope()->getSubprogram() &&
|
|
782 "Expected matching subprograms");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
783 if (!DeclareFn)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
784 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
785
|
83
|
786 trackIfUnresolved(VarInfo);
|
|
787 trackIfUnresolved(Expr);
|
|
788 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
|
|
789 MetadataAsValue::get(VMContext, VarInfo),
|
|
790 MetadataAsValue::get(VMContext, Expr)};
|
95
|
791 return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
792 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
793
|
95
|
794 Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
|
|
795 DIExpression *Expr, const DILocation *DL,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
796 BasicBlock *InsertAtEnd) {
|
95
|
797 assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
|
|
798 assert(DL && "Expected debug loc");
|
|
799 assert(DL->getScope()->getSubprogram() ==
|
|
800 VarInfo->getScope()->getSubprogram() &&
|
|
801 "Expected matching subprograms");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
802 if (!DeclareFn)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
803 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
804
|
83
|
805 trackIfUnresolved(VarInfo);
|
|
806 trackIfUnresolved(Expr);
|
|
807 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
|
|
808 MetadataAsValue::get(VMContext, VarInfo),
|
|
809 MetadataAsValue::get(VMContext, Expr)};
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
810
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
811 // If this block already has a terminator then insert this intrinsic
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
812 // before the terminator.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
813 if (TerminatorInst *T = InsertAtEnd->getTerminator())
|
95
|
814 return withDebugLoc(CallInst::Create(DeclareFn, Args, "", T), DL);
|
|
815 return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
816 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
817
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
818 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
95
|
819 DILocalVariable *VarInfo,
|
|
820 DIExpression *Expr,
|
|
821 const DILocation *DL,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
822 Instruction *InsertBefore) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
823 assert(V && "no value passed to dbg.value");
|
95
|
824 assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
|
|
825 assert(DL && "Expected debug loc");
|
|
826 assert(DL->getScope()->getSubprogram() ==
|
|
827 VarInfo->getScope()->getSubprogram() &&
|
|
828 "Expected matching subprograms");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
829 if (!ValueFn)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
830 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
831
|
83
|
832 trackIfUnresolved(VarInfo);
|
|
833 trackIfUnresolved(Expr);
|
|
834 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
|
|
835 ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
|
|
836 MetadataAsValue::get(VMContext, VarInfo),
|
|
837 MetadataAsValue::get(VMContext, Expr)};
|
95
|
838 return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
839 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
840
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
841 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
95
|
842 DILocalVariable *VarInfo,
|
|
843 DIExpression *Expr,
|
|
844 const DILocation *DL,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
845 BasicBlock *InsertAtEnd) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
846 assert(V && "no value passed to dbg.value");
|
95
|
847 assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
|
|
848 assert(DL && "Expected debug loc");
|
|
849 assert(DL->getScope()->getSubprogram() ==
|
|
850 VarInfo->getScope()->getSubprogram() &&
|
|
851 "Expected matching subprograms");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
852 if (!ValueFn)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
853 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
854
|
83
|
855 trackIfUnresolved(VarInfo);
|
|
856 trackIfUnresolved(Expr);
|
|
857 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
|
|
858 ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
|
|
859 MetadataAsValue::get(VMContext, VarInfo),
|
|
860 MetadataAsValue::get(VMContext, Expr)};
|
95
|
861
|
|
862 return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
863 }
|
83
|
864
|
95
|
865 void DIBuilder::replaceVTableHolder(DICompositeType *&T,
|
|
866 DICompositeType *VTableHolder) {
|
|
867 {
|
|
868 TypedTrackingMDRef<DICompositeType> N(T);
|
|
869 N->replaceVTableHolder(DITypeRef::get(VTableHolder));
|
|
870 T = N.get();
|
|
871 }
|
83
|
872
|
|
873 // If this didn't create a self-reference, just return.
|
|
874 if (T != VTableHolder)
|
|
875 return;
|
|
876
|
|
877 // Look for unresolved operands. T will drop RAUW support, orphaning any
|
|
878 // cycles underneath it.
|
|
879 if (T->isResolved())
|
|
880 for (const MDOperand &O : T->operands())
|
|
881 if (auto *N = dyn_cast_or_null<MDNode>(O))
|
|
882 trackIfUnresolved(N);
|
|
883 }
|
|
884
|
95
|
885 void DIBuilder::replaceArrays(DICompositeType *&T, DINodeArray Elements,
|
|
886 DINodeArray TParams) {
|
|
887 {
|
|
888 TypedTrackingMDRef<DICompositeType> N(T);
|
|
889 if (Elements)
|
|
890 N->replaceElements(Elements);
|
|
891 if (TParams)
|
|
892 N->replaceTemplateParams(DITemplateParameterArray(TParams));
|
|
893 T = N.get();
|
|
894 }
|
83
|
895
|
|
896 // If T isn't resolved, there's no problem.
|
|
897 if (!T->isResolved())
|
|
898 return;
|
|
899
|
95
|
900 // If T is resolved, it may be due to a self-reference cycle. Track the
|
83
|
901 // arrays explicitly if they're unresolved, or else the cycles will be
|
|
902 // orphaned.
|
|
903 if (Elements)
|
95
|
904 trackIfUnresolved(Elements.get());
|
83
|
905 if (TParams)
|
95
|
906 trackIfUnresolved(TParams.get());
|
83
|
907 }
|