llvm.org GIT mirror llvm / 1cacd28
DebugInfo: Remove DIArray and DITypeArray typedefs Remove the `DIArray` and `DITypeArray` typedefs, preferring the underlying types (`DebugNodeArray` and `MDTypeRefArray`, respectively). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235413 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
9 changed file(s) with 55 addition(s) and 62 deletion(s). Raw diff Collapse all Expand all
117117 DIBuilder *D = unwrap(Dref);
118118 return wrap(
119119 D->createSubroutineType(File ? unwrap(File) : nullptr,
120 DITypeArray(unwrap(ParameterTypes))));
120 MDTypeRefArray(unwrap(ParameterTypes))));
121121 }
122122
123123 LLVMMetadataRef LLVMDIBuilderCreateStructType(
130130 unwrap(Scope), Name, File ? unwrap(File) : nullptr, Line,
131131 SizeInBits, AlignInBits, Flags,
132132 DerivedFrom ? unwrap(DerivedFrom) : nullptr,
133 ElementTypes ? DIArray(unwrap(ElementTypes)) : nullptr));
133 ElementTypes ? DebugNodeArray(unwrap(ElementTypes)) : nullptr));
134134 }
135135
136136 LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType(
164164 DIBuilder *D = unwrap(Dref);
165165 return wrap(D->createArrayType(SizeInBits, AlignInBits,
166166 unwrap(ElementType),
167 DIArray(unwrap(Subscripts))));
167 DebugNodeArray(unwrap(Subscripts))));
168168 }
169169
170170 LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref,
189189 DIBuilder *D = unwrap(Dref);
190190 Metadata **DataValue = unwrap(Data);
191191 ArrayRef Elements(DataValue, Length);
192 DIArray A = D->getOrCreateArray(Elements);
192 DebugNodeArray A = D->getOrCreateArray(Elements);
193193 return wrap(A.get());
194194 }
195195
199199 DIBuilder *D = unwrap(Dref);
200200 Metadata **DataValue = unwrap(Data);
201201 ArrayRef Elements(DataValue, Length);
202 DITypeArray A = D->getOrCreateTypeArray(Elements);
202 MDTypeRefArray A = D->getOrCreateTypeArray(Elements);
203203 return wrap(A.get());
204204 }
205205
259259 /// for more info.
260260 /// @param TemplateParms Template type parameters.
261261 /// @param UniqueIdentifier A unique identifier for the class.
262 MDCompositeType *createClassType(MDScope *Scope, StringRef Name,
263 MDFile *File, unsigned LineNumber,
264 uint64_t SizeInBits, uint64_t AlignInBits,
265 uint64_t OffsetInBits, unsigned Flags,
266 MDType *DerivedFrom, DIArray Elements,
267 MDType *VTableHolder = nullptr,
268 MDNode *TemplateParms = nullptr,
269 StringRef UniqueIdentifier = "");
262 MDCompositeType *createClassType(
263 MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber,
264 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
265 unsigned Flags, MDType *DerivedFrom, DebugNodeArray Elements,
266 MDType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
267 StringRef UniqueIdentifier = "");
270268
271269 /// createStructType - Create debugging information entry for a struct.
272270 /// @param Scope Scope in which this struct is defined.
282280 MDCompositeType *createStructType(
283281 MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber,
284282 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
285 MDType *DerivedFrom, DIArray Elements, unsigned RunTimeLang = 0,
283 MDType *DerivedFrom, DebugNodeArray Elements, unsigned RunTimeLang = 0,
286284 MDType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
287285
288286 /// createUnionType - Create debugging information entry for an union.
299297 MDCompositeType *createUnionType(MDScope *Scope, StringRef Name,
300298 MDFile *File, unsigned LineNumber,
301299 uint64_t SizeInBits, uint64_t AlignInBits,
302 unsigned Flags, DIArray Elements,
300 unsigned Flags, DebugNodeArray Elements,
303301 unsigned RunTimeLang = 0,
304302 StringRef UniqueIdentifier = "");
305303
340338 MDTemplateValueParameter *createTemplateParameterPack(MDScope *Scope,
341339 StringRef Name,
342340 MDType *Ty,
343 DIArray Val);
341 DebugNodeArray Val);
344342
345343 /// createArrayType - Create debugging information entry for an array.
346344 /// @param Size Array size.
348346 /// @param Ty Element type.
349347 /// @param Subscripts Subscripts.
350348 MDCompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits,
351 MDType *Ty, DIArray Subscripts);
349 MDType *Ty, DebugNodeArray Subscripts);
352350
353351 /// createVectorType - Create debugging information entry for a vector type.
354352 /// @param Size Array size.
356354 /// @param Ty Element type.
357355 /// @param Subscripts Subscripts.
358356 MDCompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits,
359 MDType *Ty, DIArray Subscripts);
357 MDType *Ty, DebugNodeArray Subscripts);
360358
361359 /// createEnumerationType - Create debugging information entry for an
362360 /// enumeration.
371369 /// @param UniqueIdentifier A unique identifier for the enum.
372370 MDCompositeType *createEnumerationType(
373371 MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber,
374 uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements,
372 uint64_t SizeInBits, uint64_t AlignInBits, DebugNodeArray Elements,
375373 MDType *UnderlyingType, StringRef UniqueIdentifier = "");
376374
377375 /// createSubroutineType - Create subroutine type.
381379 /// @param Flags E.g.: LValueReference.
382380 /// These flags are used to emit dwarf attributes.
383381 MDSubroutineType *createSubroutineType(MDFile *File,
384 DITypeArray ParameterTypes,
382 MDTypeRefArray ParameterTypes,
385383 unsigned Flags = 0);
386384
387385 /// createArtificialType - Create a new MDType* with "artificial" flag set.
414412 /// for a subroutine type.
415413 MDBasicType *createUnspecifiedParameter();
416414
417 /// getOrCreateArray - Get a DIArray, create one if required.
418 DIArray getOrCreateArray(ArrayRef Elements);
419
420 /// getOrCreateTypeArray - Get a DITypeArray, create one if required.
421 DITypeArray getOrCreateTypeArray(ArrayRef Elements);
415 /// getOrCreateArray - Get a DebugNodeArray, create one if required.
416 DebugNodeArray getOrCreateArray(ArrayRef Elements);
417
418 /// getOrCreateTypeArray - Get a MDTypeRefArray, create one if required.
419 MDTypeRefArray getOrCreateTypeArray(ArrayRef Elements);
422420
423421 /// getOrCreateSubrange - Create a descriptor for a value range. This
424422 /// implicitly uniques the values returned.
663661 /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
664662 /// has a self-reference -- \a DIBuilder needs to track the array to
665663 /// resolve cycles.
666 void replaceArrays(MDCompositeType *&T, DIArray Elements,
667 DIArray TParems = DIArray());
664 void replaceArrays(MDCompositeType *&T, DebugNodeArray Elements,
665 DebugNodeArray TParems = DebugNodeArray());
668666
669667 /// \brief Replace a temporary node.
670668 ///
3434
3535 /// \brief Maps from type identifier to the actual MDNode.
3636 typedef DenseMap DITypeIdentifierMap;
37
38 typedef DebugNodeArray DIArray;
39 typedef MDTypeRefArray DITypeArray;
4037
4138 /// \brief Find subprogram that is enclosing this scope.
4239 MDSubprogram *getDISubprogram(const MDNode *Scope);
569569 DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
570570
571571 // If this is a variadic function, add an unspecified parameter.
572 DITypeArray FnArgs = Sub->getType()->getTypeArray();
572 MDTypeRefArray FnArgs = Sub->getType()->getTypeArray();
573573
574574 // Collect lexical scope children first.
575575 // ObjectPointer might be a local (non-argument) local variable if it's a
473473
474474 // Find the __forwarding field and the variable field in the __Block_byref
475475 // struct.
476 DIArray Fields = cast(TmpTy)->getElements();
476 DebugNodeArray Fields = cast(TmpTy)->getElements();
477477 const MDDerivedType *varField = nullptr;
478478 const MDDerivedType *forwardingField = nullptr;
479479
694694 GlobalValue::getRealLinkageName(LinkageName));
695695 }
696696
697 void DwarfUnit::addTemplateParams(DIE &Buffer, DIArray TParams) {
697 void DwarfUnit::addTemplateParams(DIE &Buffer, DebugNodeArray TParams) {
698698 // Add template parameters.
699699 for (const auto *Element : TParams) {
700700 if (auto *TTP = dyn_cast(Element))
899899 addSourceLine(Buffer, DTy);
900900 }
901901
902 void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) {
902 void DwarfUnit::constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args) {
903903 for (unsigned i = 1, N = Args.size(); i < N; ++i) {
904904 const MDType *Ty = resolve(Args[i]);
905905 if (!Ty) {
960960 case dwarf::DW_TAG_union_type:
961961 case dwarf::DW_TAG_class_type: {
962962 // Add elements to structure type.
963 DIArray Elements = CTy->getElements();
963 DebugNodeArray Elements = CTy->getElements();
964964 for (const auto *Element : Elements) {
965965 if (!Element)
966966 continue;
13151315 DIE *IdxTy = getIndexTyDie();
13161316
13171317 // Add subranges to array type.
1318 DIArray Elements = CTy->getElements();
1318 DebugNodeArray Elements = CTy->getElements();
13191319 for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
13201320 // FIXME: Should this really be such a loose cast?
13211321 if (auto *Element = dyn_cast_or_null(Elements[i]))
13251325 }
13261326
13271327 void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
1328 DIArray Elements = CTy->getElements();
1328 DebugNodeArray Elements = CTy->getElements();
13291329
13301330 // Add enumerators to enumeration type.
13311331 for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
267267 void addLinkageName(DIE &Die, StringRef LinkageName);
268268
269269 /// \brief Add template parameters in buffer.
270 void addTemplateParams(DIE &Buffer, DIArray TParams);
270 void addTemplateParams(DIE &Buffer, DebugNodeArray TParams);
271271
272272 /// \brief Add register operand.
273273 /// \returns false if the register does not exist, e.g., because it was never
315315 void constructContainingTypeDIEs();
316316
317317 /// \brief Construct function argument DIEs.
318 void constructSubprogramArguments(DIE &Buffer, DITypeArray Args);
318 void constructSubprogramArguments(DIE &Buffer, MDTypeRefArray Args);
319319
320320 /// Create a DIE with the given Tag, add the DIE to its parent, and
321321 /// call insertDIE if MD is not null.
9292 if (MDTuple *Temp = SP->getVariables().get()) {
9393 const auto &PV = PreservedVariables.lookup(SP);
9494 SmallVector Variables(PV.begin(), PV.end());
95 DIArray AV = getOrCreateArray(Variables);
95 DebugNodeArray AV = getOrCreateArray(Variables);
9696 TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
9797 }
9898 }
363363
364364 MDTemplateValueParameter *
365365 DIBuilder::createTemplateParameterPack(MDScope *Context, StringRef Name,
366 MDType *Ty, DIArray Val) {
366 MDType *Ty, DebugNodeArray Val) {
367367 return createTemplateValueParameterHelper(
368368 VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
369369 Val.get());
372372 MDCompositeType *DIBuilder::createClassType(
373373 MDScope *Context, StringRef Name, MDFile *File, unsigned LineNumber,
374374 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
375 unsigned Flags, MDType *DerivedFrom, DIArray Elements, MDType *VTableHolder,
376 MDNode *TemplateParams, StringRef UniqueIdentifier) {
375 unsigned Flags, MDType *DerivedFrom, DebugNodeArray Elements,
376 MDType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
377377 assert((!Context || isa(Context)) &&
378378 "createClassType should be called with a valid Context");
379379
392392 MDCompositeType *DIBuilder::createStructType(
393393 MDScope *Context, StringRef Name, MDFile *File, unsigned LineNumber,
394394 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
395 MDType *DerivedFrom, DIArray Elements, unsigned RunTimeLang,
395 MDType *DerivedFrom, DebugNodeArray Elements, unsigned RunTimeLang,
396396 MDType *VTableHolder, StringRef UniqueIdentifier) {
397397 auto *R = MDCompositeType::get(
398398 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
405405 return R;
406406 }
407407
408 MDCompositeType* DIBuilder::createUnionType(MDScope * Scope, StringRef Name,
409 MDFile* File, unsigned LineNumber,
410 uint64_t SizeInBits,
411 uint64_t AlignInBits, unsigned Flags,
412 DIArray Elements,
413 unsigned RunTimeLang,
414 StringRef UniqueIdentifier) {
408 MDCompositeType *DIBuilder::createUnionType(
409 MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber,
410 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
411 DebugNodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
415412 auto *R = MDCompositeType::get(
416413 VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
417414 MDScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits,
424421 }
425422
426423 MDSubroutineType *DIBuilder::createSubroutineType(MDFile *File,
427 DITypeArray ParameterTypes,
424 MDTypeRefArray ParameterTypes,
428425 unsigned Flags) {
429426 return MDSubroutineType::get(VMContext, Flags, ParameterTypes);
430427 }
431428
432429 MDCompositeType *DIBuilder::createEnumerationType(
433430 MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber,
434 uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements,
431 uint64_t SizeInBits, uint64_t AlignInBits, DebugNodeArray Elements,
435432 MDType *UnderlyingType, StringRef UniqueIdentifier) {
436433 auto *CTy = MDCompositeType::get(
437434 VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
446443 }
447444
448445 MDCompositeType *DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
449 MDType *Ty, DIArray Subscripts) {
446 MDType *Ty,
447 DebugNodeArray Subscripts) {
450448 auto *R = MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
451449 nullptr, 0, nullptr, MDTypeRef::get(Ty), Size,
452450 AlignInBits, 0, 0, Subscripts, 0, nullptr);
456454
457455 MDCompositeType *DIBuilder::createVectorType(uint64_t Size,
458456 uint64_t AlignInBits, MDType *Ty,
459 DIArray Subscripts) {
457 DebugNodeArray Subscripts) {
460458 auto *R =
461459 MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0,
462460 nullptr, MDTypeRef::get(Ty), Size, AlignInBits, 0,
527525 return RetTy;
528526 }
529527
530 DIArray DIBuilder::getOrCreateArray(ArrayRef Elements) {
528 DebugNodeArray DIBuilder::getOrCreateArray(ArrayRef Elements) {
531529 return MDTuple::get(VMContext, Elements);
532530 }
533531
534 DITypeArray DIBuilder::getOrCreateTypeArray(ArrayRef Elements) {
532 MDTypeRefArray DIBuilder::getOrCreateTypeArray(ArrayRef Elements) {
535533 SmallVector Elts;
536534 for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
537535 if (Elements[i] && isa(Elements[i]))
539537 else
540538 Elts.push_back(Elements[i]);
541539 }
542 return DITypeArray(MDNode::get(VMContext, Elts));
540 return MDTypeRefArray(MDNode::get(VMContext, Elts));
543541 }
544542
545543 MDSubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
837835 trackIfUnresolved(N);
838836 }
839837
840 void DIBuilder::replaceArrays(MDCompositeType* &T, DIArray Elements,
841 DIArray TParams) {
838 void DIBuilder::replaceArrays(MDCompositeType *&T, DebugNodeArray Elements,
839 DebugNodeArray TParams) {
842840 {
843841 TypedTrackingMDRef N(T);
844842 if (Elements)
7575 DITypeIdentifierMap Map;
7676 for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
7777 auto *CU = cast(CU_Nodes->getOperand(CUi));
78 DIArray Retain = CU->getRetainedTypes();
78 DebugNodeArray Retain = CU->getRetainedTypes();
7979 for (unsigned Ti = 0, Te = Retain.size(); Ti != Te; ++Ti) {
8080 if (!isa(Retain[Ti]))
8181 continue;
228228
229229 // Function DI
230230 auto *File = DBuilder.createFile("filename.c", "/file/dir/");
231 DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
231 MDTypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
232232 MDSubroutineType *FuncType =
233233 DBuilder.createSubroutineType(File, ParamTypes);
234234 auto *CU =