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"
44 class DILexicalBlockFile;
49 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
50 /// This should not be stored in a container, because the underlying MDNode
51 /// may change in certain situations.
56 FlagProtected = 1 << 1,
58 FlagAppleBlock = 1 << 3,
59 FlagBlockByrefStruct = 1 << 4,
61 FlagArtificial = 1 << 6,
62 FlagExplicit = 1 << 7,
63 FlagPrototyped = 1 << 8,
64 FlagObjcClassComplete = 1 << 9,
65 FlagObjectPointer = 1 << 10,
67 FlagStaticMember = 1 << 12,
68 FlagIndirectVariable = 1 << 13
71 const MDNode *DbgNode;
73 StringRef getStringField(unsigned Elt) const;
74 unsigned getUnsignedField(unsigned Elt) const {
75 return (unsigned)getUInt64Field(Elt);
77 uint64_t getUInt64Field(unsigned Elt) const;
78 int64_t getInt64Field(unsigned Elt) const;
79 DIDescriptor getDescriptorField(unsigned Elt) const;
81 template <typename DescTy>
82 DescTy getFieldAs(unsigned Elt) const {
83 return DescTy(getDescriptorField(Elt));
86 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
87 Constant *getConstantField(unsigned Elt) const;
88 Function *getFunctionField(unsigned Elt) const;
89 void replaceFunctionField(unsigned Elt, Function *F);
92 explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {}
96 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
97 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
99 // An explicit operator bool so that we can do testing of DI values
101 // FIXME: This operator bool isn't actually protecting anything at the
102 // moment due to the conversion operator above making DIDescriptor nodes
103 // implicitly convertable to bool.
104 LLVM_EXPLICIT operator bool() const { return DbgNode != 0; }
106 bool operator==(DIDescriptor Other) const {
107 return DbgNode == Other.DbgNode;
109 bool operator!=(DIDescriptor Other) const {
110 return !operator==(Other);
113 unsigned getTag() const {
114 return getUnsignedField(0) & ~LLVMDebugVersionMask;
117 bool isDerivedType() const;
118 bool isCompositeType() const;
119 bool isBasicType() const;
120 bool isVariable() const;
121 bool isSubprogram() const;
122 bool isGlobalVariable() const;
123 bool isScope() const;
125 bool isCompileUnit() const;
126 bool isNameSpace() const;
127 bool isLexicalBlockFile() const;
128 bool isLexicalBlock() const;
129 bool isSubrange() const;
130 bool isEnumerator() const;
132 bool isUnspecifiedParameter() const;
133 bool isTemplateTypeParameter() const;
134 bool isTemplateValueParameter() const;
135 bool isObjCProperty() const;
136 bool isImportedEntity() const;
138 /// print - print descriptor.
139 void print(raw_ostream &OS) const;
141 /// dump - print descriptor to dbgs() with a newline.
145 /// DISubrange - This is used to represent ranges, for array bounds.
146 class DISubrange : public DIDescriptor {
147 friend class DIDescriptor;
148 void printInternal(raw_ostream &OS) const;
150 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
152 int64_t getLo() const { return getInt64Field(1); }
153 int64_t getCount() const { return getInt64Field(2); }
157 /// DIArray - This descriptor holds an array of descriptors.
158 class DIArray : public DIDescriptor {
160 explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {}
162 unsigned getNumElements() const;
163 DIDescriptor getElement(unsigned Idx) const {
164 return getDescriptorField(Idx);
168 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
169 /// FIXME: it seems strange that this doesn't have either a reference to the
170 /// type/precision or a file/line pair for location info.
171 class DIEnumerator : public DIDescriptor {
172 friend class DIDescriptor;
173 void printInternal(raw_ostream &OS) const;
175 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
177 StringRef getName() const { return getStringField(1); }
178 int64_t getEnumValue() const { return getInt64Field(2); }
182 /// DIScope - A base class for various scopes.
183 class DIScope : public DIDescriptor {
185 friend class DIDescriptor;
186 void printInternal(raw_ostream &OS) const;
188 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
190 /// Gets the parent scope for this scope node or returns a
191 /// default constructed scope.
192 DIScope getContext() const;
193 StringRef getFilename() const;
194 StringRef getDirectory() const;
197 /// DIType - This is a wrapper for a type.
198 /// FIXME: Types should be factored much better so that CV qualifiers and
199 /// others do not require a huge and empty descriptor full of zeros.
200 class DIType : public DIScope {
202 friend class DIDescriptor;
203 void printInternal(raw_ostream &OS) const;
206 DIType(const MDNode *N = 0) : DIScope(N) {}
208 /// Verify - Verify that a type descriptor is well formed.
211 DIScope getContext() const { return getFieldAs<DIScope>(2); }
212 StringRef getName() const { return getStringField(3); }
213 unsigned getLineNumber() const { return getUnsignedField(4); }
214 uint64_t getSizeInBits() const { return getUInt64Field(5); }
215 uint64_t getAlignInBits() const { return getUInt64Field(6); }
216 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
217 // carry this is just plain insane.
218 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
219 unsigned getFlags() const { return getUnsignedField(8); }
220 bool isPrivate() const {
221 return (getFlags() & FlagPrivate) != 0;
223 bool isProtected() const {
224 return (getFlags() & FlagProtected) != 0;
226 bool isForwardDecl() const {
227 return (getFlags() & FlagFwdDecl) != 0;
229 // isAppleBlock - Return true if this is the Apple Blocks extension.
230 bool isAppleBlockExtension() const {
231 return (getFlags() & FlagAppleBlock) != 0;
233 bool isBlockByrefStruct() const {
234 return (getFlags() & FlagBlockByrefStruct) != 0;
236 bool isVirtual() const {
237 return (getFlags() & FlagVirtual) != 0;
239 bool isArtificial() const {
240 return (getFlags() & FlagArtificial) != 0;
242 bool isObjectPointer() const {
243 return (getFlags() & FlagObjectPointer) != 0;
245 bool isObjcClassComplete() const {
246 return (getFlags() & FlagObjcClassComplete) != 0;
248 bool isVector() const {
249 return (getFlags() & FlagVector) != 0;
251 bool isStaticMember() const {
252 return (getFlags() & FlagStaticMember) != 0;
254 bool isValid() const {
255 return DbgNode && isType();
258 /// isUnsignedDIType - Return true if type encoding is unsigned.
259 bool isUnsignedDIType();
261 /// replaceAllUsesWith - Replace all uses of debug info referenced by
263 void replaceAllUsesWith(DIDescriptor &D);
264 void replaceAllUsesWith(MDNode *D);
267 /// DIBasicType - A basic type, like 'int' or 'float'.
268 class DIBasicType : public DIType {
270 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
272 unsigned getEncoding() const { return getUnsignedField(9); }
274 /// Verify - Verify that a basic type descriptor is well formed.
278 /// DIDerivedType - A simple derived type, like a const qualified type,
279 /// a typedef, a pointer or reference, et cetera. Or, a data member of
280 /// a class/struct/union.
281 class DIDerivedType : public DIType {
282 friend class DIDescriptor;
283 void printInternal(raw_ostream &OS) const;
286 explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {}
288 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
290 /// getOriginalTypeSize - If this type is derived from a base type then
291 /// return base type size.
292 uint64_t getOriginalTypeSize() const;
294 /// getObjCProperty - Return property node, if this ivar is
295 /// associated with one.
296 MDNode *getObjCProperty() const;
298 DIType getClassType() const {
299 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
300 return getFieldAs<DIType>(10);
303 Constant *getConstant() const {
304 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
305 return getConstantField(10);
308 /// Verify - Verify that a derived type descriptor is well formed.
312 /// DICompositeType - This descriptor holds a type that can refer to multiple
313 /// other types, like a function or struct.
314 /// DICompositeType is derived from DIDerivedType because some
315 /// composite types (such as enums) can be derived from basic types
316 // FIXME: Make this derive from DIType directly & just store the
317 // base type in a single DIType field.
318 class DICompositeType : public DIDerivedType {
319 friend class DIDescriptor;
320 void printInternal(raw_ostream &OS) const;
322 explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {}
324 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
325 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
326 unsigned getRunTimeLang() const { return getUnsignedField(11); }
327 DICompositeType getContainingType() const {
328 return getFieldAs<DICompositeType>(12);
330 void setContainingType(DICompositeType ContainingType);
331 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
333 /// Verify - Verify that a composite type descriptor is well formed.
337 /// DIFile - This is a wrapper for a file.
338 class DIFile : public DIScope {
339 friend class DIDescriptor;
341 explicit DIFile(const MDNode *N = 0) : DIScope(N) {}
342 MDNode *getFileNode() const;
346 /// DICompileUnit - A wrapper for a compile unit.
347 class DICompileUnit : public DIScope {
348 friend class DIDescriptor;
349 void printInternal(raw_ostream &OS) const;
351 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
353 unsigned getLanguage() const { return getUnsignedField(2); }
354 StringRef getProducer() const { return getStringField(3); }
356 bool isOptimized() const { return getUnsignedField(4) != 0; }
357 StringRef getFlags() const { return getStringField(5); }
358 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
360 DIArray getEnumTypes() const;
361 DIArray getRetainedTypes() const;
362 DIArray getSubprograms() const;
363 DIArray getGlobalVariables() const;
364 DIArray getImportedEntities() const;
366 StringRef getSplitDebugFilename() const { return getStringField(12); }
368 /// Verify - Verify that a compile unit is well formed.
372 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
373 class DISubprogram : public DIScope {
374 friend class DIDescriptor;
375 void printInternal(raw_ostream &OS) const;
377 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
379 DIScope getContext() const { return getFieldAs<DIScope>(2); }
380 StringRef getName() const { return getStringField(3); }
381 StringRef getDisplayName() const { return getStringField(4); }
382 StringRef getLinkageName() const { return getStringField(5); }
383 unsigned getLineNumber() const { return getUnsignedField(6); }
384 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
386 /// isLocalToUnit - Return true if this subprogram is local to the current
387 /// compile unit, like 'static' in C.
388 unsigned isLocalToUnit() const { return getUnsignedField(8); }
389 unsigned isDefinition() const { return getUnsignedField(9); }
391 unsigned getVirtuality() const { return getUnsignedField(10); }
392 unsigned getVirtualIndex() const { return getUnsignedField(11); }
394 DICompositeType getContainingType() const {
395 return getFieldAs<DICompositeType>(12);
398 unsigned getFlags() const {
399 return getUnsignedField(13);
402 unsigned isArtificial() const {
403 return (getUnsignedField(13) & FlagArtificial) != 0;
405 /// isPrivate - Return true if this subprogram has "private"
406 /// access specifier.
407 bool isPrivate() const {
408 return (getUnsignedField(13) & FlagPrivate) != 0;
410 /// isProtected - Return true if this subprogram has "protected"
411 /// access specifier.
412 bool isProtected() const {
413 return (getUnsignedField(13) & FlagProtected) != 0;
415 /// isExplicit - Return true if this subprogram is marked as explicit.
416 bool isExplicit() const {
417 return (getUnsignedField(13) & FlagExplicit) != 0;
419 /// isPrototyped - Return true if this subprogram is prototyped.
420 bool isPrototyped() const {
421 return (getUnsignedField(13) & FlagPrototyped) != 0;
424 unsigned isOptimized() const;
426 /// Verify - Verify that a subprogram descriptor is well formed.
429 /// describes - Return true if this subprogram provides debugging
430 /// information for the function F.
431 bool describes(const Function *F);
433 Function *getFunction() const { return getFunctionField(15); }
434 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
435 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
436 DISubprogram getFunctionDeclaration() const {
437 return getFieldAs<DISubprogram>(17);
439 MDNode *getVariablesNodes() const;
440 DIArray getVariables() const;
442 /// getScopeLineNumber - Get the beginning of the scope of the
443 /// function, not necessarily where the name of the program
445 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
448 /// DILexicalBlock - This is a wrapper for a lexical block.
449 class DILexicalBlock : public DIScope {
451 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
452 DIScope getContext() const { return getFieldAs<DIScope>(2); }
453 unsigned getLineNumber() const { return getUnsignedField(3); }
454 unsigned getColumnNumber() const { return getUnsignedField(4); }
458 /// DILexicalBlockFile - This is a wrapper for a lexical block with
459 /// a filename change.
460 class DILexicalBlockFile : public DIScope {
462 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
463 DIScope getContext() const {
464 if (getScope().isSubprogram())
466 return getScope().getContext();
468 unsigned getLineNumber() const { return getScope().getLineNumber(); }
469 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
470 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
474 /// DINameSpace - A wrapper for a C++ style name space.
475 class DINameSpace : public DIScope {
476 friend class DIDescriptor;
477 void printInternal(raw_ostream &OS) const;
479 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
480 DIScope getContext() const { return getFieldAs<DIScope>(2); }
481 StringRef getName() const { return getStringField(3); }
482 unsigned getLineNumber() const { return getUnsignedField(4); }
486 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
487 class DITemplateTypeParameter : public DIDescriptor {
489 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
491 DIScope getContext() const { return getFieldAs<DIScope>(1); }
492 StringRef getName() const { return getStringField(2); }
493 DIType getType() const { return getFieldAs<DIType>(3); }
494 StringRef getFilename() const {
495 return getFieldAs<DIFile>(4).getFilename();
497 StringRef getDirectory() const {
498 return getFieldAs<DIFile>(4).getDirectory();
500 unsigned getLineNumber() const { return getUnsignedField(5); }
501 unsigned getColumnNumber() const { return getUnsignedField(6); }
505 /// DITemplateValueParameter - This is a wrapper for template value parameter.
506 class DITemplateValueParameter : public DIDescriptor {
508 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
510 DIScope getContext() const { return getFieldAs<DIScope>(1); }
511 StringRef getName() const { return getStringField(2); }
512 DIType getType() const { return getFieldAs<DIType>(3); }
513 Value *getValue() const;
514 StringRef getFilename() const {
515 return getFieldAs<DIFile>(5).getFilename();
517 StringRef getDirectory() const {
518 return getFieldAs<DIFile>(5).getDirectory();
520 unsigned getLineNumber() const { return getUnsignedField(6); }
521 unsigned getColumnNumber() const { return getUnsignedField(7); }
525 /// DIGlobalVariable - This is a wrapper for a global variable.
526 class DIGlobalVariable : public DIDescriptor {
527 friend class DIDescriptor;
528 void printInternal(raw_ostream &OS) const;
530 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
532 DIScope getContext() const { return getFieldAs<DIScope>(2); }
533 StringRef getName() const { return getStringField(3); }
534 StringRef getDisplayName() const { return getStringField(4); }
535 StringRef getLinkageName() const { return getStringField(5); }
536 StringRef getFilename() const {
537 return getFieldAs<DIFile>(6).getFilename();
539 StringRef getDirectory() const {
540 return getFieldAs<DIFile>(6).getDirectory();
544 unsigned getLineNumber() const { return getUnsignedField(7); }
545 DIType getType() const { return getFieldAs<DIType>(8); }
546 unsigned isLocalToUnit() const { return getUnsignedField(9); }
547 unsigned isDefinition() const { return getUnsignedField(10); }
549 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
550 Constant *getConstant() const { return getConstantField(11); }
551 DIDerivedType getStaticDataMemberDeclaration() const {
552 return getFieldAs<DIDerivedType>(12);
555 /// Verify - Verify that a global variable descriptor is well formed.
559 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
561 class DIVariable : public DIDescriptor {
562 friend class DIDescriptor;
563 void printInternal(raw_ostream &OS) const;
565 explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {}
567 DIScope getContext() const { return getFieldAs<DIScope>(1); }
568 StringRef getName() const { return getStringField(2); }
569 DIFile getFile() const { return getFieldAs<DIFile>(3); }
570 unsigned getLineNumber() const {
571 return (getUnsignedField(4) << 8) >> 8;
573 unsigned getArgNumber() const {
574 unsigned L = getUnsignedField(4);
577 DIType getType() const { return getFieldAs<DIType>(5); }
579 /// isArtificial - Return true if this variable is marked as "artificial".
580 bool isArtificial() const {
581 return (getUnsignedField(6) & FlagArtificial) != 0;
584 bool isObjectPointer() const {
585 return (getUnsignedField(6) & FlagObjectPointer) != 0;
588 /// \brief Return true if this variable is represented as a pointer.
589 bool isIndirect() const {
590 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
593 /// getInlinedAt - If this variable is inlined then return inline location.
594 MDNode *getInlinedAt() const;
596 /// Verify - Verify that a variable descriptor is well formed.
599 /// HasComplexAddr - Return true if the variable has a complex address.
600 bool hasComplexAddress() const {
601 return getNumAddrElements() > 0;
604 unsigned getNumAddrElements() const;
606 uint64_t getAddrElement(unsigned Idx) const {
607 return getUInt64Field(Idx+8);
610 /// isBlockByrefVariable - Return true if the variable was declared as
611 /// a "__block" variable (Apple Blocks).
612 bool isBlockByrefVariable() const {
613 return getType().isBlockByrefStruct();
616 /// isInlinedFnArgument - Return true if this variable provides debugging
617 /// information for an inlined function arguments.
618 bool isInlinedFnArgument(const Function *CurFn);
620 void printExtendedName(raw_ostream &OS) const;
623 /// DILocation - This object holds location information. This object
624 /// is not associated with any DWARF tag.
625 class DILocation : public DIDescriptor {
627 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
629 unsigned getLineNumber() const { return getUnsignedField(0); }
630 unsigned getColumnNumber() const { return getUnsignedField(1); }
631 DIScope getScope() const { return getFieldAs<DIScope>(2); }
632 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
633 StringRef getFilename() const { return getScope().getFilename(); }
634 StringRef getDirectory() const { return getScope().getDirectory(); }
638 class DIObjCProperty : public DIDescriptor {
639 friend class DIDescriptor;
640 void printInternal(raw_ostream &OS) const;
642 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
644 StringRef getObjCPropertyName() const { return getStringField(1); }
645 DIFile getFile() const { return getFieldAs<DIFile>(2); }
646 unsigned getLineNumber() const { return getUnsignedField(3); }
648 StringRef getObjCPropertyGetterName() const {
649 return getStringField(4);
651 StringRef getObjCPropertySetterName() const {
652 return getStringField(5);
654 bool isReadOnlyObjCProperty() const {
655 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
657 bool isReadWriteObjCProperty() const {
658 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
660 bool isAssignObjCProperty() const {
661 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
663 bool isRetainObjCProperty() const {
664 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
666 bool isCopyObjCProperty() const {
667 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
669 bool isNonAtomicObjCProperty() const {
670 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
673 DIType getType() const { return getFieldAs<DIType>(7); }
675 /// Verify - Verify that a derived type descriptor is well formed.
679 /// \brief An imported module (C++ using directive or similar).
680 class DIImportedEntity : public DIDescriptor {
681 friend class DIDescriptor;
682 void printInternal(raw_ostream &OS) const;
684 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
685 DIScope getContext() const { return getFieldAs<DIScope>(1); }
686 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
687 unsigned getLineNumber() const { return getUnsignedField(3); }
688 StringRef getName() const { return getStringField(4); }
692 /// getDISubprogram - Find subprogram that is enclosing this scope.
693 DISubprogram getDISubprogram(const MDNode *Scope);
695 /// getDICompositeType - Find underlying composite type.
696 DICompositeType getDICompositeType(DIType T);
698 /// isSubprogramContext - Return true if Context is either a subprogram
699 /// or another context nested inside a subprogram.
700 bool isSubprogramContext(const MDNode *Context);
702 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
703 /// to hold function specific information.
704 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
706 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
707 /// suitable to hold function specific information.
708 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
710 /// createInlinedVariable - Create a new inlined variable based on current
712 /// @param DV Current Variable.
713 /// @param InlinedScope Location at current variable is inlined.
714 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
715 LLVMContext &VMContext);
717 /// cleanseInlinedVariable - Remove inlined scope from the variable.
718 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
720 /// DebugInfoFinder tries to list all debug info MDNodes in a module. To
721 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
722 /// processDeclare and processValue. processModule will go through
723 /// all DICompileUnits and list debug info MDNodes used by the CUs.
724 class DebugInfoFinder {
726 /// processModule - Process entire module and collect debug info
728 void processModule(const Module &M);
730 /// processDeclare - Process DbgDeclareInst.
731 void processDeclare(const DbgDeclareInst *DDI);
732 /// Process DbgValueInst.
733 void processValue(const DbgValueInst *DVI);
738 /// processType - Process DIType.
739 void processType(DIType DT);
741 /// processLexicalBlock - Process DILexicalBlock.
742 void processLexicalBlock(DILexicalBlock LB);
744 /// processSubprogram - Process DISubprogram.
745 void processSubprogram(DISubprogram SP);
747 /// processLocation - Process DILocation.
748 void processLocation(DILocation Loc);
750 void processScope(DIScope Scope);
752 /// addCompileUnit - Add compile unit into CUs.
753 bool addCompileUnit(DICompileUnit CU);
755 /// addGlobalVariable - Add global variable into GVs.
756 bool addGlobalVariable(DIGlobalVariable DIG);
758 // addSubprogram - Add subprogram into SPs.
759 bool addSubprogram(DISubprogram SP);
761 /// addType - Add type into Tys.
762 bool addType(DIType DT);
764 bool addScope(DIScope Scope);
767 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
768 iterator compile_unit_begin() const { return CUs.begin(); }
769 iterator compile_unit_end() const { return CUs.end(); }
770 iterator subprogram_begin() const { return SPs.begin(); }
771 iterator subprogram_end() const { return SPs.end(); }
772 iterator global_variable_begin() const { return GVs.begin(); }
773 iterator global_variable_end() const { return GVs.end(); }
774 iterator type_begin() const { return TYs.begin(); }
775 iterator type_end() const { return TYs.end(); }
776 iterator scope_begin() const { return Scopes.begin(); }
777 iterator scope_end() const { return Scopes.end(); }
779 unsigned compile_unit_count() const { return CUs.size(); }
780 unsigned global_variable_count() const { return GVs.size(); }
781 unsigned subprogram_count() const { return SPs.size(); }
782 unsigned type_count() const { return TYs.size(); }
783 unsigned scope_count() const { return Scopes.size(); }
786 SmallVector<MDNode *, 8> CUs; // Compile Units
787 SmallVector<MDNode *, 8> SPs; // Subprograms
788 SmallVector<MDNode *, 8> GVs; // Global Variables;
789 SmallVector<MDNode *, 8> TYs; // Types
790 SmallVector<MDNode *, 8> Scopes; // Scopes
791 SmallPtrSet<MDNode *, 64> NodesSeen;
793 } // end namespace llvm