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 unsigned getTag() const {
106 return getUnsignedField(0) & ~LLVMDebugVersionMask;
109 bool isDerivedType() const;
110 bool isCompositeType() const;
111 bool isBasicType() const;
112 bool isVariable() const;
113 bool isSubprogram() const;
114 bool isGlobalVariable() const;
115 bool isScope() const;
117 bool isCompileUnit() const;
118 bool isNameSpace() const;
119 bool isLexicalBlockFile() const;
120 bool isLexicalBlock() const;
121 bool isSubrange() const;
122 bool isEnumerator() const;
124 bool isGlobal() const;
125 bool isUnspecifiedParameter() const;
126 bool isTemplateTypeParameter() const;
127 bool isTemplateValueParameter() const;
128 bool isObjCProperty() const;
129 bool isImportedEntity() const;
131 /// print - print descriptor.
132 void print(raw_ostream &OS) const;
134 /// dump - print descriptor to dbgs() with a newline.
138 /// DISubrange - This is used to represent ranges, for array bounds.
139 class DISubrange : public DIDescriptor {
140 friend class DIDescriptor;
141 void printInternal(raw_ostream &OS) const;
143 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
145 int64_t getLo() const { return getInt64Field(1); }
146 int64_t getCount() const { return getInt64Field(2); }
150 /// DIArray - This descriptor holds an array of descriptors.
151 class DIArray : public DIDescriptor {
153 explicit DIArray(const MDNode *N = 0)
156 unsigned getNumElements() const;
157 DIDescriptor getElement(unsigned Idx) const {
158 return getDescriptorField(Idx);
162 /// DIScope - A base class for various scopes.
163 class DIScope : public DIDescriptor {
165 friend class DIDescriptor;
166 void printInternal(raw_ostream &OS) const;
168 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
170 /// Set the filename by allocating a new string MDNode for
171 /// it and attaching it to the underlying node.
172 void setFilename(StringRef Name, LLVMContext &Context);
173 StringRef getFilename() const;
174 StringRef getDirectory() const;
177 /// DIFile - This is a wrapper for a file.
178 class DIFile : public DIScope {
179 friend class DIDescriptor;
181 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
182 if (DbgNode && !isFile())
185 MDNode *getFileNode() const;
189 /// DICompileUnit - A wrapper for a compile unit.
190 class DICompileUnit : public DIScope {
191 friend class DIDescriptor;
192 void printInternal(raw_ostream &OS) const;
194 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
196 unsigned getLanguage() const { return getUnsignedField(2); }
197 StringRef getProducer() const { return getStringField(3); }
199 bool isOptimized() const { return getUnsignedField(4) != 0; }
200 StringRef getFlags() const { return getStringField(5); }
201 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
203 DIArray getEnumTypes() const;
204 DIArray getRetainedTypes() const;
205 DIArray getSubprograms() const;
206 DIArray getGlobalVariables() const;
207 DIArray getImportedEntities() const;
209 StringRef getSplitDebugFilename() const { return getStringField(12); }
211 /// Verify - Verify that a compile unit is well formed.
215 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
216 /// FIXME: it seems strange that this doesn't have either a reference to the
217 /// type/precision or a file/line pair for location info.
218 class DIEnumerator : public DIDescriptor {
219 friend class DIDescriptor;
220 void printInternal(raw_ostream &OS) const;
222 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
224 StringRef getName() const { return getStringField(1); }
225 uint64_t getEnumValue() const { return getUInt64Field(2); }
229 /// DIType - This is a wrapper for a type.
230 /// FIXME: Types should be factored much better so that CV qualifiers and
231 /// others do not require a huge and empty descriptor full of zeros.
232 class DIType : public DIScope {
234 friend class DIDescriptor;
235 void printInternal(raw_ostream &OS) const;
236 // This ctor is used when the Tag has already been validated by a derived
238 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
240 /// Verify - Verify that a type descriptor is well formed.
242 explicit DIType(const MDNode *N);
245 DIScope getContext() const { return getFieldAs<DIScope>(2); }
246 StringRef getName() const { return getStringField(3); }
247 unsigned getLineNumber() const { return getUnsignedField(4); }
248 uint64_t getSizeInBits() const { return getUInt64Field(5); }
249 uint64_t getAlignInBits() const { return getUInt64Field(6); }
250 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
251 // carry this is just plain insane.
252 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
253 unsigned getFlags() const { return getUnsignedField(8); }
254 bool isPrivate() const {
255 return (getFlags() & FlagPrivate) != 0;
257 bool isProtected() const {
258 return (getFlags() & FlagProtected) != 0;
260 bool isForwardDecl() const {
261 return (getFlags() & FlagFwdDecl) != 0;
263 // isAppleBlock - Return true if this is the Apple Blocks extension.
264 bool isAppleBlockExtension() const {
265 return (getFlags() & FlagAppleBlock) != 0;
267 bool isBlockByrefStruct() const {
268 return (getFlags() & FlagBlockByrefStruct) != 0;
270 bool isVirtual() const {
271 return (getFlags() & FlagVirtual) != 0;
273 bool isArtificial() const {
274 return (getFlags() & FlagArtificial) != 0;
276 bool isObjectPointer() const {
277 return (getFlags() & FlagObjectPointer) != 0;
279 bool isObjcClassComplete() const {
280 return (getFlags() & FlagObjcClassComplete) != 0;
282 bool isVector() const {
283 return (getFlags() & FlagVector) != 0;
285 bool isStaticMember() const {
286 return (getFlags() & FlagStaticMember) != 0;
288 bool isValid() const {
289 return DbgNode && isType();
292 /// isUnsignedDIType - Return true if type encoding is unsigned.
293 bool isUnsignedDIType();
295 /// replaceAllUsesWith - Replace all uses of debug info referenced by
297 void replaceAllUsesWith(DIDescriptor &D);
298 void replaceAllUsesWith(MDNode *D);
301 /// DIBasicType - A basic type, like 'int' or 'float'.
302 class DIBasicType : public DIType {
304 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
306 unsigned getEncoding() const { return getUnsignedField(9); }
308 /// Verify - Verify that a basic type descriptor is well formed.
312 /// DIDerivedType - A simple derived type, like a const qualified type,
313 /// a typedef, a pointer or reference, et cetera. Or, a data member of
314 /// a class/struct/union.
315 class DIDerivedType : public DIType {
316 friend class DIDescriptor;
317 void printInternal(raw_ostream &OS) const;
319 explicit DIDerivedType(const MDNode *N, bool, bool)
320 : DIType(N, true, true) {}
322 explicit DIDerivedType(const MDNode *N = 0)
323 : DIType(N, true, true) {}
325 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
327 /// getOriginalTypeSize - If this type is derived from a base type then
328 /// return base type size.
329 uint64_t getOriginalTypeSize() const;
331 /// getObjCProperty - Return property node, if this ivar is
332 /// associated with one.
333 MDNode *getObjCProperty() const;
335 DIType getClassType() const {
336 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
337 return getFieldAs<DIType>(10);
340 Constant *getConstant() const {
341 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
342 return getConstantField(10);
345 /// Verify - Verify that a derived type descriptor is well formed.
349 /// DICompositeType - This descriptor holds a type that can refer to multiple
350 /// other types, like a function or struct.
351 /// DICompositeType is derived from DIDerivedType because some
352 /// composite types (such as enums) can be derived from basic types
353 // FIXME: Make this derive from DIType directly & just store the
354 // base type in a single DIType field.
355 class DICompositeType : public DIDerivedType {
356 friend class DIDescriptor;
357 void printInternal(raw_ostream &OS) const;
359 explicit DICompositeType(const MDNode *N = 0)
360 : DIDerivedType(N, true, true) {
361 if (N && !isCompositeType())
365 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
366 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
367 unsigned getRunTimeLang() const { return getUnsignedField(11); }
368 DICompositeType getContainingType() const {
369 return getFieldAs<DICompositeType>(12);
371 void setContainingType(DICompositeType ContainingType);
372 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
374 /// Verify - Verify that a composite type descriptor is well formed.
378 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
379 class DITemplateTypeParameter : public DIDescriptor {
381 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
383 DIScope getContext() const { return getFieldAs<DIScope>(1); }
384 StringRef getName() const { return getStringField(2); }
385 DIType getType() const { return getFieldAs<DIType>(3); }
386 StringRef getFilename() const {
387 return getFieldAs<DIFile>(4).getFilename();
389 StringRef getDirectory() const {
390 return getFieldAs<DIFile>(4).getDirectory();
392 unsigned getLineNumber() const { return getUnsignedField(5); }
393 unsigned getColumnNumber() const { return getUnsignedField(6); }
397 /// DITemplateValueParameter - This is a wrapper for template value parameter.
398 class DITemplateValueParameter : public DIDescriptor {
400 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
402 DIScope getContext() const { return getFieldAs<DIScope>(1); }
403 StringRef getName() const { return getStringField(2); }
404 DIType getType() const { return getFieldAs<DIType>(3); }
405 Value *getValue() const;
406 StringRef getFilename() const {
407 return getFieldAs<DIFile>(5).getFilename();
409 StringRef getDirectory() const {
410 return getFieldAs<DIFile>(5).getDirectory();
412 unsigned getLineNumber() const { return getUnsignedField(6); }
413 unsigned getColumnNumber() const { return getUnsignedField(7); }
417 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
418 class DISubprogram : public DIScope {
419 friend class DIDescriptor;
420 void printInternal(raw_ostream &OS) const;
422 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
424 DIScope getContext() const { return getFieldAs<DIScope>(2); }
425 StringRef getName() const { return getStringField(3); }
426 StringRef getDisplayName() const { return getStringField(4); }
427 StringRef getLinkageName() const { return getStringField(5); }
428 unsigned getLineNumber() const { return getUnsignedField(6); }
429 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
431 /// isLocalToUnit - Return true if this subprogram is local to the current
432 /// compile unit, like 'static' in C.
433 unsigned isLocalToUnit() const { return getUnsignedField(8); }
434 unsigned isDefinition() const { return getUnsignedField(9); }
436 unsigned getVirtuality() const { return getUnsignedField(10); }
437 unsigned getVirtualIndex() const { return getUnsignedField(11); }
439 DICompositeType getContainingType() const {
440 return getFieldAs<DICompositeType>(12);
443 unsigned getFlags() const {
444 return getUnsignedField(13);
447 unsigned isArtificial() const {
448 return (getUnsignedField(13) & FlagArtificial) != 0;
450 /// isPrivate - Return true if this subprogram has "private"
451 /// access specifier.
452 bool isPrivate() const {
453 return (getUnsignedField(13) & FlagPrivate) != 0;
455 /// isProtected - Return true if this subprogram has "protected"
456 /// access specifier.
457 bool isProtected() const {
458 return (getUnsignedField(13) & FlagProtected) != 0;
460 /// isExplicit - Return true if this subprogram is marked as explicit.
461 bool isExplicit() const {
462 return (getUnsignedField(13) & FlagExplicit) != 0;
464 /// isPrototyped - Return true if this subprogram is prototyped.
465 bool isPrototyped() const {
466 return (getUnsignedField(13) & FlagPrototyped) != 0;
469 unsigned isOptimized() const;
471 /// Verify - Verify that a subprogram descriptor is well formed.
474 /// describes - Return true if this subprogram provides debugging
475 /// information for the function F.
476 bool describes(const Function *F);
478 Function *getFunction() const { return getFunctionField(15); }
479 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
480 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
481 DISubprogram getFunctionDeclaration() const {
482 return getFieldAs<DISubprogram>(17);
484 MDNode *getVariablesNodes() const;
485 DIArray getVariables() const;
487 /// getScopeLineNumber - Get the beginning of the scope of the
488 /// function, not necessarily where the name of the program
490 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
493 /// DIGlobalVariable - This is a wrapper for a global variable.
494 class DIGlobalVariable : public DIDescriptor {
495 friend class DIDescriptor;
496 void printInternal(raw_ostream &OS) const;
498 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
500 DIScope getContext() const { return getFieldAs<DIScope>(2); }
501 StringRef getName() const { return getStringField(3); }
502 StringRef getDisplayName() const { return getStringField(4); }
503 StringRef getLinkageName() const { return getStringField(5); }
504 StringRef getFilename() const {
505 return getFieldAs<DIFile>(6).getFilename();
507 StringRef getDirectory() const {
508 return getFieldAs<DIFile>(6).getDirectory();
512 unsigned getLineNumber() const { return getUnsignedField(7); }
513 DIType getType() const { return getFieldAs<DIType>(8); }
514 unsigned isLocalToUnit() const { return getUnsignedField(9); }
515 unsigned isDefinition() const { return getUnsignedField(10); }
517 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
518 Constant *getConstant() const { return getConstantField(11); }
519 DIDerivedType getStaticDataMemberDeclaration() const {
520 return getFieldAs<DIDerivedType>(12);
523 /// Verify - Verify that a global variable descriptor is well formed.
527 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
529 class DIVariable : public DIDescriptor {
530 friend class DIDescriptor;
531 void printInternal(raw_ostream &OS) const;
533 explicit DIVariable(const MDNode *N = 0)
536 DIScope getContext() const { return getFieldAs<DIScope>(1); }
537 StringRef getName() const { return getStringField(2); }
538 DIFile getFile() const { return getFieldAs<DIFile>(3); }
539 unsigned getLineNumber() const {
540 return (getUnsignedField(4) << 8) >> 8;
542 unsigned getArgNumber() const {
543 unsigned L = getUnsignedField(4);
546 DIType getType() const { return getFieldAs<DIType>(5); }
548 /// isArtificial - Return true if this variable is marked as "artificial".
549 bool isArtificial() const {
550 return (getUnsignedField(6) & FlagArtificial) != 0;
553 bool isObjectPointer() const {
554 return (getUnsignedField(6) & FlagObjectPointer) != 0;
557 /// \brief Return true if this variable is represented as a pointer.
558 bool isIndirect() const {
559 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
562 /// getInlinedAt - If this variable is inlined then return inline location.
563 MDNode *getInlinedAt() const;
565 /// Verify - Verify that a variable descriptor is well formed.
568 /// HasComplexAddr - Return true if the variable has a complex address.
569 bool hasComplexAddress() const {
570 return getNumAddrElements() > 0;
573 unsigned getNumAddrElements() const;
575 uint64_t getAddrElement(unsigned Idx) const {
576 return getUInt64Field(Idx+8);
579 /// isBlockByrefVariable - Return true if the variable was declared as
580 /// a "__block" variable (Apple Blocks).
581 bool isBlockByrefVariable() const {
582 return getType().isBlockByrefStruct();
585 /// isInlinedFnArgument - Return true if this variable provides debugging
586 /// information for an inlined function arguments.
587 bool isInlinedFnArgument(const Function *CurFn);
589 void printExtendedName(raw_ostream &OS) const;
592 /// DILexicalBlock - This is a wrapper for a lexical block.
593 class DILexicalBlock : public DIScope {
595 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
596 DIScope getContext() const { return getFieldAs<DIScope>(2); }
597 unsigned getLineNumber() const { return getUnsignedField(3); }
598 unsigned getColumnNumber() const { return getUnsignedField(4); }
602 /// DILexicalBlockFile - This is a wrapper for a lexical block with
603 /// a filename change.
604 class DILexicalBlockFile : public DIScope {
606 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
607 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
608 unsigned getLineNumber() const { return getScope().getLineNumber(); }
609 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
610 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
614 /// DINameSpace - A wrapper for a C++ style name space.
615 class DINameSpace : public DIScope {
616 friend class DIDescriptor;
617 void printInternal(raw_ostream &OS) const;
619 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
620 DIScope getContext() const { return getFieldAs<DIScope>(2); }
621 StringRef getName() const { return getStringField(3); }
622 unsigned getLineNumber() const { return getUnsignedField(4); }
626 /// DILocation - This object holds location information. This object
627 /// is not associated with any DWARF tag.
628 class DILocation : public DIDescriptor {
630 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
632 unsigned getLineNumber() const { return getUnsignedField(0); }
633 unsigned getColumnNumber() const { return getUnsignedField(1); }
634 DIScope getScope() const { return getFieldAs<DIScope>(2); }
635 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
636 StringRef getFilename() const { return getScope().getFilename(); }
637 StringRef getDirectory() const { return getScope().getDirectory(); }
641 class DIObjCProperty : public DIDescriptor {
642 friend class DIDescriptor;
643 void printInternal(raw_ostream &OS) const;
645 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
647 StringRef getObjCPropertyName() const { return getStringField(1); }
648 DIFile getFile() const { return getFieldAs<DIFile>(2); }
649 unsigned getLineNumber() const { return getUnsignedField(3); }
651 StringRef getObjCPropertyGetterName() const {
652 return getStringField(4);
654 StringRef getObjCPropertySetterName() const {
655 return getStringField(5);
657 bool isReadOnlyObjCProperty() const {
658 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
660 bool isReadWriteObjCProperty() const {
661 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
663 bool isAssignObjCProperty() const {
664 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
666 bool isRetainObjCProperty() const {
667 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
669 bool isCopyObjCProperty() const {
670 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
672 bool isNonAtomicObjCProperty() const {
673 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
676 DIType getType() const { return getFieldAs<DIType>(7); }
678 /// Verify - Verify that a derived type descriptor is well formed.
682 /// \brief An imported module (C++ using directive or similar).
683 class DIImportedEntity : public DIDescriptor {
684 friend class DIDescriptor;
685 void printInternal(raw_ostream &OS) const;
687 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
688 DIScope getContext() const { return getFieldAs<DIScope>(1); }
689 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
690 unsigned getLineNumber() const { return getUnsignedField(3); }
691 StringRef getName() const { return getStringField(4); }
695 /// getDISubprogram - Find subprogram that is enclosing this scope.
696 DISubprogram getDISubprogram(const MDNode *Scope);
698 /// getDICompositeType - Find underlying composite type.
699 DICompositeType getDICompositeType(DIType T);
701 /// isSubprogramContext - Return true if Context is either a subprogram
702 /// or another context nested inside a subprogram.
703 bool isSubprogramContext(const MDNode *Context);
705 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
706 /// to hold function specific information.
707 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
709 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
710 /// suitable to hold function specific information.
711 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
713 /// createInlinedVariable - Create a new inlined variable based on current
715 /// @param DV Current Variable.
716 /// @param InlinedScope Location at current variable is inlined.
717 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
718 LLVMContext &VMContext);
720 /// cleanseInlinedVariable - Remove inlined scope from the variable.
721 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
723 class DebugInfoFinder {
725 /// processModule - Process entire module and collect debug info
727 void processModule(const Module &M);
730 /// processType - Process DIType.
731 void processType(DIType DT);
733 /// processLexicalBlock - Process DILexicalBlock.
734 void processLexicalBlock(DILexicalBlock LB);
736 /// processSubprogram - Process DISubprogram.
737 void processSubprogram(DISubprogram SP);
739 /// processDeclare - Process DbgDeclareInst.
740 void processDeclare(const DbgDeclareInst *DDI);
742 /// processLocation - Process DILocation.
743 void processLocation(DILocation Loc);
745 /// addCompileUnit - Add compile unit into CUs.
746 bool addCompileUnit(DICompileUnit CU);
748 /// addGlobalVariable - Add global variable into GVs.
749 bool addGlobalVariable(DIGlobalVariable DIG);
751 // addSubprogram - Add subprogram into SPs.
752 bool addSubprogram(DISubprogram SP);
754 /// addType - Add type into Tys.
755 bool addType(DIType DT);
758 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
759 iterator compile_unit_begin() const { return CUs.begin(); }
760 iterator compile_unit_end() const { return CUs.end(); }
761 iterator subprogram_begin() const { return SPs.begin(); }
762 iterator subprogram_end() const { return SPs.end(); }
763 iterator global_variable_begin() const { return GVs.begin(); }
764 iterator global_variable_end() const { return GVs.end(); }
765 iterator type_begin() const { return TYs.begin(); }
766 iterator type_end() const { return TYs.end(); }
768 unsigned compile_unit_count() const { return CUs.size(); }
769 unsigned global_variable_count() const { return GVs.size(); }
770 unsigned subprogram_count() const { return SPs.size(); }
771 unsigned type_count() const { return TYs.size(); }
774 SmallVector<MDNode *, 8> CUs; // Compile Units
775 SmallVector<MDNode *, 8> SPs; // Subprograms
776 SmallVector<MDNode *, 8> GVs; // Global Variables;
777 SmallVector<MDNode *, 8> TYs; // Types
778 SmallPtrSet<MDNode *, 64> NodesSeen;
780 } // end namespace llvm