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() : DbgNode(0) {}
93 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
94 explicit DIDescriptor(const DIFile F);
95 explicit DIDescriptor(const DISubprogram F);
96 explicit DIDescriptor(const DILexicalBlockFile F);
97 explicit DIDescriptor(const DILexicalBlock F);
98 explicit DIDescriptor(const DIVariable F);
99 explicit DIDescriptor(const DIType F);
103 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
104 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
106 // An explicit operator bool so that we can do testing of DI values
108 // FIXME: This operator bool isn't actually protecting anything at the
109 // moment due to the conversion operator above making DIDescriptor nodes
110 // implicitly convertable to bool.
111 LLVM_EXPLICIT operator bool() const { return DbgNode != 0; }
113 bool operator==(DIDescriptor Other) const {
114 return DbgNode == Other.DbgNode;
116 bool operator!=(DIDescriptor Other) const {
117 return !operator==(Other);
120 unsigned getTag() const {
121 return getUnsignedField(0) & ~LLVMDebugVersionMask;
124 bool isDerivedType() const;
125 bool isCompositeType() const;
126 bool isBasicType() const;
127 bool isVariable() const;
128 bool isSubprogram() const;
129 bool isGlobalVariable() const;
130 bool isScope() const;
132 bool isCompileUnit() const;
133 bool isNameSpace() const;
134 bool isLexicalBlockFile() const;
135 bool isLexicalBlock() const;
136 bool isSubrange() const;
137 bool isEnumerator() const;
139 bool isGlobal() const;
140 bool isUnspecifiedParameter() const;
141 bool isTemplateTypeParameter() const;
142 bool isTemplateValueParameter() const;
143 bool isObjCProperty() const;
144 bool isImportedEntity() const;
146 /// print - print descriptor.
147 void print(raw_ostream &OS) const;
149 /// dump - print descriptor to dbgs() with a newline.
153 /// DISubrange - This is used to represent ranges, for array bounds.
154 class DISubrange : public DIDescriptor {
155 friend class DIDescriptor;
156 void printInternal(raw_ostream &OS) const;
158 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
160 int64_t getLo() const { return getInt64Field(1); }
161 int64_t getCount() const { return getInt64Field(2); }
165 /// DIArray - This descriptor holds an array of descriptors.
166 class DIArray : public DIDescriptor {
168 explicit DIArray(const MDNode *N = 0)
171 unsigned getNumElements() const;
172 DIDescriptor getElement(unsigned Idx) const {
173 return getDescriptorField(Idx);
177 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
178 /// FIXME: it seems strange that this doesn't have either a reference to the
179 /// type/precision or a file/line pair for location info.
180 class DIEnumerator : public DIDescriptor {
181 friend class DIDescriptor;
182 void printInternal(raw_ostream &OS) const;
184 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
186 StringRef getName() const { return getStringField(1); }
187 int64_t getEnumValue() const { return getInt64Field(2); }
191 /// DIScope - A base class for various scopes.
192 class DIScope : public DIDescriptor {
194 friend class DIDescriptor;
195 void printInternal(raw_ostream &OS) const;
197 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
199 StringRef getFilename() const;
200 StringRef getDirectory() const;
203 /// DIType - This is a wrapper for a type.
204 /// FIXME: Types should be factored much better so that CV qualifiers and
205 /// others do not require a huge and empty descriptor full of zeros.
206 class DIType : public DIScope {
208 friend class DIDescriptor;
209 void printInternal(raw_ostream &OS) const;
212 DIType(const MDNode *N = 0) : DIScope(N) {}
214 /// Verify - Verify that a type descriptor is well formed.
217 DIScope getContext() const { return getFieldAs<DIScope>(2); }
218 StringRef getName() const { return getStringField(3); }
219 unsigned getLineNumber() const { return getUnsignedField(4); }
220 uint64_t getSizeInBits() const { return getUInt64Field(5); }
221 uint64_t getAlignInBits() const { return getUInt64Field(6); }
222 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
223 // carry this is just plain insane.
224 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
225 unsigned getFlags() const { return getUnsignedField(8); }
226 bool isPrivate() const {
227 return (getFlags() & FlagPrivate) != 0;
229 bool isProtected() const {
230 return (getFlags() & FlagProtected) != 0;
232 bool isForwardDecl() const {
233 return (getFlags() & FlagFwdDecl) != 0;
235 // isAppleBlock - Return true if this is the Apple Blocks extension.
236 bool isAppleBlockExtension() const {
237 return (getFlags() & FlagAppleBlock) != 0;
239 bool isBlockByrefStruct() const {
240 return (getFlags() & FlagBlockByrefStruct) != 0;
242 bool isVirtual() const {
243 return (getFlags() & FlagVirtual) != 0;
245 bool isArtificial() const {
246 return (getFlags() & FlagArtificial) != 0;
248 bool isObjectPointer() const {
249 return (getFlags() & FlagObjectPointer) != 0;
251 bool isObjcClassComplete() const {
252 return (getFlags() & FlagObjcClassComplete) != 0;
254 bool isVector() const {
255 return (getFlags() & FlagVector) != 0;
257 bool isStaticMember() const {
258 return (getFlags() & FlagStaticMember) != 0;
260 bool isValid() const {
261 return DbgNode && isType();
264 /// isUnsignedDIType - Return true if type encoding is unsigned.
265 bool isUnsignedDIType();
267 /// replaceAllUsesWith - Replace all uses of debug info referenced by
269 void replaceAllUsesWith(DIDescriptor &D);
270 void replaceAllUsesWith(MDNode *D);
273 /// DIBasicType - A basic type, like 'int' or 'float'.
274 class DIBasicType : public DIType {
276 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
278 unsigned getEncoding() const { return getUnsignedField(9); }
280 /// Verify - Verify that a basic type descriptor is well formed.
284 /// DIDerivedType - A simple derived type, like a const qualified type,
285 /// a typedef, a pointer or reference, et cetera. Or, a data member of
286 /// a class/struct/union.
287 class DIDerivedType : public DIType {
288 friend class DIDescriptor;
289 void printInternal(raw_ostream &OS) const;
292 explicit DIDerivedType(const MDNode *N = 0)
295 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
297 /// getOriginalTypeSize - If this type is derived from a base type then
298 /// return base type size.
299 uint64_t getOriginalTypeSize() const;
301 /// getObjCProperty - Return property node, if this ivar is
302 /// associated with one.
303 MDNode *getObjCProperty() const;
305 DIType getClassType() const {
306 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
307 return getFieldAs<DIType>(10);
310 Constant *getConstant() const {
311 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
312 return getConstantField(10);
315 /// Verify - Verify that a derived type descriptor is well formed.
319 /// DICompositeType - This descriptor holds a type that can refer to multiple
320 /// other types, like a function or struct.
321 /// DICompositeType is derived from DIDerivedType because some
322 /// composite types (such as enums) can be derived from basic types
323 // FIXME: Make this derive from DIType directly & just store the
324 // base type in a single DIType field.
325 class DICompositeType : public DIDerivedType {
326 friend class DIDescriptor;
327 void printInternal(raw_ostream &OS) const;
329 explicit DICompositeType(const MDNode *N = 0)
330 : DIDerivedType(N) {}
332 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
333 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
334 unsigned getRunTimeLang() const { return getUnsignedField(11); }
335 DICompositeType getContainingType() const {
336 return getFieldAs<DICompositeType>(12);
338 void setContainingType(DICompositeType ContainingType);
339 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
341 /// Verify - Verify that a composite type descriptor is well formed.
345 /// DIFile - This is a wrapper for a file.
346 class DIFile : public DIScope {
347 friend class DIDescriptor;
349 explicit DIFile(const MDNode *N = 0) : DIScope(N) {}
350 MDNode *getFileNode() const;
354 /// DICompileUnit - A wrapper for a compile unit.
355 class DICompileUnit : public DIScope {
356 friend class DIDescriptor;
357 void printInternal(raw_ostream &OS) const;
359 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
361 unsigned getLanguage() const { return getUnsignedField(2); }
362 StringRef getProducer() const { return getStringField(3); }
364 bool isOptimized() const { return getUnsignedField(4) != 0; }
365 StringRef getFlags() const { return getStringField(5); }
366 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
368 DIArray getEnumTypes() const;
369 DIArray getRetainedTypes() const;
370 DIArray getSubprograms() const;
371 DIArray getGlobalVariables() const;
372 DIArray getImportedEntities() const;
374 StringRef getSplitDebugFilename() const { return getStringField(12); }
376 /// Verify - Verify that a compile unit is well formed.
380 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
381 class DISubprogram : public DIScope {
382 friend class DIDescriptor;
383 void printInternal(raw_ostream &OS) const;
385 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
387 DIScope getContext() const { return getFieldAs<DIScope>(2); }
388 StringRef getName() const { return getStringField(3); }
389 StringRef getDisplayName() const { return getStringField(4); }
390 StringRef getLinkageName() const { return getStringField(5); }
391 unsigned getLineNumber() const { return getUnsignedField(6); }
392 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
394 /// isLocalToUnit - Return true if this subprogram is local to the current
395 /// compile unit, like 'static' in C.
396 unsigned isLocalToUnit() const { return getUnsignedField(8); }
397 unsigned isDefinition() const { return getUnsignedField(9); }
399 unsigned getVirtuality() const { return getUnsignedField(10); }
400 unsigned getVirtualIndex() const { return getUnsignedField(11); }
402 DICompositeType getContainingType() const {
403 return getFieldAs<DICompositeType>(12);
406 unsigned getFlags() const {
407 return getUnsignedField(13);
410 unsigned isArtificial() const {
411 return (getUnsignedField(13) & FlagArtificial) != 0;
413 /// isPrivate - Return true if this subprogram has "private"
414 /// access specifier.
415 bool isPrivate() const {
416 return (getUnsignedField(13) & FlagPrivate) != 0;
418 /// isProtected - Return true if this subprogram has "protected"
419 /// access specifier.
420 bool isProtected() const {
421 return (getUnsignedField(13) & FlagProtected) != 0;
423 /// isExplicit - Return true if this subprogram is marked as explicit.
424 bool isExplicit() const {
425 return (getUnsignedField(13) & FlagExplicit) != 0;
427 /// isPrototyped - Return true if this subprogram is prototyped.
428 bool isPrototyped() const {
429 return (getUnsignedField(13) & FlagPrototyped) != 0;
432 unsigned isOptimized() const;
434 /// Verify - Verify that a subprogram descriptor is well formed.
437 /// describes - Return true if this subprogram provides debugging
438 /// information for the function F.
439 bool describes(const Function *F);
441 Function *getFunction() const { return getFunctionField(15); }
442 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
443 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
444 DISubprogram getFunctionDeclaration() const {
445 return getFieldAs<DISubprogram>(17);
447 MDNode *getVariablesNodes() const;
448 DIArray getVariables() const;
450 /// getScopeLineNumber - Get the beginning of the scope of the
451 /// function, not necessarily where the name of the program
453 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
456 /// DILexicalBlock - This is a wrapper for a lexical block.
457 class DILexicalBlock : public DIScope {
459 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
460 DIScope getContext() const { return getFieldAs<DIScope>(2); }
461 unsigned getLineNumber() const { return getUnsignedField(3); }
462 unsigned getColumnNumber() const { return getUnsignedField(4); }
466 /// DILexicalBlockFile - This is a wrapper for a lexical block with
467 /// a filename change.
468 class DILexicalBlockFile : public DIScope {
470 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
471 DIScope getContext() const {
472 if (getScope().isSubprogram())
474 return getScope().getContext();
476 unsigned getLineNumber() const { return getScope().getLineNumber(); }
477 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
478 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
482 /// DINameSpace - A wrapper for a C++ style name space.
483 class DINameSpace : public DIScope {
484 friend class DIDescriptor;
485 void printInternal(raw_ostream &OS) const;
487 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
488 DIScope getContext() const { return getFieldAs<DIScope>(2); }
489 StringRef getName() const { return getStringField(3); }
490 unsigned getLineNumber() const { return getUnsignedField(4); }
494 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
495 class DITemplateTypeParameter : public DIDescriptor {
497 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
499 DIScope getContext() const { return getFieldAs<DIScope>(1); }
500 StringRef getName() const { return getStringField(2); }
501 DIType getType() const { return getFieldAs<DIType>(3); }
502 StringRef getFilename() const {
503 return getFieldAs<DIFile>(4).getFilename();
505 StringRef getDirectory() const {
506 return getFieldAs<DIFile>(4).getDirectory();
508 unsigned getLineNumber() const { return getUnsignedField(5); }
509 unsigned getColumnNumber() const { return getUnsignedField(6); }
513 /// DITemplateValueParameter - This is a wrapper for template value parameter.
514 class DITemplateValueParameter : public DIDescriptor {
516 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
518 DIScope getContext() const { return getFieldAs<DIScope>(1); }
519 StringRef getName() const { return getStringField(2); }
520 DIType getType() const { return getFieldAs<DIType>(3); }
521 Value *getValue() const;
522 StringRef getFilename() const {
523 return getFieldAs<DIFile>(5).getFilename();
525 StringRef getDirectory() const {
526 return getFieldAs<DIFile>(5).getDirectory();
528 unsigned getLineNumber() const { return getUnsignedField(6); }
529 unsigned getColumnNumber() const { return getUnsignedField(7); }
533 /// DIGlobalVariable - This is a wrapper for a global variable.
534 class DIGlobalVariable : public DIDescriptor {
535 friend class DIDescriptor;
536 void printInternal(raw_ostream &OS) const;
538 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
540 DIScope getContext() const { return getFieldAs<DIScope>(2); }
541 StringRef getName() const { return getStringField(3); }
542 StringRef getDisplayName() const { return getStringField(4); }
543 StringRef getLinkageName() const { return getStringField(5); }
544 StringRef getFilename() const {
545 return getFieldAs<DIFile>(6).getFilename();
547 StringRef getDirectory() const {
548 return getFieldAs<DIFile>(6).getDirectory();
552 unsigned getLineNumber() const { return getUnsignedField(7); }
553 DIType getType() const { return getFieldAs<DIType>(8); }
554 unsigned isLocalToUnit() const { return getUnsignedField(9); }
555 unsigned isDefinition() const { return getUnsignedField(10); }
557 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
558 Constant *getConstant() const { return getConstantField(11); }
559 DIDerivedType getStaticDataMemberDeclaration() const {
560 return getFieldAs<DIDerivedType>(12);
563 /// Verify - Verify that a global variable descriptor is well formed.
567 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
569 class DIVariable : public DIDescriptor {
570 friend class DIDescriptor;
571 void printInternal(raw_ostream &OS) const;
573 explicit DIVariable(const MDNode *N = 0)
576 DIScope getContext() const { return getFieldAs<DIScope>(1); }
577 StringRef getName() const { return getStringField(2); }
578 DIFile getFile() const { return getFieldAs<DIFile>(3); }
579 unsigned getLineNumber() const {
580 return (getUnsignedField(4) << 8) >> 8;
582 unsigned getArgNumber() const {
583 unsigned L = getUnsignedField(4);
586 DIType getType() const { return getFieldAs<DIType>(5); }
588 /// isArtificial - Return true if this variable is marked as "artificial".
589 bool isArtificial() const {
590 return (getUnsignedField(6) & FlagArtificial) != 0;
593 bool isObjectPointer() const {
594 return (getUnsignedField(6) & FlagObjectPointer) != 0;
597 /// \brief Return true if this variable is represented as a pointer.
598 bool isIndirect() const {
599 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
602 /// getInlinedAt - If this variable is inlined then return inline location.
603 MDNode *getInlinedAt() const;
605 /// Verify - Verify that a variable descriptor is well formed.
608 /// HasComplexAddr - Return true if the variable has a complex address.
609 bool hasComplexAddress() const {
610 return getNumAddrElements() > 0;
613 unsigned getNumAddrElements() const;
615 uint64_t getAddrElement(unsigned Idx) const {
616 return getUInt64Field(Idx+8);
619 /// isBlockByrefVariable - Return true if the variable was declared as
620 /// a "__block" variable (Apple Blocks).
621 bool isBlockByrefVariable() const {
622 return getType().isBlockByrefStruct();
625 /// isInlinedFnArgument - Return true if this variable provides debugging
626 /// information for an inlined function arguments.
627 bool isInlinedFnArgument(const Function *CurFn);
629 void printExtendedName(raw_ostream &OS) const;
632 /// DILocation - This object holds location information. This object
633 /// is not associated with any DWARF tag.
634 class DILocation : public DIDescriptor {
636 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
638 unsigned getLineNumber() const { return getUnsignedField(0); }
639 unsigned getColumnNumber() const { return getUnsignedField(1); }
640 DIScope getScope() const { return getFieldAs<DIScope>(2); }
641 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
642 StringRef getFilename() const { return getScope().getFilename(); }
643 StringRef getDirectory() const { return getScope().getDirectory(); }
647 class DIObjCProperty : public DIDescriptor {
648 friend class DIDescriptor;
649 void printInternal(raw_ostream &OS) const;
651 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
653 StringRef getObjCPropertyName() const { return getStringField(1); }
654 DIFile getFile() const { return getFieldAs<DIFile>(2); }
655 unsigned getLineNumber() const { return getUnsignedField(3); }
657 StringRef getObjCPropertyGetterName() const {
658 return getStringField(4);
660 StringRef getObjCPropertySetterName() const {
661 return getStringField(5);
663 bool isReadOnlyObjCProperty() const {
664 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
666 bool isReadWriteObjCProperty() const {
667 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
669 bool isAssignObjCProperty() const {
670 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
672 bool isRetainObjCProperty() const {
673 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
675 bool isCopyObjCProperty() const {
676 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
678 bool isNonAtomicObjCProperty() const {
679 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
682 DIType getType() const { return getFieldAs<DIType>(7); }
684 /// Verify - Verify that a derived type descriptor is well formed.
688 /// \brief An imported module (C++ using directive or similar).
689 class DIImportedEntity : public DIDescriptor {
690 friend class DIDescriptor;
691 void printInternal(raw_ostream &OS) const;
693 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
694 DIScope getContext() const { return getFieldAs<DIScope>(1); }
695 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
696 unsigned getLineNumber() const { return getUnsignedField(3); }
697 StringRef getName() const { return getStringField(4); }
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 /// DebugInfoFinder tries to list all debug info MDNodes in a module. To
730 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
731 /// processDeclare and processValue. processModule will go through
732 /// all DICompileUnits and list debug info MDNodes used by the CUs.
733 class DebugInfoFinder {
735 /// processModule - Process entire module and collect debug info
737 void processModule(const Module &M);
739 /// processDeclare - Process DbgDeclareInst.
740 void processDeclare(const DbgDeclareInst *DDI);
741 /// Process DbgValueInst.
742 void processValue(const DbgValueInst *DVI);
747 /// processType - Process DIType.
748 void processType(DIType DT);
750 /// processLexicalBlock - Process DILexicalBlock.
751 void processLexicalBlock(DILexicalBlock LB);
753 /// processSubprogram - Process DISubprogram.
754 void processSubprogram(DISubprogram SP);
756 /// processLocation - Process DILocation.
757 void processLocation(DILocation Loc);
759 void processScope(DIScope Scope);
761 /// addCompileUnit - Add compile unit into CUs.
762 bool addCompileUnit(DICompileUnit CU);
764 /// addGlobalVariable - Add global variable into GVs.
765 bool addGlobalVariable(DIGlobalVariable DIG);
767 // addSubprogram - Add subprogram into SPs.
768 bool addSubprogram(DISubprogram SP);
770 /// addType - Add type into Tys.
771 bool addType(DIType DT);
773 bool addScope(DIScope Scope);
776 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
777 iterator compile_unit_begin() const { return CUs.begin(); }
778 iterator compile_unit_end() const { return CUs.end(); }
779 iterator subprogram_begin() const { return SPs.begin(); }
780 iterator subprogram_end() const { return SPs.end(); }
781 iterator global_variable_begin() const { return GVs.begin(); }
782 iterator global_variable_end() const { return GVs.end(); }
783 iterator type_begin() const { return TYs.begin(); }
784 iterator type_end() const { return TYs.end(); }
785 iterator scope_begin() const { return Scopes.begin(); }
786 iterator scope_end() const { return Scopes.end(); }
788 unsigned compile_unit_count() const { return CUs.size(); }
789 unsigned global_variable_count() const { return GVs.size(); }
790 unsigned subprogram_count() const { return SPs.size(); }
791 unsigned type_count() const { return TYs.size(); }
792 unsigned scope_count() const { return Scopes.size(); }
795 SmallVector<MDNode *, 8> CUs; // Compile Units
796 SmallVector<MDNode *, 8> SPs; // Subprograms
797 SmallVector<MDNode *, 8> GVs; // Global Variables;
798 SmallVector<MDNode *, 8> TYs; // Types
799 SmallVector<MDNode *, 8> Scopes; // Scopes
800 SmallPtrSet<MDNode *, 64> NodesSeen;
802 } // end namespace llvm