1 //===--- llvm/Analysis/DebugInfo.h - Debug Information Helpers --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a bunch of datatypes that are useful for creating and
11 // walking debug info in LLVM IR form. They essentially provide wrappers around
12 // the information in the global variables that's needed when constructing the
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_DEBUGINFO_H
18 #define LLVM_DEBUGINFO_H
20 #include "llvm/ADT/SmallPtrSet.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/Dwarf.h"
43 class DILexicalBlockFile;
48 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
49 /// This should not be stored in a container, because the underlying MDNode
50 /// may change in certain situations.
55 FlagProtected = 1 << 1,
57 FlagAppleBlock = 1 << 3,
58 FlagBlockByrefStruct = 1 << 4,
60 FlagArtificial = 1 << 6,
61 FlagExplicit = 1 << 7,
62 FlagPrototyped = 1 << 8,
63 FlagObjcClassComplete = 1 << 9,
64 FlagObjectPointer = 1 << 10,
66 FlagStaticMember = 1 << 12
69 const MDNode *DbgNode;
71 StringRef getStringField(unsigned Elt) const;
72 unsigned getUnsignedField(unsigned Elt) const {
73 return (unsigned)getUInt64Field(Elt);
75 uint64_t getUInt64Field(unsigned Elt) const;
76 int64_t getInt64Field(unsigned Elt) const;
77 DIDescriptor getDescriptorField(unsigned Elt) const;
79 template <typename DescTy>
80 DescTy getFieldAs(unsigned Elt) const {
81 return DescTy(getDescriptorField(Elt));
84 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
85 Constant *getConstantField(unsigned Elt) const;
86 Function *getFunctionField(unsigned Elt) const;
87 void replaceFunctionField(unsigned Elt, Function *F);
90 explicit DIDescriptor() : DbgNode(0) {}
91 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
92 explicit DIDescriptor(const DIFile F);
93 explicit DIDescriptor(const DISubprogram F);
94 explicit DIDescriptor(const DILexicalBlockFile F);
95 explicit DIDescriptor(const DILexicalBlock F);
96 explicit DIDescriptor(const DIVariable F);
97 explicit DIDescriptor(const DIType F);
101 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
102 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
104 unsigned getTag() const {
105 return getUnsignedField(0) & ~LLVMDebugVersionMask;
108 bool isDerivedType() const;
109 bool isCompositeType() const;
110 bool isBasicType() const;
111 bool isVariable() const;
112 bool isSubprogram() const;
113 bool isGlobalVariable() const;
114 bool isScope() const;
116 bool isCompileUnit() const;
117 bool isNameSpace() const;
118 bool isLexicalBlockFile() const;
119 bool isLexicalBlock() const;
120 bool isSubrange() const;
121 bool isEnumerator() const;
123 bool isGlobal() const;
124 bool isUnspecifiedParameter() const;
125 bool isTemplateTypeParameter() const;
126 bool isTemplateValueParameter() const;
127 bool isObjCProperty() const;
129 /// print - print descriptor.
130 void print(raw_ostream &OS) const;
132 /// dump - print descriptor to dbgs() with a newline.
136 /// DISubrange - This is used to represent ranges, for array bounds.
137 class DISubrange : public DIDescriptor {
138 friend class DIDescriptor;
139 void printInternal(raw_ostream &OS) const;
141 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
143 int64_t getLo() const { return getInt64Field(1); }
144 int64_t getCount() const { return getInt64Field(2); }
148 /// DIArray - This descriptor holds an array of descriptors.
149 class DIArray : public DIDescriptor {
151 explicit DIArray(const MDNode *N = 0)
154 unsigned getNumElements() const;
155 DIDescriptor getElement(unsigned Idx) const {
156 return getDescriptorField(Idx);
160 /// DIScope - A base class for various scopes.
161 class DIScope : public DIDescriptor {
163 friend class DIDescriptor;
164 void printInternal(raw_ostream &OS) const;
166 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
168 StringRef getFilename() const;
169 StringRef getDirectory() const;
172 /// DICompileUnit - A wrapper for a compile unit.
173 class DICompileUnit : public DIScope {
174 friend class DIDescriptor;
175 void printInternal(raw_ostream &OS) const;
177 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
179 unsigned getLanguage() const { return getUnsignedField(2); }
180 StringRef getFilename() const { return getStringField(3); }
181 StringRef getDirectory() const { return getStringField(4); }
182 StringRef getProducer() const { return getStringField(5); }
184 /// isMain - Each input file is encoded as a separate compile unit in LLVM
185 /// debugging information output. However, many target specific tool chains
186 /// prefer to encode only one compile unit in an object file. In this
187 /// situation, the LLVM code generator will include debugging information
188 /// entities in the compile unit that is marked as main compile unit. The
189 /// code generator accepts maximum one main compile unit per module. If a
190 /// module does not contain any main compile unit then the code generator
191 /// will emit multiple compile units in the output object file.
192 // TODO: This can be removed when we remove the legacy debug information.
193 bool isMain() const { return getUnsignedField(6) != 0; }
194 bool isOptimized() const { return getUnsignedField(7) != 0; }
195 StringRef getFlags() const { return getStringField(8); }
196 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
198 DIArray getEnumTypes() const;
199 DIArray getRetainedTypes() const;
200 DIArray getSubprograms() const;
201 DIArray getGlobalVariables() const;
203 StringRef getSplitDebugFilename() const { return getStringField(14); }
205 /// Verify - Verify that a compile unit is well formed.
209 /// DIFile - This is a wrapper for a file.
210 class DIFile : public DIScope {
211 friend class DIDescriptor;
212 void printInternal(raw_ostream &OS) const {} // FIXME: Output something?
214 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
215 if (DbgNode && !isFile())
218 StringRef getFilename() const { return getStringField(1); }
219 StringRef getDirectory() const { return getStringField(2); }
223 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
224 /// FIXME: it seems strange that this doesn't have either a reference to the
225 /// type/precision or a file/line pair for location info.
226 class DIEnumerator : public DIDescriptor {
227 friend class DIDescriptor;
228 void printInternal(raw_ostream &OS) const;
230 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
232 StringRef getName() const { return getStringField(1); }
233 uint64_t getEnumValue() const { return getUInt64Field(2); }
237 /// DIType - This is a wrapper for a type.
238 /// FIXME: Types should be factored much better so that CV qualifiers and
239 /// others do not require a huge and empty descriptor full of zeros.
240 class DIType : public DIScope {
242 friend class DIDescriptor;
243 void printInternal(raw_ostream &OS) const;
244 // This ctor is used when the Tag has already been validated by a derived
246 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
248 /// Verify - Verify that a type descriptor is well formed.
250 explicit DIType(const MDNode *N);
253 DIScope getContext() const { return getFieldAs<DIScope>(1); }
254 StringRef getName() const { return getStringField(2); }
255 DIFile getFile() const { return getFieldAs<DIFile>(3); }
256 unsigned getLineNumber() const { return getUnsignedField(4); }
257 uint64_t getSizeInBits() const { return getUInt64Field(5); }
258 uint64_t getAlignInBits() const { return getUInt64Field(6); }
259 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
260 // carry this is just plain insane.
261 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
262 unsigned getFlags() const { return getUnsignedField(8); }
263 bool isPrivate() const {
264 return (getFlags() & FlagPrivate) != 0;
266 bool isProtected() const {
267 return (getFlags() & FlagProtected) != 0;
269 bool isForwardDecl() const {
270 return (getFlags() & FlagFwdDecl) != 0;
272 // isAppleBlock - Return true if this is the Apple Blocks extension.
273 bool isAppleBlockExtension() const {
274 return (getFlags() & FlagAppleBlock) != 0;
276 bool isBlockByrefStruct() const {
277 return (getFlags() & FlagBlockByrefStruct) != 0;
279 bool isVirtual() const {
280 return (getFlags() & FlagVirtual) != 0;
282 bool isArtificial() const {
283 return (getFlags() & FlagArtificial) != 0;
285 bool isObjectPointer() const {
286 return (getFlags() & FlagObjectPointer) != 0;
288 bool isObjcClassComplete() const {
289 return (getFlags() & FlagObjcClassComplete) != 0;
291 bool isVector() const {
292 return (getFlags() & FlagVector) != 0;
294 bool isStaticMember() const {
295 return (getFlags() & FlagStaticMember) != 0;
297 bool isValid() const {
298 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
300 StringRef getDirectory() const {
301 return getFieldAs<DIFile>(3).getDirectory();
303 StringRef getFilename() const {
304 return getFieldAs<DIFile>(3).getFilename();
307 /// isUnsignedDIType - Return true if type encoding is unsigned.
308 bool isUnsignedDIType();
310 /// replaceAllUsesWith - Replace all uses of debug info referenced by
312 void replaceAllUsesWith(DIDescriptor &D);
313 void replaceAllUsesWith(MDNode *D);
316 /// DIBasicType - A basic type, like 'int' or 'float'.
317 class DIBasicType : public DIType {
319 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
321 unsigned getEncoding() const { return getUnsignedField(9); }
323 /// Verify - Verify that a basic type descriptor is well formed.
327 /// DIDerivedType - A simple derived type, like a const qualified type,
328 /// a typedef, a pointer or reference, et cetera. Or, a data member of
329 /// a class/struct/union.
330 class DIDerivedType : public DIType {
331 friend class DIDescriptor;
332 void printInternal(raw_ostream &OS) const;
334 explicit DIDerivedType(const MDNode *N, bool, bool)
335 : DIType(N, true, true) {}
337 explicit DIDerivedType(const MDNode *N = 0)
338 : DIType(N, true, true) {}
340 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
342 /// getOriginalTypeSize - If this type is derived from a base type then
343 /// return base type size.
344 uint64_t getOriginalTypeSize() const;
346 /// getObjCProperty - Return property node, if this ivar is
347 /// associated with one.
348 MDNode *getObjCProperty() const;
350 DIType getClassType() const {
351 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
352 return getFieldAs<DIType>(10);
355 Constant *getConstant() const {
356 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
357 return getConstantField(10);
360 /// Verify - Verify that a derived type descriptor is well formed.
364 /// DICompositeType - This descriptor holds a type that can refer to multiple
365 /// other types, like a function or struct.
366 /// FIXME: Why is this a DIDerivedType??
367 class DICompositeType : public DIDerivedType {
368 friend class DIDescriptor;
369 void printInternal(raw_ostream &OS) const;
371 explicit DICompositeType(const MDNode *N = 0)
372 : DIDerivedType(N, true, true) {
373 if (N && !isCompositeType())
377 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
378 unsigned getRunTimeLang() const { return getUnsignedField(11); }
379 DICompositeType getContainingType() const {
380 return getFieldAs<DICompositeType>(12);
382 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
384 /// Verify - Verify that a composite type descriptor is well formed.
388 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
389 class DITemplateTypeParameter : public DIDescriptor {
391 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
393 DIScope getContext() const { return getFieldAs<DIScope>(1); }
394 StringRef getName() const { return getStringField(2); }
395 DIType getType() const { return getFieldAs<DIType>(3); }
396 StringRef getFilename() const {
397 return getFieldAs<DIFile>(4).getFilename();
399 StringRef getDirectory() const {
400 return getFieldAs<DIFile>(4).getDirectory();
402 unsigned getLineNumber() const { return getUnsignedField(5); }
403 unsigned getColumnNumber() const { return getUnsignedField(6); }
407 /// DITemplateValueParameter - This is a wrapper for template value parameter.
408 class DITemplateValueParameter : public DIDescriptor {
410 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
412 DIScope getContext() const { return getFieldAs<DIScope>(1); }
413 StringRef getName() const { return getStringField(2); }
414 DIType getType() const { return getFieldAs<DIType>(3); }
415 uint64_t getValue() const { return getUInt64Field(4); }
416 StringRef getFilename() const {
417 return getFieldAs<DIFile>(5).getFilename();
419 StringRef getDirectory() const {
420 return getFieldAs<DIFile>(5).getDirectory();
422 unsigned getLineNumber() const { return getUnsignedField(6); }
423 unsigned getColumnNumber() const { return getUnsignedField(7); }
427 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
428 class DISubprogram : public DIScope {
429 friend class DIDescriptor;
430 void printInternal(raw_ostream &OS) const;
432 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
434 DIScope getContext() const { return getFieldAs<DIScope>(2); }
435 StringRef getName() const { return getStringField(3); }
436 StringRef getDisplayName() const { return getStringField(4); }
437 StringRef getLinkageName() const { return getStringField(5); }
438 unsigned getLineNumber() const { return getUnsignedField(7); }
439 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
441 /// getReturnTypeName - Subprogram return types are encoded either as
442 /// DIType or as DICompositeType.
443 StringRef getReturnTypeName() const {
444 DICompositeType DCT(getFieldAs<DICompositeType>(8));
446 DIArray A = DCT.getTypeArray();
447 DIType T(A.getElement(0));
450 DIType T(getFieldAs<DIType>(8));
454 /// isLocalToUnit - Return true if this subprogram is local to the current
455 /// compile unit, like 'static' in C.
456 unsigned isLocalToUnit() const { return getUnsignedField(9); }
457 unsigned isDefinition() const { return getUnsignedField(10); }
459 unsigned getVirtuality() const { return getUnsignedField(11); }
460 unsigned getVirtualIndex() const { return getUnsignedField(12); }
462 DICompositeType getContainingType() const {
463 return getFieldAs<DICompositeType>(13);
466 unsigned getFlags() const {
467 return getUnsignedField(14);
470 unsigned isArtificial() const {
471 return (getUnsignedField(14) & FlagArtificial) != 0;
473 /// isPrivate - Return true if this subprogram has "private"
474 /// access specifier.
475 bool isPrivate() const {
476 return (getUnsignedField(14) & FlagPrivate) != 0;
478 /// isProtected - Return true if this subprogram has "protected"
479 /// access specifier.
480 bool isProtected() const {
481 return (getUnsignedField(14) & FlagProtected) != 0;
483 /// isExplicit - Return true if this subprogram is marked as explicit.
484 bool isExplicit() const {
485 return (getUnsignedField(14) & FlagExplicit) != 0;
487 /// isPrototyped - Return true if this subprogram is prototyped.
488 bool isPrototyped() const {
489 return (getUnsignedField(14) & FlagPrototyped) != 0;
492 unsigned isOptimized() const;
494 StringRef getFilename() const {
495 return getFieldAs<DIFile>(6).getFilename();
498 StringRef getDirectory() const {
499 return getFieldAs<DIFile>(6).getDirectory();
502 DIFile getFile() const {
503 return getFieldAs<DIFile>(6);
506 /// getScopeLineNumber - Get the beginning of the scope of the
507 /// function, not necessarily where the name of the program
509 unsigned getScopeLineNumber() const { return getUnsignedField(20); }
511 /// Verify - Verify that a subprogram descriptor is well formed.
514 /// describes - Return true if this subprogram provides debugging
515 /// information for the function F.
516 bool describes(const Function *F);
518 Function *getFunction() const { return getFunctionField(16); }
519 void replaceFunction(Function *F) { replaceFunctionField(16, F); }
520 DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
521 DISubprogram getFunctionDeclaration() const {
522 return getFieldAs<DISubprogram>(18);
524 MDNode *getVariablesNodes() const;
525 DIArray getVariables() const;
528 /// DIGlobalVariable - This is a wrapper for a global variable.
529 class DIGlobalVariable : public DIDescriptor {
530 friend class DIDescriptor;
531 void printInternal(raw_ostream &OS) const;
533 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
535 DIScope getContext() const { return getFieldAs<DIScope>(2); }
536 StringRef getName() const { return getStringField(3); }
537 StringRef getDisplayName() const { return getStringField(4); }
538 StringRef getLinkageName() const { return getStringField(5); }
539 StringRef getFilename() const {
540 return getFieldAs<DIFile>(6).getFilename();
542 StringRef getDirectory() const {
543 return getFieldAs<DIFile>(6).getDirectory();
547 unsigned getLineNumber() const { return getUnsignedField(7); }
548 DIType getType() const { return getFieldAs<DIType>(8); }
549 unsigned isLocalToUnit() const { return getUnsignedField(9); }
550 unsigned isDefinition() const { return getUnsignedField(10); }
552 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
553 Constant *getConstant() const { return getConstantField(11); }
554 DIDerivedType getStaticDataMemberDeclaration() const {
555 return getFieldAs<DIDerivedType>(12);
558 /// Verify - Verify that a global variable descriptor is well formed.
562 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
564 class DIVariable : public DIDescriptor {
565 friend class DIDescriptor;
566 void printInternal(raw_ostream &OS) const;
568 explicit DIVariable(const MDNode *N = 0)
571 DIScope getContext() const { return getFieldAs<DIScope>(1); }
572 StringRef getName() const { return getStringField(2); }
573 DIFile getFile() const { return getFieldAs<DIFile>(3); }
574 unsigned getLineNumber() const {
575 return (getUnsignedField(4) << 8) >> 8;
577 unsigned getArgNumber() const {
578 unsigned L = getUnsignedField(4);
581 DIType getType() const { return getFieldAs<DIType>(5); }
583 /// isArtificial - Return true if this variable is marked as "artificial".
584 bool isArtificial() const {
585 return (getUnsignedField(6) & FlagArtificial) != 0;
588 bool isObjectPointer() const {
589 return (getUnsignedField(6) & FlagObjectPointer) != 0;
592 /// getInlinedAt - If this variable is inlined then return inline location.
593 MDNode *getInlinedAt() const;
595 /// Verify - Verify that a variable descriptor is well formed.
598 /// HasComplexAddr - Return true if the variable has a complex address.
599 bool hasComplexAddress() const {
600 return getNumAddrElements() > 0;
603 unsigned getNumAddrElements() const;
605 uint64_t getAddrElement(unsigned Idx) const {
606 return getUInt64Field(Idx+8);
609 /// isBlockByrefVariable - Return true if the variable was declared as
610 /// a "__block" variable (Apple Blocks).
611 bool isBlockByrefVariable() const {
612 return getType().isBlockByrefStruct();
615 /// isInlinedFnArgument - Return true if this variable provides debugging
616 /// information for an inlined function arguments.
617 bool isInlinedFnArgument(const Function *CurFn);
619 void printExtendedName(raw_ostream &OS) const;
622 /// DILexicalBlock - This is a wrapper for a lexical block.
623 class DILexicalBlock : public DIScope {
625 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
626 DIScope getContext() const { return getFieldAs<DIScope>(1); }
627 unsigned getLineNumber() const { return getUnsignedField(2); }
628 unsigned getColumnNumber() const { return getUnsignedField(3); }
629 StringRef getDirectory() const {
630 StringRef dir = getFieldAs<DIFile>(4).getDirectory();
631 return !dir.empty() ? dir : getContext().getDirectory();
633 StringRef getFilename() const {
634 StringRef filename = getFieldAs<DIFile>(4).getFilename();
635 return !filename.empty() ? filename : getContext().getFilename();
640 /// DILexicalBlockFile - This is a wrapper for a lexical block with
641 /// a filename change.
642 class DILexicalBlockFile : public DIScope {
644 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
645 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
646 unsigned getLineNumber() const { return getScope().getLineNumber(); }
647 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
648 StringRef getDirectory() const {
649 StringRef dir = getFieldAs<DIFile>(2).getDirectory();
650 return !dir.empty() ? dir : getContext().getDirectory();
652 StringRef getFilename() const {
653 StringRef filename = getFieldAs<DIFile>(2).getFilename();
654 assert(!filename.empty() && "Why'd you create this then?");
657 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(1); }
661 /// DINameSpace - A wrapper for a C++ style name space.
662 class DINameSpace : public DIScope {
664 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
665 DIScope getContext() const { return getFieldAs<DIScope>(1); }
666 StringRef getName() const { return getStringField(2); }
667 StringRef getDirectory() const {
668 return getFieldAs<DIFile>(3).getDirectory();
670 StringRef getFilename() const {
671 return getFieldAs<DIFile>(3).getFilename();
673 unsigned getLineNumber() const { return getUnsignedField(4); }
677 /// DILocation - This object holds location information. This object
678 /// is not associated with any DWARF tag.
679 class DILocation : public DIDescriptor {
681 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
683 unsigned getLineNumber() const { return getUnsignedField(0); }
684 unsigned getColumnNumber() const { return getUnsignedField(1); }
685 DIScope getScope() const { return getFieldAs<DIScope>(2); }
686 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
687 StringRef getFilename() const { return getScope().getFilename(); }
688 StringRef getDirectory() const { return getScope().getDirectory(); }
692 class DIObjCProperty : public DIDescriptor {
693 friend class DIDescriptor;
694 void printInternal(raw_ostream &OS) const;
696 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
698 StringRef getObjCPropertyName() const { return getStringField(1); }
699 DIFile getFile() const { return getFieldAs<DIFile>(2); }
700 unsigned getLineNumber() const { return getUnsignedField(3); }
702 StringRef getObjCPropertyGetterName() const {
703 return getStringField(4);
705 StringRef getObjCPropertySetterName() const {
706 return getStringField(5);
708 bool isReadOnlyObjCProperty() {
709 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
711 bool isReadWriteObjCProperty() {
712 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
714 bool isAssignObjCProperty() {
715 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
717 bool isRetainObjCProperty() {
718 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
720 bool isCopyObjCProperty() {
721 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
723 bool isNonAtomicObjCProperty() {
724 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
727 DIType getType() const { return getFieldAs<DIType>(7); }
729 /// Verify - Verify that a derived type descriptor is well formed.
733 /// getDISubprogram - Find subprogram that is enclosing this scope.
734 DISubprogram getDISubprogram(const MDNode *Scope);
736 /// getDICompositeType - Find underlying composite type.
737 DICompositeType getDICompositeType(DIType T);
739 /// isSubprogramContext - Return true if Context is either a subprogram
740 /// or another context nested inside a subprogram.
741 bool isSubprogramContext(const MDNode *Context);
743 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
744 /// to hold function specific information.
745 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
747 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
748 /// suitable to hold function specific information.
749 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
751 /// createInlinedVariable - Create a new inlined variable based on current
753 /// @param DV Current Variable.
754 /// @param InlinedScope Location at current variable is inlined.
755 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
756 LLVMContext &VMContext);
758 /// cleanseInlinedVariable - Remove inlined scope from the variable.
759 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
761 class DebugInfoFinder {
763 /// processModule - Process entire module and collect debug info
765 void processModule(const Module &M);
768 /// processType - Process DIType.
769 void processType(DIType DT);
771 /// processLexicalBlock - Process DILexicalBlock.
772 void processLexicalBlock(DILexicalBlock LB);
774 /// processSubprogram - Process DISubprogram.
775 void processSubprogram(DISubprogram SP);
777 /// processDeclare - Process DbgDeclareInst.
778 void processDeclare(const DbgDeclareInst *DDI);
780 /// processLocation - Process DILocation.
781 void processLocation(DILocation Loc);
783 /// addCompileUnit - Add compile unit into CUs.
784 bool addCompileUnit(DICompileUnit CU);
786 /// addGlobalVariable - Add global variable into GVs.
787 bool addGlobalVariable(DIGlobalVariable DIG);
789 // addSubprogram - Add subprogram into SPs.
790 bool addSubprogram(DISubprogram SP);
792 /// addType - Add type into Tys.
793 bool addType(DIType DT);
796 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
797 iterator compile_unit_begin() const { return CUs.begin(); }
798 iterator compile_unit_end() const { return CUs.end(); }
799 iterator subprogram_begin() const { return SPs.begin(); }
800 iterator subprogram_end() const { return SPs.end(); }
801 iterator global_variable_begin() const { return GVs.begin(); }
802 iterator global_variable_end() const { return GVs.end(); }
803 iterator type_begin() const { return TYs.begin(); }
804 iterator type_end() const { return TYs.end(); }
806 unsigned compile_unit_count() const { return CUs.size(); }
807 unsigned global_variable_count() const { return GVs.size(); }
808 unsigned subprogram_count() const { return SPs.size(); }
809 unsigned type_count() const { return TYs.size(); }
812 SmallVector<MDNode *, 8> CUs; // Compile Units
813 SmallVector<MDNode *, 8> SPs; // Subprograms
814 SmallVector<MDNode *, 8> GVs; // Global Variables;
815 SmallVector<MDNode *, 8> TYs; // Types
816 SmallPtrSet<MDNode *, 64> NodesSeen;
818 } // end namespace llvm