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,
67 FlagIndirectVariable = 1 << 13
70 const MDNode *DbgNode;
72 StringRef getStringField(unsigned Elt) const;
73 unsigned getUnsignedField(unsigned Elt) const {
74 return (unsigned)getUInt64Field(Elt);
76 uint64_t getUInt64Field(unsigned Elt) const;
77 int64_t getInt64Field(unsigned Elt) const;
78 DIDescriptor getDescriptorField(unsigned Elt) const;
80 template <typename DescTy>
81 DescTy getFieldAs(unsigned Elt) const {
82 return DescTy(getDescriptorField(Elt));
85 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
86 Constant *getConstantField(unsigned Elt) const;
87 Function *getFunctionField(unsigned Elt) const;
88 void replaceFunctionField(unsigned Elt, Function *F);
91 explicit DIDescriptor() : DbgNode(0) {}
92 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
93 explicit DIDescriptor(const DIFile F);
94 explicit DIDescriptor(const DISubprogram F);
95 explicit DIDescriptor(const DILexicalBlockFile F);
96 explicit DIDescriptor(const DILexicalBlock F);
97 explicit DIDescriptor(const DIVariable F);
98 explicit DIDescriptor(const DIType F);
102 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
103 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
105 // An explicit operator bool so that we can do testing of DI values
107 // FIXME: This operator bool isn't actually protecting anything at the
108 // moment due to the conversion operator above making DIDescriptor nodes
109 // implicitly convertable to pointer.
110 LLVM_EXPLICIT operator bool() const { return DbgNode != 0; }
112 bool operator==(DIDescriptor Other) const {
113 return DbgNode != Other.DbgNode;
115 bool operator!=(DIDescriptor Other) const {
116 return !operator==(Other);
119 unsigned getTag() const {
120 return getUnsignedField(0) & ~LLVMDebugVersionMask;
123 bool isDerivedType() const;
124 bool isCompositeType() const;
125 bool isBasicType() const;
126 bool isVariable() const;
127 bool isSubprogram() const;
128 bool isGlobalVariable() const;
129 bool isScope() const;
131 bool isCompileUnit() const;
132 bool isNameSpace() const;
133 bool isLexicalBlockFile() const;
134 bool isLexicalBlock() const;
135 bool isSubrange() const;
136 bool isEnumerator() const;
138 bool isGlobal() const;
139 bool isUnspecifiedParameter() const;
140 bool isTemplateTypeParameter() const;
141 bool isTemplateValueParameter() const;
142 bool isObjCProperty() const;
143 bool isImportedEntity() const;
145 /// print - print descriptor.
146 void print(raw_ostream &OS) const;
148 /// dump - print descriptor to dbgs() with a newline.
152 /// DISubrange - This is used to represent ranges, for array bounds.
153 class DISubrange : public DIDescriptor {
154 friend class DIDescriptor;
155 void printInternal(raw_ostream &OS) const;
157 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
159 int64_t getLo() const { return getInt64Field(1); }
160 int64_t getCount() const { return getInt64Field(2); }
164 /// DIArray - This descriptor holds an array of descriptors.
165 class DIArray : public DIDescriptor {
167 explicit DIArray(const MDNode *N = 0)
170 unsigned getNumElements() const;
171 DIDescriptor getElement(unsigned Idx) const {
172 return getDescriptorField(Idx);
176 /// DIScope - A base class for various scopes.
177 class DIScope : public DIDescriptor {
179 friend class DIDescriptor;
180 void printInternal(raw_ostream &OS) const;
182 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
184 /// Set the filename by allocating a new string MDNode for
185 /// it and attaching it to the underlying node.
186 void setFilename(StringRef Name, LLVMContext &Context);
187 StringRef getFilename() const;
188 StringRef getDirectory() const;
191 /// DIFile - This is a wrapper for a file.
192 class DIFile : public DIScope {
193 friend class DIDescriptor;
195 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
196 if (DbgNode && !isFile())
199 MDNode *getFileNode() const;
203 /// DICompileUnit - A wrapper for a compile unit.
204 class DICompileUnit : public DIScope {
205 friend class DIDescriptor;
206 void printInternal(raw_ostream &OS) const;
208 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
210 unsigned getLanguage() const { return getUnsignedField(2); }
211 StringRef getProducer() const { return getStringField(3); }
213 bool isOptimized() const { return getUnsignedField(4) != 0; }
214 StringRef getFlags() const { return getStringField(5); }
215 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
217 DIArray getEnumTypes() const;
218 DIArray getRetainedTypes() const;
219 DIArray getSubprograms() const;
220 DIArray getGlobalVariables() const;
221 DIArray getImportedEntities() const;
223 StringRef getSplitDebugFilename() const { return getStringField(12); }
225 /// Verify - Verify that a compile unit is well formed.
229 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
230 /// FIXME: it seems strange that this doesn't have either a reference to the
231 /// type/precision or a file/line pair for location info.
232 class DIEnumerator : public DIDescriptor {
233 friend class DIDescriptor;
234 void printInternal(raw_ostream &OS) const;
236 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
238 StringRef getName() const { return getStringField(1); }
239 int64_t getEnumValue() const { return getInt64Field(2); }
243 /// DIType - This is a wrapper for a type.
244 /// FIXME: Types should be factored much better so that CV qualifiers and
245 /// others do not require a huge and empty descriptor full of zeros.
246 class DIType : public DIScope {
248 friend class DIDescriptor;
249 void printInternal(raw_ostream &OS) const;
250 // This ctor is used when the Tag has already been validated by a derived
252 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
254 /// Verify - Verify that a type descriptor is well formed.
256 explicit DIType(const MDNode *N);
259 DIScope getContext() const { return getFieldAs<DIScope>(2); }
260 StringRef getName() const { return getStringField(3); }
261 unsigned getLineNumber() const { return getUnsignedField(4); }
262 uint64_t getSizeInBits() const { return getUInt64Field(5); }
263 uint64_t getAlignInBits() const { return getUInt64Field(6); }
264 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
265 // carry this is just plain insane.
266 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
267 unsigned getFlags() const { return getUnsignedField(8); }
268 bool isPrivate() const {
269 return (getFlags() & FlagPrivate) != 0;
271 bool isProtected() const {
272 return (getFlags() & FlagProtected) != 0;
274 bool isForwardDecl() const {
275 return (getFlags() & FlagFwdDecl) != 0;
277 // isAppleBlock - Return true if this is the Apple Blocks extension.
278 bool isAppleBlockExtension() const {
279 return (getFlags() & FlagAppleBlock) != 0;
281 bool isBlockByrefStruct() const {
282 return (getFlags() & FlagBlockByrefStruct) != 0;
284 bool isVirtual() const {
285 return (getFlags() & FlagVirtual) != 0;
287 bool isArtificial() const {
288 return (getFlags() & FlagArtificial) != 0;
290 bool isObjectPointer() const {
291 return (getFlags() & FlagObjectPointer) != 0;
293 bool isObjcClassComplete() const {
294 return (getFlags() & FlagObjcClassComplete) != 0;
296 bool isVector() const {
297 return (getFlags() & FlagVector) != 0;
299 bool isStaticMember() const {
300 return (getFlags() & FlagStaticMember) != 0;
302 bool isValid() const {
303 return DbgNode && isType();
306 /// isUnsignedDIType - Return true if type encoding is unsigned.
307 bool isUnsignedDIType();
309 /// replaceAllUsesWith - Replace all uses of debug info referenced by
311 void replaceAllUsesWith(DIDescriptor &D);
312 void replaceAllUsesWith(MDNode *D);
315 /// DIBasicType - A basic type, like 'int' or 'float'.
316 class DIBasicType : public DIType {
318 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
320 unsigned getEncoding() const { return getUnsignedField(9); }
322 /// Verify - Verify that a basic type descriptor is well formed.
326 /// DIDerivedType - A simple derived type, like a const qualified type,
327 /// a typedef, a pointer or reference, et cetera. Or, a data member of
328 /// a class/struct/union.
329 class DIDerivedType : public DIType {
330 friend class DIDescriptor;
331 void printInternal(raw_ostream &OS) const;
333 explicit DIDerivedType(const MDNode *N, bool, bool)
334 : DIType(N, true, true) {}
336 explicit DIDerivedType(const MDNode *N = 0)
337 : DIType(N, true, true) {}
339 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
341 /// getOriginalTypeSize - If this type is derived from a base type then
342 /// return base type size.
343 uint64_t getOriginalTypeSize() const;
345 /// getObjCProperty - Return property node, if this ivar is
346 /// associated with one.
347 MDNode *getObjCProperty() const;
349 DIType getClassType() const {
350 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
351 return getFieldAs<DIType>(10);
354 Constant *getConstant() const {
355 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
356 return getConstantField(10);
359 /// Verify - Verify that a derived type descriptor is well formed.
363 /// DICompositeType - This descriptor holds a type that can refer to multiple
364 /// other types, like a function or struct.
365 /// DICompositeType is derived from DIDerivedType because some
366 /// composite types (such as enums) can be derived from basic types
367 // FIXME: Make this derive from DIType directly & just store the
368 // base type in a single DIType field.
369 class DICompositeType : public DIDerivedType {
370 friend class DIDescriptor;
371 void printInternal(raw_ostream &OS) const;
373 explicit DICompositeType(const MDNode *N = 0)
374 : DIDerivedType(N, true, true) {
375 if (N && !isCompositeType())
379 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
380 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
381 unsigned getRunTimeLang() const { return getUnsignedField(11); }
382 DICompositeType getContainingType() const {
383 return getFieldAs<DICompositeType>(12);
385 void setContainingType(DICompositeType ContainingType);
386 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
388 /// Verify - Verify that a composite type descriptor is well formed.
392 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
393 class DITemplateTypeParameter : public DIDescriptor {
395 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
397 DIScope getContext() const { return getFieldAs<DIScope>(1); }
398 StringRef getName() const { return getStringField(2); }
399 DIType getType() const { return getFieldAs<DIType>(3); }
400 StringRef getFilename() const {
401 return getFieldAs<DIFile>(4).getFilename();
403 StringRef getDirectory() const {
404 return getFieldAs<DIFile>(4).getDirectory();
406 unsigned getLineNumber() const { return getUnsignedField(5); }
407 unsigned getColumnNumber() const { return getUnsignedField(6); }
411 /// DITemplateValueParameter - This is a wrapper for template value parameter.
412 class DITemplateValueParameter : public DIDescriptor {
414 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
416 DIScope getContext() const { return getFieldAs<DIScope>(1); }
417 StringRef getName() const { return getStringField(2); }
418 DIType getType() const { return getFieldAs<DIType>(3); }
419 Value *getValue() const;
420 StringRef getFilename() const {
421 return getFieldAs<DIFile>(5).getFilename();
423 StringRef getDirectory() const {
424 return getFieldAs<DIFile>(5).getDirectory();
426 unsigned getLineNumber() const { return getUnsignedField(6); }
427 unsigned getColumnNumber() const { return getUnsignedField(7); }
431 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
432 class DISubprogram : public DIScope {
433 friend class DIDescriptor;
434 void printInternal(raw_ostream &OS) const;
436 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
438 DIScope getContext() const { return getFieldAs<DIScope>(2); }
439 StringRef getName() const { return getStringField(3); }
440 StringRef getDisplayName() const { return getStringField(4); }
441 StringRef getLinkageName() const { return getStringField(5); }
442 unsigned getLineNumber() const { return getUnsignedField(6); }
443 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
445 /// isLocalToUnit - Return true if this subprogram is local to the current
446 /// compile unit, like 'static' in C.
447 unsigned isLocalToUnit() const { return getUnsignedField(8); }
448 unsigned isDefinition() const { return getUnsignedField(9); }
450 unsigned getVirtuality() const { return getUnsignedField(10); }
451 unsigned getVirtualIndex() const { return getUnsignedField(11); }
453 DICompositeType getContainingType() const {
454 return getFieldAs<DICompositeType>(12);
457 unsigned getFlags() const {
458 return getUnsignedField(13);
461 unsigned isArtificial() const {
462 return (getUnsignedField(13) & FlagArtificial) != 0;
464 /// isPrivate - Return true if this subprogram has "private"
465 /// access specifier.
466 bool isPrivate() const {
467 return (getUnsignedField(13) & FlagPrivate) != 0;
469 /// isProtected - Return true if this subprogram has "protected"
470 /// access specifier.
471 bool isProtected() const {
472 return (getUnsignedField(13) & FlagProtected) != 0;
474 /// isExplicit - Return true if this subprogram is marked as explicit.
475 bool isExplicit() const {
476 return (getUnsignedField(13) & FlagExplicit) != 0;
478 /// isPrototyped - Return true if this subprogram is prototyped.
479 bool isPrototyped() const {
480 return (getUnsignedField(13) & FlagPrototyped) != 0;
483 unsigned isOptimized() const;
485 /// Verify - Verify that a subprogram descriptor is well formed.
488 /// describes - Return true if this subprogram provides debugging
489 /// information for the function F.
490 bool describes(const Function *F);
492 Function *getFunction() const { return getFunctionField(15); }
493 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
494 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
495 DISubprogram getFunctionDeclaration() const {
496 return getFieldAs<DISubprogram>(17);
498 MDNode *getVariablesNodes() const;
499 DIArray getVariables() const;
501 /// getScopeLineNumber - Get the beginning of the scope of the
502 /// function, not necessarily where the name of the program
504 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
507 /// DIGlobalVariable - This is a wrapper for a global variable.
508 class DIGlobalVariable : public DIDescriptor {
509 friend class DIDescriptor;
510 void printInternal(raw_ostream &OS) const;
512 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
514 DIScope getContext() const { return getFieldAs<DIScope>(2); }
515 StringRef getName() const { return getStringField(3); }
516 StringRef getDisplayName() const { return getStringField(4); }
517 StringRef getLinkageName() const { return getStringField(5); }
518 StringRef getFilename() const {
519 return getFieldAs<DIFile>(6).getFilename();
521 StringRef getDirectory() const {
522 return getFieldAs<DIFile>(6).getDirectory();
526 unsigned getLineNumber() const { return getUnsignedField(7); }
527 DIType getType() const { return getFieldAs<DIType>(8); }
528 unsigned isLocalToUnit() const { return getUnsignedField(9); }
529 unsigned isDefinition() const { return getUnsignedField(10); }
531 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
532 Constant *getConstant() const { return getConstantField(11); }
533 DIDerivedType getStaticDataMemberDeclaration() const {
534 return getFieldAs<DIDerivedType>(12);
537 /// Verify - Verify that a global variable descriptor is well formed.
541 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
543 class DIVariable : public DIDescriptor {
544 friend class DIDescriptor;
545 void printInternal(raw_ostream &OS) const;
547 explicit DIVariable(const MDNode *N = 0)
550 DIScope getContext() const { return getFieldAs<DIScope>(1); }
551 StringRef getName() const { return getStringField(2); }
552 DIFile getFile() const { return getFieldAs<DIFile>(3); }
553 unsigned getLineNumber() const {
554 return (getUnsignedField(4) << 8) >> 8;
556 unsigned getArgNumber() const {
557 unsigned L = getUnsignedField(4);
560 DIType getType() const { return getFieldAs<DIType>(5); }
562 /// isArtificial - Return true if this variable is marked as "artificial".
563 bool isArtificial() const {
564 return (getUnsignedField(6) & FlagArtificial) != 0;
567 bool isObjectPointer() const {
568 return (getUnsignedField(6) & FlagObjectPointer) != 0;
571 /// \brief Return true if this variable is represented as a pointer.
572 bool isIndirect() const {
573 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
576 /// getInlinedAt - If this variable is inlined then return inline location.
577 MDNode *getInlinedAt() const;
579 /// Verify - Verify that a variable descriptor is well formed.
582 /// HasComplexAddr - Return true if the variable has a complex address.
583 bool hasComplexAddress() const {
584 return getNumAddrElements() > 0;
587 unsigned getNumAddrElements() const;
589 uint64_t getAddrElement(unsigned Idx) const {
590 return getUInt64Field(Idx+8);
593 /// isBlockByrefVariable - Return true if the variable was declared as
594 /// a "__block" variable (Apple Blocks).
595 bool isBlockByrefVariable() const {
596 return getType().isBlockByrefStruct();
599 /// isInlinedFnArgument - Return true if this variable provides debugging
600 /// information for an inlined function arguments.
601 bool isInlinedFnArgument(const Function *CurFn);
603 void printExtendedName(raw_ostream &OS) const;
606 /// DILexicalBlock - This is a wrapper for a lexical block.
607 class DILexicalBlock : public DIScope {
609 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
610 DIScope getContext() const { return getFieldAs<DIScope>(2); }
611 unsigned getLineNumber() const { return getUnsignedField(3); }
612 unsigned getColumnNumber() const { return getUnsignedField(4); }
616 /// DILexicalBlockFile - This is a wrapper for a lexical block with
617 /// a filename change.
618 class DILexicalBlockFile : public DIScope {
620 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
621 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
622 unsigned getLineNumber() const { return getScope().getLineNumber(); }
623 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
624 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
628 /// DINameSpace - A wrapper for a C++ style name space.
629 class DINameSpace : public DIScope {
630 friend class DIDescriptor;
631 void printInternal(raw_ostream &OS) const;
633 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
634 DIScope getContext() const { return getFieldAs<DIScope>(2); }
635 StringRef getName() const { return getStringField(3); }
636 unsigned getLineNumber() const { return getUnsignedField(4); }
640 /// DILocation - This object holds location information. This object
641 /// is not associated with any DWARF tag.
642 class DILocation : public DIDescriptor {
644 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
646 unsigned getLineNumber() const { return getUnsignedField(0); }
647 unsigned getColumnNumber() const { return getUnsignedField(1); }
648 DIScope getScope() const { return getFieldAs<DIScope>(2); }
649 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
650 StringRef getFilename() const { return getScope().getFilename(); }
651 StringRef getDirectory() const { return getScope().getDirectory(); }
655 class DIObjCProperty : public DIDescriptor {
656 friend class DIDescriptor;
657 void printInternal(raw_ostream &OS) const;
659 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
661 StringRef getObjCPropertyName() const { return getStringField(1); }
662 DIFile getFile() const { return getFieldAs<DIFile>(2); }
663 unsigned getLineNumber() const { return getUnsignedField(3); }
665 StringRef getObjCPropertyGetterName() const {
666 return getStringField(4);
668 StringRef getObjCPropertySetterName() const {
669 return getStringField(5);
671 bool isReadOnlyObjCProperty() const {
672 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
674 bool isReadWriteObjCProperty() const {
675 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
677 bool isAssignObjCProperty() const {
678 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
680 bool isRetainObjCProperty() const {
681 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
683 bool isCopyObjCProperty() const {
684 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
686 bool isNonAtomicObjCProperty() const {
687 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
690 DIType getType() const { return getFieldAs<DIType>(7); }
692 /// Verify - Verify that a derived type descriptor is well formed.
696 /// \brief An imported module (C++ using directive or similar).
697 class DIImportedEntity : public DIDescriptor {
698 friend class DIDescriptor;
699 void printInternal(raw_ostream &OS) const;
701 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
702 DIScope getContext() const { return getFieldAs<DIScope>(1); }
703 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
704 unsigned getLineNumber() const { return getUnsignedField(3); }
705 StringRef getName() const { return getStringField(4); }
709 /// getDISubprogram - Find subprogram that is enclosing this scope.
710 DISubprogram getDISubprogram(const MDNode *Scope);
712 /// getDICompositeType - Find underlying composite type.
713 DICompositeType getDICompositeType(DIType T);
715 /// isSubprogramContext - Return true if Context is either a subprogram
716 /// or another context nested inside a subprogram.
717 bool isSubprogramContext(const MDNode *Context);
719 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
720 /// to hold function specific information.
721 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
723 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
724 /// suitable to hold function specific information.
725 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
727 /// createInlinedVariable - Create a new inlined variable based on current
729 /// @param DV Current Variable.
730 /// @param InlinedScope Location at current variable is inlined.
731 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
732 LLVMContext &VMContext);
734 /// cleanseInlinedVariable - Remove inlined scope from the variable.
735 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
737 class DebugInfoFinder {
739 /// processModule - Process entire module and collect debug info
741 void processModule(const Module &M);
744 /// processType - Process DIType.
745 void processType(DIType DT);
747 /// processLexicalBlock - Process DILexicalBlock.
748 void processLexicalBlock(DILexicalBlock LB);
750 /// processSubprogram - Process DISubprogram.
751 void processSubprogram(DISubprogram SP);
753 /// processDeclare - Process DbgDeclareInst.
754 void processDeclare(const DbgDeclareInst *DDI);
756 /// processLocation - Process DILocation.
757 void processLocation(DILocation Loc);
759 /// addCompileUnit - Add compile unit into CUs.
760 bool addCompileUnit(DICompileUnit CU);
762 /// addGlobalVariable - Add global variable into GVs.
763 bool addGlobalVariable(DIGlobalVariable DIG);
765 // addSubprogram - Add subprogram into SPs.
766 bool addSubprogram(DISubprogram SP);
768 /// addType - Add type into Tys.
769 bool addType(DIType DT);
772 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
773 iterator compile_unit_begin() const { return CUs.begin(); }
774 iterator compile_unit_end() const { return CUs.end(); }
775 iterator subprogram_begin() const { return SPs.begin(); }
776 iterator subprogram_end() const { return SPs.end(); }
777 iterator global_variable_begin() const { return GVs.begin(); }
778 iterator global_variable_end() const { return GVs.end(); }
779 iterator type_begin() const { return TYs.begin(); }
780 iterator type_end() const { return TYs.end(); }
782 unsigned compile_unit_count() const { return CUs.size(); }
783 unsigned global_variable_count() const { return GVs.size(); }
784 unsigned subprogram_count() const { return SPs.size(); }
785 unsigned type_count() const { return TYs.size(); }
788 SmallVector<MDNode *, 8> CUs; // Compile Units
789 SmallVector<MDNode *, 8> SPs; // Subprograms
790 SmallVector<MDNode *, 8> GVs; // Global Variables;
791 SmallVector<MDNode *, 8> TYs; // Types
792 SmallPtrSet<MDNode *, 64> NodesSeen;
794 } // end namespace llvm