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;
128 bool isImportedEntity() const;
130 /// print - print descriptor.
131 void print(raw_ostream &OS) const;
133 /// dump - print descriptor to dbgs() with a newline.
137 /// DISubrange - This is used to represent ranges, for array bounds.
138 class DISubrange : public DIDescriptor {
139 friend class DIDescriptor;
140 void printInternal(raw_ostream &OS) const;
142 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
144 int64_t getLo() const { return getInt64Field(1); }
145 int64_t getCount() const { return getInt64Field(2); }
149 /// DIArray - This descriptor holds an array of descriptors.
150 class DIArray : public DIDescriptor {
152 explicit DIArray(const MDNode *N = 0)
155 unsigned getNumElements() const;
156 DIDescriptor getElement(unsigned Idx) const {
157 return getDescriptorField(Idx);
161 /// DIScope - A base class for various scopes.
162 class DIScope : public DIDescriptor {
164 friend class DIDescriptor;
165 void printInternal(raw_ostream &OS) const;
167 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
169 /// Set the filename by allocating a new string MDNode for
170 /// it and attaching it to the underlying node.
171 void setFilename(StringRef Name, LLVMContext &Context);
172 StringRef getFilename() const;
173 StringRef getDirectory() const;
176 /// DIFile - This is a wrapper for a file.
177 class DIFile : public DIScope {
178 friend class DIDescriptor;
180 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
181 if (DbgNode && !isFile())
184 MDNode *getFileNode() const;
188 /// DICompileUnit - A wrapper for a compile unit.
189 class DICompileUnit : public DIScope {
190 friend class DIDescriptor;
191 void printInternal(raw_ostream &OS) const;
193 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
195 unsigned getLanguage() const { return getUnsignedField(2); }
196 StringRef getProducer() const { return getStringField(3); }
198 bool isOptimized() const { return getUnsignedField(4) != 0; }
199 StringRef getFlags() const { return getStringField(5); }
200 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
202 DIArray getEnumTypes() const;
203 DIArray getRetainedTypes() const;
204 DIArray getSubprograms() const;
205 DIArray getGlobalVariables() const;
206 DIArray getImportedEntities() const;
208 StringRef getSplitDebugFilename() const { return getStringField(12); }
210 /// Verify - Verify that a compile unit is well formed.
214 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
215 /// FIXME: it seems strange that this doesn't have either a reference to the
216 /// type/precision or a file/line pair for location info.
217 class DIEnumerator : public DIDescriptor {
218 friend class DIDescriptor;
219 void printInternal(raw_ostream &OS) const;
221 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
223 StringRef getName() const { return getStringField(1); }
224 uint64_t getEnumValue() const { return getUInt64Field(2); }
228 /// DIType - This is a wrapper for a type.
229 /// FIXME: Types should be factored much better so that CV qualifiers and
230 /// others do not require a huge and empty descriptor full of zeros.
231 class DIType : public DIScope {
233 friend class DIDescriptor;
234 void printInternal(raw_ostream &OS) const;
235 // This ctor is used when the Tag has already been validated by a derived
237 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
239 /// Verify - Verify that a type descriptor is well formed.
241 explicit DIType(const MDNode *N);
244 DIScope getContext() const { return getFieldAs<DIScope>(2); }
245 StringRef getName() const { return getStringField(3); }
246 unsigned getLineNumber() const { return getUnsignedField(4); }
247 uint64_t getSizeInBits() const { return getUInt64Field(5); }
248 uint64_t getAlignInBits() const { return getUInt64Field(6); }
249 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
250 // carry this is just plain insane.
251 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
252 unsigned getFlags() const { return getUnsignedField(8); }
253 bool isPrivate() const {
254 return (getFlags() & FlagPrivate) != 0;
256 bool isProtected() const {
257 return (getFlags() & FlagProtected) != 0;
259 bool isForwardDecl() const {
260 return (getFlags() & FlagFwdDecl) != 0;
262 // isAppleBlock - Return true if this is the Apple Blocks extension.
263 bool isAppleBlockExtension() const {
264 return (getFlags() & FlagAppleBlock) != 0;
266 bool isBlockByrefStruct() const {
267 return (getFlags() & FlagBlockByrefStruct) != 0;
269 bool isVirtual() const {
270 return (getFlags() & FlagVirtual) != 0;
272 bool isArtificial() const {
273 return (getFlags() & FlagArtificial) != 0;
275 bool isObjectPointer() const {
276 return (getFlags() & FlagObjectPointer) != 0;
278 bool isObjcClassComplete() const {
279 return (getFlags() & FlagObjcClassComplete) != 0;
281 bool isVector() const {
282 return (getFlags() & FlagVector) != 0;
284 bool isStaticMember() const {
285 return (getFlags() & FlagStaticMember) != 0;
287 bool isValid() const {
288 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
291 /// isUnsignedDIType - Return true if type encoding is unsigned.
292 bool isUnsignedDIType();
294 /// replaceAllUsesWith - Replace all uses of debug info referenced by
296 void replaceAllUsesWith(DIDescriptor &D);
297 void replaceAllUsesWith(MDNode *D);
300 /// DIBasicType - A basic type, like 'int' or 'float'.
301 class DIBasicType : public DIType {
303 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
305 unsigned getEncoding() const { return getUnsignedField(9); }
307 /// Verify - Verify that a basic type descriptor is well formed.
311 /// DIDerivedType - A simple derived type, like a const qualified type,
312 /// a typedef, a pointer or reference, et cetera. Or, a data member of
313 /// a class/struct/union.
314 class DIDerivedType : public DIType {
315 friend class DIDescriptor;
316 void printInternal(raw_ostream &OS) const;
318 explicit DIDerivedType(const MDNode *N, bool, bool)
319 : DIType(N, true, true) {}
321 explicit DIDerivedType(const MDNode *N = 0)
322 : DIType(N, true, true) {}
324 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
326 /// getOriginalTypeSize - If this type is derived from a base type then
327 /// return base type size.
328 uint64_t getOriginalTypeSize() const;
330 /// getObjCProperty - Return property node, if this ivar is
331 /// associated with one.
332 MDNode *getObjCProperty() const;
334 DIType getClassType() const {
335 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
336 return getFieldAs<DIType>(10);
339 Constant *getConstant() const {
340 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
341 return getConstantField(10);
344 /// Verify - Verify that a derived type descriptor is well formed.
348 /// DICompositeType - This descriptor holds a type that can refer to multiple
349 /// other types, like a function or struct.
350 /// DICompositeType is derived from DIDerivedType because some
351 /// composite types (such as enums) can be derived from basic types
352 // FIXME: Make this derive from DIType directly & just store the
353 // base type in a single DIType field.
354 class DICompositeType : public DIDerivedType {
355 friend class DIDescriptor;
356 void printInternal(raw_ostream &OS) const;
358 explicit DICompositeType(const MDNode *N = 0)
359 : DIDerivedType(N, true, true) {
360 if (N && !isCompositeType())
364 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
365 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
366 unsigned getRunTimeLang() const { return getUnsignedField(11); }
367 DICompositeType getContainingType() const {
368 return getFieldAs<DICompositeType>(12);
370 void setContainingType(DICompositeType ContainingType);
371 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
373 /// Verify - Verify that a composite type descriptor is well formed.
377 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
378 class DITemplateTypeParameter : public DIDescriptor {
380 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
382 DIScope getContext() const { return getFieldAs<DIScope>(1); }
383 StringRef getName() const { return getStringField(2); }
384 DIType getType() const { return getFieldAs<DIType>(3); }
385 StringRef getFilename() const {
386 return getFieldAs<DIFile>(4).getFilename();
388 StringRef getDirectory() const {
389 return getFieldAs<DIFile>(4).getDirectory();
391 unsigned getLineNumber() const { return getUnsignedField(5); }
392 unsigned getColumnNumber() const { return getUnsignedField(6); }
396 /// DITemplateValueParameter - This is a wrapper for template value parameter.
397 class DITemplateValueParameter : public DIDescriptor {
399 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
401 DIScope getContext() const { return getFieldAs<DIScope>(1); }
402 StringRef getName() const { return getStringField(2); }
403 DIType getType() const { return getFieldAs<DIType>(3); }
404 uint64_t getValue() const { return getUInt64Field(4); }
405 StringRef getFilename() const {
406 return getFieldAs<DIFile>(5).getFilename();
408 StringRef getDirectory() const {
409 return getFieldAs<DIFile>(5).getDirectory();
411 unsigned getLineNumber() const { return getUnsignedField(6); }
412 unsigned getColumnNumber() const { return getUnsignedField(7); }
416 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
417 class DISubprogram : public DIScope {
418 friend class DIDescriptor;
419 void printInternal(raw_ostream &OS) const;
421 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
423 DIScope getContext() const { return getFieldAs<DIScope>(2); }
424 StringRef getName() const { return getStringField(3); }
425 StringRef getDisplayName() const { return getStringField(4); }
426 StringRef getLinkageName() const { return getStringField(5); }
427 unsigned getLineNumber() const { return getUnsignedField(6); }
428 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
430 /// getReturnTypeName - Subprogram return types are encoded either as
431 /// DIType or as DICompositeType.
432 StringRef getReturnTypeName() const {
433 DICompositeType DCT(getFieldAs<DICompositeType>(7));
435 DIArray A = DCT.getTypeArray();
436 DIType T(A.getElement(0));
439 DIType T(getFieldAs<DIType>(7));
443 /// isLocalToUnit - Return true if this subprogram is local to the current
444 /// compile unit, like 'static' in C.
445 unsigned isLocalToUnit() const { return getUnsignedField(8); }
446 unsigned isDefinition() const { return getUnsignedField(9); }
448 unsigned getVirtuality() const { return getUnsignedField(10); }
449 unsigned getVirtualIndex() const { return getUnsignedField(11); }
451 DICompositeType getContainingType() const {
452 return getFieldAs<DICompositeType>(12);
455 unsigned getFlags() const {
456 return getUnsignedField(13);
459 unsigned isArtificial() const {
460 return (getUnsignedField(13) & FlagArtificial) != 0;
462 /// isPrivate - Return true if this subprogram has "private"
463 /// access specifier.
464 bool isPrivate() const {
465 return (getUnsignedField(13) & FlagPrivate) != 0;
467 /// isProtected - Return true if this subprogram has "protected"
468 /// access specifier.
469 bool isProtected() const {
470 return (getUnsignedField(13) & FlagProtected) != 0;
472 /// isExplicit - Return true if this subprogram is marked as explicit.
473 bool isExplicit() const {
474 return (getUnsignedField(13) & FlagExplicit) != 0;
476 /// isPrototyped - Return true if this subprogram is prototyped.
477 bool isPrototyped() const {
478 return (getUnsignedField(13) & FlagPrototyped) != 0;
481 unsigned isOptimized() const;
483 /// getScopeLineNumber - Get the beginning of the scope of the
484 /// function, not necessarily where the name of the program
486 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
488 /// Verify - Verify that a subprogram descriptor is well formed.
491 /// describes - Return true if this subprogram provides debugging
492 /// information for the function F.
493 bool describes(const Function *F);
495 Function *getFunction() const { return getFunctionField(15); }
496 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
497 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
498 DISubprogram getFunctionDeclaration() const {
499 return getFieldAs<DISubprogram>(17);
501 MDNode *getVariablesNodes() const;
502 DIArray getVariables() const;
505 /// DIGlobalVariable - This is a wrapper for a global variable.
506 class DIGlobalVariable : public DIDescriptor {
507 friend class DIDescriptor;
508 void printInternal(raw_ostream &OS) const;
510 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
512 DIScope getContext() const { return getFieldAs<DIScope>(2); }
513 StringRef getName() const { return getStringField(3); }
514 StringRef getDisplayName() const { return getStringField(4); }
515 StringRef getLinkageName() const { return getStringField(5); }
516 StringRef getFilename() const {
517 return getFieldAs<DIFile>(6).getFilename();
519 StringRef getDirectory() const {
520 return getFieldAs<DIFile>(6).getDirectory();
524 unsigned getLineNumber() const { return getUnsignedField(7); }
525 DIType getType() const { return getFieldAs<DIType>(8); }
526 unsigned isLocalToUnit() const { return getUnsignedField(9); }
527 unsigned isDefinition() const { return getUnsignedField(10); }
529 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
530 Constant *getConstant() const { return getConstantField(11); }
531 DIDerivedType getStaticDataMemberDeclaration() const {
532 return getFieldAs<DIDerivedType>(12);
535 /// Verify - Verify that a global variable descriptor is well formed.
539 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
541 class DIVariable : public DIDescriptor {
542 friend class DIDescriptor;
543 void printInternal(raw_ostream &OS) const;
545 explicit DIVariable(const MDNode *N = 0)
548 DIScope getContext() const { return getFieldAs<DIScope>(1); }
549 StringRef getName() const { return getStringField(2); }
550 DIFile getFile() const { return getFieldAs<DIFile>(3); }
551 unsigned getLineNumber() const {
552 return (getUnsignedField(4) << 8) >> 8;
554 unsigned getArgNumber() const {
555 unsigned L = getUnsignedField(4);
558 DIType getType() const { return getFieldAs<DIType>(5); }
560 /// isArtificial - Return true if this variable is marked as "artificial".
561 bool isArtificial() const {
562 return (getUnsignedField(6) & FlagArtificial) != 0;
565 bool isObjectPointer() const {
566 return (getUnsignedField(6) & FlagObjectPointer) != 0;
569 /// getInlinedAt - If this variable is inlined then return inline location.
570 MDNode *getInlinedAt() const;
572 /// Verify - Verify that a variable descriptor is well formed.
575 /// HasComplexAddr - Return true if the variable has a complex address.
576 bool hasComplexAddress() const {
577 return getNumAddrElements() > 0;
580 unsigned getNumAddrElements() const;
582 uint64_t getAddrElement(unsigned Idx) const {
583 return getUInt64Field(Idx+8);
586 /// isBlockByrefVariable - Return true if the variable was declared as
587 /// a "__block" variable (Apple Blocks).
588 bool isBlockByrefVariable() const {
589 return getType().isBlockByrefStruct();
592 /// isInlinedFnArgument - Return true if this variable provides debugging
593 /// information for an inlined function arguments.
594 bool isInlinedFnArgument(const Function *CurFn);
596 void printExtendedName(raw_ostream &OS) const;
599 /// DILexicalBlock - This is a wrapper for a lexical block.
600 class DILexicalBlock : public DIScope {
602 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
603 DIScope getContext() const { return getFieldAs<DIScope>(2); }
604 unsigned getLineNumber() const { return getUnsignedField(3); }
605 unsigned getColumnNumber() const { return getUnsignedField(4); }
609 /// DILexicalBlockFile - This is a wrapper for a lexical block with
610 /// a filename change.
611 class DILexicalBlockFile : public DIScope {
613 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
614 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
615 unsigned getLineNumber() const { return getScope().getLineNumber(); }
616 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
617 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
621 /// DINameSpace - A wrapper for a C++ style name space.
622 class DINameSpace : public DIScope {
623 friend class DIDescriptor;
624 void printInternal(raw_ostream &OS) const;
626 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
627 DIScope getContext() const { return getFieldAs<DIScope>(2); }
628 StringRef getName() const { return getStringField(3); }
629 unsigned getLineNumber() const { return getUnsignedField(4); }
633 /// DILocation - This object holds location information. This object
634 /// is not associated with any DWARF tag.
635 class DILocation : public DIDescriptor {
637 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
639 unsigned getLineNumber() const { return getUnsignedField(0); }
640 unsigned getColumnNumber() const { return getUnsignedField(1); }
641 DIScope getScope() const { return getFieldAs<DIScope>(2); }
642 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
643 StringRef getFilename() const { return getScope().getFilename(); }
644 StringRef getDirectory() const { return getScope().getDirectory(); }
648 class DIObjCProperty : public DIDescriptor {
649 friend class DIDescriptor;
650 void printInternal(raw_ostream &OS) const;
652 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
654 StringRef getObjCPropertyName() const { return getStringField(1); }
655 DIFile getFile() const { return getFieldAs<DIFile>(2); }
656 unsigned getLineNumber() const { return getUnsignedField(3); }
658 StringRef getObjCPropertyGetterName() const {
659 return getStringField(4);
661 StringRef getObjCPropertySetterName() const {
662 return getStringField(5);
664 bool isReadOnlyObjCProperty() {
665 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
667 bool isReadWriteObjCProperty() {
668 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
670 bool isAssignObjCProperty() {
671 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
673 bool isRetainObjCProperty() {
674 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
676 bool isCopyObjCProperty() {
677 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
679 bool isNonAtomicObjCProperty() {
680 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
683 DIType getType() const { return getFieldAs<DIType>(7); }
685 /// Verify - Verify that a derived type descriptor is well formed.
689 /// \brief An imported module (C++ using directive or similar).
690 class DIImportedEntity : public DIDescriptor {
691 friend class DIDescriptor;
692 void printInternal(raw_ostream &OS) const;
694 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
695 DIScope getContext() const { return getFieldAs<DIScope>(1); }
696 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
697 unsigned getLineNumber() const { return getUnsignedField(3); }
701 /// getDISubprogram - Find subprogram that is enclosing this scope.
702 DISubprogram getDISubprogram(const MDNode *Scope);
704 /// getDICompositeType - Find underlying composite type.
705 DICompositeType getDICompositeType(DIType T);
707 /// isSubprogramContext - Return true if Context is either a subprogram
708 /// or another context nested inside a subprogram.
709 bool isSubprogramContext(const MDNode *Context);
711 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
712 /// to hold function specific information.
713 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
715 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
716 /// suitable to hold function specific information.
717 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
719 /// createInlinedVariable - Create a new inlined variable based on current
721 /// @param DV Current Variable.
722 /// @param InlinedScope Location at current variable is inlined.
723 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
724 LLVMContext &VMContext);
726 /// cleanseInlinedVariable - Remove inlined scope from the variable.
727 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
729 class DebugInfoFinder {
731 /// processModule - Process entire module and collect debug info
733 void processModule(const Module &M);
736 /// processType - Process DIType.
737 void processType(DIType DT);
739 /// processLexicalBlock - Process DILexicalBlock.
740 void processLexicalBlock(DILexicalBlock LB);
742 /// processSubprogram - Process DISubprogram.
743 void processSubprogram(DISubprogram SP);
745 /// processDeclare - Process DbgDeclareInst.
746 void processDeclare(const DbgDeclareInst *DDI);
748 /// processLocation - Process DILocation.
749 void processLocation(DILocation Loc);
751 /// addCompileUnit - Add compile unit into CUs.
752 bool addCompileUnit(DICompileUnit CU);
754 /// addGlobalVariable - Add global variable into GVs.
755 bool addGlobalVariable(DIGlobalVariable DIG);
757 // addSubprogram - Add subprogram into SPs.
758 bool addSubprogram(DISubprogram SP);
760 /// addType - Add type into Tys.
761 bool addType(DIType DT);
764 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
765 iterator compile_unit_begin() const { return CUs.begin(); }
766 iterator compile_unit_end() const { return CUs.end(); }
767 iterator subprogram_begin() const { return SPs.begin(); }
768 iterator subprogram_end() const { return SPs.end(); }
769 iterator global_variable_begin() const { return GVs.begin(); }
770 iterator global_variable_end() const { return GVs.end(); }
771 iterator type_begin() const { return TYs.begin(); }
772 iterator type_end() const { return TYs.end(); }
774 unsigned compile_unit_count() const { return CUs.size(); }
775 unsigned global_variable_count() const { return GVs.size(); }
776 unsigned subprogram_count() const { return SPs.size(); }
777 unsigned type_count() const { return TYs.size(); }
780 SmallVector<MDNode *, 8> CUs; // Compile Units
781 SmallVector<MDNode *, 8> SPs; // Subprograms
782 SmallVector<MDNode *, 8> GVs; // Global Variables;
783 SmallVector<MDNode *, 8> TYs; // Types
784 SmallPtrSet<MDNode *, 64> NodesSeen;
786 } // end namespace llvm