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/DenseMap.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Support/Dwarf.h"
44 class DILexicalBlockFile;
49 /// Map from a pair <unique type name, an unsigned flag> to MDNode.
50 typedef DenseMap<std::pair<StringRef, unsigned>, MDNode*> DITypeHashMap;
52 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
53 /// This should not be stored in a container, because the underlying MDNode
54 /// may change in certain situations.
59 FlagProtected = 1 << 1,
61 FlagAppleBlock = 1 << 3,
62 FlagBlockByrefStruct = 1 << 4,
64 FlagArtificial = 1 << 6,
65 FlagExplicit = 1 << 7,
66 FlagPrototyped = 1 << 8,
67 FlagObjcClassComplete = 1 << 9,
68 FlagObjectPointer = 1 << 10,
70 FlagStaticMember = 1 << 12,
71 FlagIndirectVariable = 1 << 13
74 const MDNode *DbgNode;
76 StringRef getStringField(unsigned Elt) const;
77 unsigned getUnsignedField(unsigned Elt) const {
78 return (unsigned)getUInt64Field(Elt);
80 uint64_t getUInt64Field(unsigned Elt) const;
81 int64_t getInt64Field(unsigned Elt) const;
82 DIDescriptor getDescriptorField(unsigned Elt) const;
84 template <typename DescTy>
85 DescTy getFieldAs(unsigned Elt) const {
86 return DescTy(getDescriptorField(Elt));
89 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
90 Constant *getConstantField(unsigned Elt) const;
91 Function *getFunctionField(unsigned Elt) const;
92 void replaceFunctionField(unsigned Elt, Function *F);
95 explicit DIDescriptor() : DbgNode(0) {}
96 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
97 explicit DIDescriptor(const DIFile F);
98 explicit DIDescriptor(const DISubprogram F);
99 explicit DIDescriptor(const DILexicalBlockFile F);
100 explicit DIDescriptor(const DILexicalBlock F);
101 explicit DIDescriptor(const DIVariable F);
102 explicit DIDescriptor(const DIType F);
106 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
107 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
109 unsigned getTag() const {
110 return getUnsignedField(0) & ~LLVMDebugVersionMask;
113 bool isDerivedType() const;
114 bool isCompositeType() const;
115 bool isBasicType() const;
116 bool isVariable() const;
117 bool isSubprogram() const;
118 bool isGlobalVariable() const;
119 bool isScope() const;
121 bool isCompileUnit() const;
122 bool isNameSpace() const;
123 bool isLexicalBlockFile() const;
124 bool isLexicalBlock() const;
125 bool isSubrange() const;
126 bool isEnumerator() const;
128 bool isGlobal() const;
129 bool isUnspecifiedParameter() const;
130 bool isTemplateTypeParameter() const;
131 bool isTemplateValueParameter() const;
132 bool isObjCProperty() const;
133 bool isImportedEntity() const;
135 /// print - print descriptor.
136 void print(raw_ostream &OS) const;
138 /// dump - print descriptor to dbgs() with a newline.
142 /// DISubrange - This is used to represent ranges, for array bounds.
143 class DISubrange : public DIDescriptor {
144 friend class DIDescriptor;
145 void printInternal(raw_ostream &OS) const;
147 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
149 int64_t getLo() const { return getInt64Field(1); }
150 int64_t getCount() const { return getInt64Field(2); }
154 /// DIArray - This descriptor holds an array of descriptors.
155 class DIArray : public DIDescriptor {
157 explicit DIArray(const MDNode *N = 0)
160 unsigned getNumElements() const;
161 DIDescriptor getElement(unsigned Idx) const {
162 return getDescriptorField(Idx);
166 /// DIScope - A base class for various scopes.
167 class DIScope : public DIDescriptor {
169 friend class DIDescriptor;
170 void printInternal(raw_ostream &OS) const;
172 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
174 /// Set the filename by allocating a new string MDNode for
175 /// it and attaching it to the underlying node.
176 void setFilename(StringRef Name, LLVMContext &Context);
177 StringRef getFilename() const;
178 StringRef getDirectory() const;
181 /// DIFile - This is a wrapper for a file.
182 class DIFile : public DIScope {
183 friend class DIDescriptor;
185 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
186 if (DbgNode && !isFile())
189 MDNode *getFileNode() const;
193 /// DICompileUnit - A wrapper for a compile unit.
194 class DICompileUnit : public DIScope {
195 friend class DIDescriptor;
196 void printInternal(raw_ostream &OS) const;
198 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
200 unsigned getLanguage() const { return getUnsignedField(2); }
201 StringRef getProducer() const { return getStringField(3); }
203 bool isOptimized() const { return getUnsignedField(4) != 0; }
204 StringRef getFlags() const { return getStringField(5); }
205 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
207 DIArray getEnumTypes() const;
208 DIArray getRetainedTypes() const;
209 DIArray getSubprograms() const;
210 DIArray getGlobalVariables() const;
211 DIArray getImportedEntities() const;
213 StringRef getSplitDebugFilename() const { return getStringField(12); }
215 /// Verify - Verify that a compile unit is well formed.
219 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
220 /// FIXME: it seems strange that this doesn't have either a reference to the
221 /// type/precision or a file/line pair for location info.
222 class DIEnumerator : public DIDescriptor {
223 friend class DIDescriptor;
224 void printInternal(raw_ostream &OS) const;
226 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
228 StringRef getName() const { return getStringField(1); }
229 int64_t getEnumValue() const { return getInt64Field(2); }
233 /// DIType - This is a wrapper for a type.
234 /// FIXME: Types should be factored much better so that CV qualifiers and
235 /// others do not require a huge and empty descriptor full of zeros.
236 class DIType : public DIScope {
238 friend class DIDescriptor;
239 void printInternal(raw_ostream &OS) const;
240 // This ctor is used when the Tag has already been validated by a derived
242 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
244 /// Verify - Verify that a type descriptor is well formed.
246 explicit DIType(const MDNode *N);
249 DIScope getContext() const { return getFieldAs<DIScope>(2); }
250 StringRef getName() const { return getStringField(3); }
251 unsigned getLineNumber() const { return getUnsignedField(4); }
252 uint64_t getSizeInBits() const { return getUInt64Field(5); }
253 uint64_t getAlignInBits() const { return getUInt64Field(6); }
254 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
255 // carry this is just plain insane.
256 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
257 unsigned getFlags() const { return getUnsignedField(8); }
258 bool isPrivate() const {
259 return (getFlags() & FlagPrivate) != 0;
261 bool isProtected() const {
262 return (getFlags() & FlagProtected) != 0;
264 bool isForwardDecl() const {
265 return (getFlags() & FlagFwdDecl) != 0;
267 // isAppleBlock - Return true if this is the Apple Blocks extension.
268 bool isAppleBlockExtension() const {
269 return (getFlags() & FlagAppleBlock) != 0;
271 bool isBlockByrefStruct() const {
272 return (getFlags() & FlagBlockByrefStruct) != 0;
274 bool isVirtual() const {
275 return (getFlags() & FlagVirtual) != 0;
277 bool isArtificial() const {
278 return (getFlags() & FlagArtificial) != 0;
280 bool isObjectPointer() const {
281 return (getFlags() & FlagObjectPointer) != 0;
283 bool isObjcClassComplete() const {
284 return (getFlags() & FlagObjcClassComplete) != 0;
286 bool isVector() const {
287 return (getFlags() & FlagVector) != 0;
289 bool isStaticMember() const {
290 return (getFlags() & FlagStaticMember) != 0;
292 bool isValid() const {
293 return DbgNode && isType();
296 /// isUnsignedDIType - Return true if type encoding is unsigned.
297 bool isUnsignedDIType();
299 /// replaceAllUsesWith - Replace all uses of debug info referenced by
301 void replaceAllUsesWith(DIDescriptor &D);
302 void replaceAllUsesWith(MDNode *D);
305 /// DIBasicType - A basic type, like 'int' or 'float'.
306 class DIBasicType : public DIType {
308 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
310 unsigned getEncoding() const { return getUnsignedField(9); }
312 /// Verify - Verify that a basic type descriptor is well formed.
316 /// DIDerivedType - A simple derived type, like a const qualified type,
317 /// a typedef, a pointer or reference, et cetera. Or, a data member of
318 /// a class/struct/union.
319 class DIDerivedType : public DIType {
320 friend class DIDescriptor;
321 void printInternal(raw_ostream &OS) const;
323 explicit DIDerivedType(const MDNode *N, bool, bool)
324 : DIType(N, true, true) {}
326 explicit DIDerivedType(const MDNode *N = 0)
327 : DIType(N, true, true) {}
329 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
331 /// getOriginalTypeSize - If this type is derived from a base type then
332 /// return base type size.
333 uint64_t getOriginalTypeSize() const;
335 /// getObjCProperty - Return property node, if this ivar is
336 /// associated with one.
337 MDNode *getObjCProperty() const;
339 DIType getClassType() const {
340 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
341 return getFieldAs<DIType>(10);
344 Constant *getConstant() const {
345 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
346 return getConstantField(10);
349 /// Verify - Verify that a derived type descriptor is well formed.
353 /// DICompositeType - This descriptor holds a type that can refer to multiple
354 /// other types, like a function or struct.
355 /// DICompositeType is derived from DIDerivedType because some
356 /// composite types (such as enums) can be derived from basic types
357 // FIXME: Make this derive from DIType directly & just store the
358 // base type in a single DIType field.
359 class DICompositeType : public DIDerivedType {
360 friend class DIDescriptor;
361 void printInternal(raw_ostream &OS) const;
363 explicit DICompositeType(const MDNode *N = 0)
364 : DIDerivedType(N, true, true) {
365 if (N && !isCompositeType())
369 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
370 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
371 unsigned getRunTimeLang() const { return getUnsignedField(11); }
372 DICompositeType getContainingType() const {
373 return getFieldAs<DICompositeType>(12);
375 void setContainingType(DICompositeType ContainingType);
376 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
378 /// Verify - Verify that a composite type descriptor is well formed.
382 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
383 class DITemplateTypeParameter : public DIDescriptor {
385 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
387 DIScope getContext() const { return getFieldAs<DIScope>(1); }
388 StringRef getName() const { return getStringField(2); }
389 DIType getType() const { return getFieldAs<DIType>(3); }
390 StringRef getFilename() const {
391 return getFieldAs<DIFile>(4).getFilename();
393 StringRef getDirectory() const {
394 return getFieldAs<DIFile>(4).getDirectory();
396 unsigned getLineNumber() const { return getUnsignedField(5); }
397 unsigned getColumnNumber() const { return getUnsignedField(6); }
401 /// DITemplateValueParameter - This is a wrapper for template value parameter.
402 class DITemplateValueParameter : public DIDescriptor {
404 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
406 DIScope getContext() const { return getFieldAs<DIScope>(1); }
407 StringRef getName() const { return getStringField(2); }
408 DIType getType() const { return getFieldAs<DIType>(3); }
409 Value *getValue() const;
410 StringRef getFilename() const {
411 return getFieldAs<DIFile>(5).getFilename();
413 StringRef getDirectory() const {
414 return getFieldAs<DIFile>(5).getDirectory();
416 unsigned getLineNumber() const { return getUnsignedField(6); }
417 unsigned getColumnNumber() const { return getUnsignedField(7); }
421 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
422 class DISubprogram : public DIScope {
423 friend class DIDescriptor;
424 void printInternal(raw_ostream &OS) const;
426 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
428 DIScope getContext() const { return getFieldAs<DIScope>(2); }
429 StringRef getName() const { return getStringField(3); }
430 StringRef getDisplayName() const { return getStringField(4); }
431 StringRef getLinkageName() const { return getStringField(5); }
432 unsigned getLineNumber() const { return getUnsignedField(6); }
433 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
435 /// isLocalToUnit - Return true if this subprogram is local to the current
436 /// compile unit, like 'static' in C.
437 unsigned isLocalToUnit() const { return getUnsignedField(8); }
438 unsigned isDefinition() const { return getUnsignedField(9); }
440 unsigned getVirtuality() const { return getUnsignedField(10); }
441 unsigned getVirtualIndex() const { return getUnsignedField(11); }
443 DICompositeType getContainingType() const {
444 return getFieldAs<DICompositeType>(12);
447 unsigned getFlags() const {
448 return getUnsignedField(13);
451 unsigned isArtificial() const {
452 return (getUnsignedField(13) & FlagArtificial) != 0;
454 /// isPrivate - Return true if this subprogram has "private"
455 /// access specifier.
456 bool isPrivate() const {
457 return (getUnsignedField(13) & FlagPrivate) != 0;
459 /// isProtected - Return true if this subprogram has "protected"
460 /// access specifier.
461 bool isProtected() const {
462 return (getUnsignedField(13) & FlagProtected) != 0;
464 /// isExplicit - Return true if this subprogram is marked as explicit.
465 bool isExplicit() const {
466 return (getUnsignedField(13) & FlagExplicit) != 0;
468 /// isPrototyped - Return true if this subprogram is prototyped.
469 bool isPrototyped() const {
470 return (getUnsignedField(13) & FlagPrototyped) != 0;
473 unsigned isOptimized() const;
475 /// Verify - Verify that a subprogram descriptor is well formed.
478 /// describes - Return true if this subprogram provides debugging
479 /// information for the function F.
480 bool describes(const Function *F);
482 Function *getFunction() const { return getFunctionField(15); }
483 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
484 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
485 DISubprogram getFunctionDeclaration() const {
486 return getFieldAs<DISubprogram>(17);
488 MDNode *getVariablesNodes() const;
489 DIArray getVariables() const;
491 /// getScopeLineNumber - Get the beginning of the scope of the
492 /// function, not necessarily where the name of the program
494 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
497 /// DIGlobalVariable - This is a wrapper for a global variable.
498 class DIGlobalVariable : public DIDescriptor {
499 friend class DIDescriptor;
500 void printInternal(raw_ostream &OS) const;
502 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
504 DIScope getContext() const { return getFieldAs<DIScope>(2); }
505 StringRef getName() const { return getStringField(3); }
506 StringRef getDisplayName() const { return getStringField(4); }
507 StringRef getLinkageName() const { return getStringField(5); }
508 StringRef getFilename() const {
509 return getFieldAs<DIFile>(6).getFilename();
511 StringRef getDirectory() const {
512 return getFieldAs<DIFile>(6).getDirectory();
516 unsigned getLineNumber() const { return getUnsignedField(7); }
517 DIType getType() const { return getFieldAs<DIType>(8); }
518 unsigned isLocalToUnit() const { return getUnsignedField(9); }
519 unsigned isDefinition() const { return getUnsignedField(10); }
521 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
522 Constant *getConstant() const { return getConstantField(11); }
523 DIDerivedType getStaticDataMemberDeclaration() const {
524 return getFieldAs<DIDerivedType>(12);
527 /// Verify - Verify that a global variable descriptor is well formed.
531 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
533 class DIVariable : public DIDescriptor {
534 friend class DIDescriptor;
535 void printInternal(raw_ostream &OS) const;
537 explicit DIVariable(const MDNode *N = 0)
540 DIScope getContext() const { return getFieldAs<DIScope>(1); }
541 StringRef getName() const { return getStringField(2); }
542 DIFile getFile() const { return getFieldAs<DIFile>(3); }
543 unsigned getLineNumber() const {
544 return (getUnsignedField(4) << 8) >> 8;
546 unsigned getArgNumber() const {
547 unsigned L = getUnsignedField(4);
550 DIType getType() const { return getFieldAs<DIType>(5); }
552 /// isArtificial - Return true if this variable is marked as "artificial".
553 bool isArtificial() const {
554 return (getUnsignedField(6) & FlagArtificial) != 0;
557 bool isObjectPointer() const {
558 return (getUnsignedField(6) & FlagObjectPointer) != 0;
561 /// \brief Return true if this variable is represented as a pointer.
562 bool isIndirect() const {
563 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
566 /// getInlinedAt - If this variable is inlined then return inline location.
567 MDNode *getInlinedAt() const;
569 /// Verify - Verify that a variable descriptor is well formed.
572 /// HasComplexAddr - Return true if the variable has a complex address.
573 bool hasComplexAddress() const {
574 return getNumAddrElements() > 0;
577 unsigned getNumAddrElements() const;
579 uint64_t getAddrElement(unsigned Idx) const {
580 return getUInt64Field(Idx+8);
583 /// isBlockByrefVariable - Return true if the variable was declared as
584 /// a "__block" variable (Apple Blocks).
585 bool isBlockByrefVariable() const {
586 return getType().isBlockByrefStruct();
589 /// isInlinedFnArgument - Return true if this variable provides debugging
590 /// information for an inlined function arguments.
591 bool isInlinedFnArgument(const Function *CurFn);
593 void printExtendedName(raw_ostream &OS) const;
596 /// DILexicalBlock - This is a wrapper for a lexical block.
597 class DILexicalBlock : public DIScope {
599 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
600 DIScope getContext() const { return getFieldAs<DIScope>(2); }
601 unsigned getLineNumber() const { return getUnsignedField(3); }
602 unsigned getColumnNumber() const { return getUnsignedField(4); }
606 /// DILexicalBlockFile - This is a wrapper for a lexical block with
607 /// a filename change.
608 class DILexicalBlockFile : public DIScope {
610 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
611 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
612 unsigned getLineNumber() const { return getScope().getLineNumber(); }
613 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
614 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
618 /// DINameSpace - A wrapper for a C++ style name space.
619 class DINameSpace : public DIScope {
620 friend class DIDescriptor;
621 void printInternal(raw_ostream &OS) const;
623 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
624 DIScope getContext() const { return getFieldAs<DIScope>(2); }
625 StringRef getName() const { return getStringField(3); }
626 unsigned getLineNumber() const { return getUnsignedField(4); }
630 /// DILocation - This object holds location information. This object
631 /// is not associated with any DWARF tag.
632 class DILocation : public DIDescriptor {
634 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
636 unsigned getLineNumber() const { return getUnsignedField(0); }
637 unsigned getColumnNumber() const { return getUnsignedField(1); }
638 DIScope getScope() const { return getFieldAs<DIScope>(2); }
639 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
640 StringRef getFilename() const { return getScope().getFilename(); }
641 StringRef getDirectory() const { return getScope().getDirectory(); }
645 class DIObjCProperty : public DIDescriptor {
646 friend class DIDescriptor;
647 void printInternal(raw_ostream &OS) const;
649 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
651 StringRef getObjCPropertyName() const { return getStringField(1); }
652 DIFile getFile() const { return getFieldAs<DIFile>(2); }
653 unsigned getLineNumber() const { return getUnsignedField(3); }
655 StringRef getObjCPropertyGetterName() const {
656 return getStringField(4);
658 StringRef getObjCPropertySetterName() const {
659 return getStringField(5);
661 bool isReadOnlyObjCProperty() const {
662 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
664 bool isReadWriteObjCProperty() const {
665 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
667 bool isAssignObjCProperty() const {
668 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
670 bool isRetainObjCProperty() const {
671 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
673 bool isCopyObjCProperty() const {
674 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
676 bool isNonAtomicObjCProperty() const {
677 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
680 DIType getType() const { return getFieldAs<DIType>(7); }
682 /// Verify - Verify that a derived type descriptor is well formed.
686 /// \brief An imported module (C++ using directive or similar).
687 class DIImportedEntity : public DIDescriptor {
688 friend class DIDescriptor;
689 void printInternal(raw_ostream &OS) const;
691 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
692 DIScope getContext() const { return getFieldAs<DIScope>(1); }
693 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
694 unsigned getLineNumber() const { return getUnsignedField(3); }
695 StringRef getName() const { return getStringField(4); }
699 /// getDISubprogram - Find subprogram that is enclosing this scope.
700 DISubprogram getDISubprogram(const MDNode *Scope);
702 /// getDICompositeType - Find underlying composite type.
703 DICompositeType getDICompositeType(DIType T);
705 /// isSubprogramContext - Return true if Context is either a subprogram
706 /// or another context nested inside a subprogram.
707 bool isSubprogramContext(const MDNode *Context);
709 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
710 /// to hold function specific information.
711 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
713 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
714 /// suitable to hold function specific information.
715 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
717 /// createInlinedVariable - Create a new inlined variable based on current
719 /// @param DV Current Variable.
720 /// @param InlinedScope Location at current variable is inlined.
721 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
722 LLVMContext &VMContext);
724 /// cleanseInlinedVariable - Remove inlined scope from the variable.
725 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
727 class DebugInfoFinder {
729 /// processModule - Process entire module and collect debug info
731 void processModule(const Module &M);
734 /// processType - Process DIType.
735 void processType(DIType DT);
737 /// processLexicalBlock - Process DILexicalBlock.
738 void processLexicalBlock(DILexicalBlock LB);
740 /// processSubprogram - Process DISubprogram.
741 void processSubprogram(DISubprogram SP);
743 /// processDeclare - Process DbgDeclareInst.
744 void processDeclare(const DbgDeclareInst *DDI);
746 /// processLocation - Process DILocation.
747 void processLocation(DILocation Loc);
749 /// addCompileUnit - Add compile unit into CUs.
750 bool addCompileUnit(DICompileUnit CU);
752 /// addGlobalVariable - Add global variable into GVs.
753 bool addGlobalVariable(DIGlobalVariable DIG);
755 // addSubprogram - Add subprogram into SPs.
756 bool addSubprogram(DISubprogram SP);
758 /// addType - Add type into Tys.
759 bool addType(DIType DT);
762 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
763 iterator compile_unit_begin() const { return CUs.begin(); }
764 iterator compile_unit_end() const { return CUs.end(); }
765 iterator subprogram_begin() const { return SPs.begin(); }
766 iterator subprogram_end() const { return SPs.end(); }
767 iterator global_variable_begin() const { return GVs.begin(); }
768 iterator global_variable_end() const { return GVs.end(); }
769 iterator type_begin() const { return TYs.begin(); }
770 iterator type_end() const { return TYs.end(); }
772 unsigned compile_unit_count() const { return CUs.size(); }
773 unsigned global_variable_count() const { return GVs.size(); }
774 unsigned subprogram_count() const { return SPs.size(); }
775 unsigned type_count() const { return TYs.size(); }
778 SmallVector<MDNode *, 8> CUs; // Compile Units
779 SmallVector<MDNode *, 8> SPs; // Subprograms
780 SmallVector<MDNode *, 8> GVs; // Global Variables;
781 SmallVector<MDNode *, 8> TYs; // Types
782 SmallPtrSet<MDNode *, 64> NodesSeen;
784 } // end namespace llvm