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 isGlobal() const;
133 bool isUnspecifiedParameter() const;
134 bool isTemplateTypeParameter() const;
135 bool isTemplateValueParameter() const;
136 bool isObjCProperty() const;
137 bool isImportedEntity() const;
139 /// print - print descriptor.
140 void print(raw_ostream &OS) const;
142 /// dump - print descriptor to dbgs() with a newline.
146 /// DISubrange - This is used to represent ranges, for array bounds.
147 class DISubrange : public DIDescriptor {
148 friend class DIDescriptor;
149 void printInternal(raw_ostream &OS) const;
151 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
153 int64_t getLo() const { return getInt64Field(1); }
154 int64_t getCount() const { return getInt64Field(2); }
158 /// DIArray - This descriptor holds an array of descriptors.
159 class DIArray : public DIDescriptor {
161 explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {}
163 unsigned getNumElements() const;
164 DIDescriptor getElement(unsigned Idx) const {
165 return getDescriptorField(Idx);
169 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
170 /// FIXME: it seems strange that this doesn't have either a reference to the
171 /// type/precision or a file/line pair for location info.
172 class DIEnumerator : public DIDescriptor {
173 friend class DIDescriptor;
174 void printInternal(raw_ostream &OS) const;
176 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
178 StringRef getName() const { return getStringField(1); }
179 int64_t getEnumValue() const { return getInt64Field(2); }
183 /// DIScope - A base class for various scopes.
184 class DIScope : public DIDescriptor {
186 friend class DIDescriptor;
187 void printInternal(raw_ostream &OS) const;
189 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
191 StringRef getFilename() const;
192 StringRef getDirectory() const;
195 /// DIType - This is a wrapper for a type.
196 /// FIXME: Types should be factored much better so that CV qualifiers and
197 /// others do not require a huge and empty descriptor full of zeros.
198 class DIType : public DIScope {
200 friend class DIDescriptor;
201 void printInternal(raw_ostream &OS) const;
204 DIType(const MDNode *N = 0) : DIScope(N) {}
206 /// Verify - Verify that a type descriptor is well formed.
209 DIScope getContext() const { return getFieldAs<DIScope>(2); }
210 StringRef getName() const { return getStringField(3); }
211 unsigned getLineNumber() const { return getUnsignedField(4); }
212 uint64_t getSizeInBits() const { return getUInt64Field(5); }
213 uint64_t getAlignInBits() const { return getUInt64Field(6); }
214 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
215 // carry this is just plain insane.
216 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
217 unsigned getFlags() const { return getUnsignedField(8); }
218 bool isPrivate() const {
219 return (getFlags() & FlagPrivate) != 0;
221 bool isProtected() const {
222 return (getFlags() & FlagProtected) != 0;
224 bool isForwardDecl() const {
225 return (getFlags() & FlagFwdDecl) != 0;
227 // isAppleBlock - Return true if this is the Apple Blocks extension.
228 bool isAppleBlockExtension() const {
229 return (getFlags() & FlagAppleBlock) != 0;
231 bool isBlockByrefStruct() const {
232 return (getFlags() & FlagBlockByrefStruct) != 0;
234 bool isVirtual() const {
235 return (getFlags() & FlagVirtual) != 0;
237 bool isArtificial() const {
238 return (getFlags() & FlagArtificial) != 0;
240 bool isObjectPointer() const {
241 return (getFlags() & FlagObjectPointer) != 0;
243 bool isObjcClassComplete() const {
244 return (getFlags() & FlagObjcClassComplete) != 0;
246 bool isVector() const {
247 return (getFlags() & FlagVector) != 0;
249 bool isStaticMember() const {
250 return (getFlags() & FlagStaticMember) != 0;
252 bool isValid() const {
253 return DbgNode && isType();
256 /// isUnsignedDIType - Return true if type encoding is unsigned.
257 bool isUnsignedDIType();
259 /// replaceAllUsesWith - Replace all uses of debug info referenced by
261 void replaceAllUsesWith(DIDescriptor &D);
262 void replaceAllUsesWith(MDNode *D);
265 /// DIBasicType - A basic type, like 'int' or 'float'.
266 class DIBasicType : public DIType {
268 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
270 unsigned getEncoding() const { return getUnsignedField(9); }
272 /// Verify - Verify that a basic type descriptor is well formed.
276 /// DIDerivedType - A simple derived type, like a const qualified type,
277 /// a typedef, a pointer or reference, et cetera. Or, a data member of
278 /// a class/struct/union.
279 class DIDerivedType : public DIType {
280 friend class DIDescriptor;
281 void printInternal(raw_ostream &OS) const;
284 explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {}
286 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
288 /// getOriginalTypeSize - If this type is derived from a base type then
289 /// return base type size.
290 uint64_t getOriginalTypeSize() const;
292 /// getObjCProperty - Return property node, if this ivar is
293 /// associated with one.
294 MDNode *getObjCProperty() const;
296 DIType getClassType() const {
297 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
298 return getFieldAs<DIType>(10);
301 Constant *getConstant() const {
302 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
303 return getConstantField(10);
306 /// Verify - Verify that a derived type descriptor is well formed.
310 /// DICompositeType - This descriptor holds a type that can refer to multiple
311 /// other types, like a function or struct.
312 /// DICompositeType is derived from DIDerivedType because some
313 /// composite types (such as enums) can be derived from basic types
314 // FIXME: Make this derive from DIType directly & just store the
315 // base type in a single DIType field.
316 class DICompositeType : public DIDerivedType {
317 friend class DIDescriptor;
318 void printInternal(raw_ostream &OS) const;
320 explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {}
322 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
323 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
324 unsigned getRunTimeLang() const { return getUnsignedField(11); }
325 DICompositeType getContainingType() const {
326 return getFieldAs<DICompositeType>(12);
328 void setContainingType(DICompositeType ContainingType);
329 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
331 /// Verify - Verify that a composite type descriptor is well formed.
335 /// DIFile - This is a wrapper for a file.
336 class DIFile : public DIScope {
337 friend class DIDescriptor;
339 explicit DIFile(const MDNode *N = 0) : DIScope(N) {}
340 MDNode *getFileNode() const;
344 /// DICompileUnit - A wrapper for a compile unit.
345 class DICompileUnit : public DIScope {
346 friend class DIDescriptor;
347 void printInternal(raw_ostream &OS) const;
349 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
351 unsigned getLanguage() const { return getUnsignedField(2); }
352 StringRef getProducer() const { return getStringField(3); }
354 bool isOptimized() const { return getUnsignedField(4) != 0; }
355 StringRef getFlags() const { return getStringField(5); }
356 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
358 DIArray getEnumTypes() const;
359 DIArray getRetainedTypes() const;
360 DIArray getSubprograms() const;
361 DIArray getGlobalVariables() const;
362 DIArray getImportedEntities() const;
364 StringRef getSplitDebugFilename() const { return getStringField(12); }
366 /// Verify - Verify that a compile unit is well formed.
370 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
371 class DISubprogram : public DIScope {
372 friend class DIDescriptor;
373 void printInternal(raw_ostream &OS) const;
375 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
377 DIScope getContext() const { return getFieldAs<DIScope>(2); }
378 StringRef getName() const { return getStringField(3); }
379 StringRef getDisplayName() const { return getStringField(4); }
380 StringRef getLinkageName() const { return getStringField(5); }
381 unsigned getLineNumber() const { return getUnsignedField(6); }
382 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
384 /// isLocalToUnit - Return true if this subprogram is local to the current
385 /// compile unit, like 'static' in C.
386 unsigned isLocalToUnit() const { return getUnsignedField(8); }
387 unsigned isDefinition() const { return getUnsignedField(9); }
389 unsigned getVirtuality() const { return getUnsignedField(10); }
390 unsigned getVirtualIndex() const { return getUnsignedField(11); }
392 DICompositeType getContainingType() const {
393 return getFieldAs<DICompositeType>(12);
396 unsigned getFlags() const {
397 return getUnsignedField(13);
400 unsigned isArtificial() const {
401 return (getUnsignedField(13) & FlagArtificial) != 0;
403 /// isPrivate - Return true if this subprogram has "private"
404 /// access specifier.
405 bool isPrivate() const {
406 return (getUnsignedField(13) & FlagPrivate) != 0;
408 /// isProtected - Return true if this subprogram has "protected"
409 /// access specifier.
410 bool isProtected() const {
411 return (getUnsignedField(13) & FlagProtected) != 0;
413 /// isExplicit - Return true if this subprogram is marked as explicit.
414 bool isExplicit() const {
415 return (getUnsignedField(13) & FlagExplicit) != 0;
417 /// isPrototyped - Return true if this subprogram is prototyped.
418 bool isPrototyped() const {
419 return (getUnsignedField(13) & FlagPrototyped) != 0;
422 unsigned isOptimized() const;
424 /// Verify - Verify that a subprogram descriptor is well formed.
427 /// describes - Return true if this subprogram provides debugging
428 /// information for the function F.
429 bool describes(const Function *F);
431 Function *getFunction() const { return getFunctionField(15); }
432 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
433 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
434 DISubprogram getFunctionDeclaration() const {
435 return getFieldAs<DISubprogram>(17);
437 MDNode *getVariablesNodes() const;
438 DIArray getVariables() const;
440 /// getScopeLineNumber - Get the beginning of the scope of the
441 /// function, not necessarily where the name of the program
443 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
446 /// DILexicalBlock - This is a wrapper for a lexical block.
447 class DILexicalBlock : public DIScope {
449 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
450 DIScope getContext() const { return getFieldAs<DIScope>(2); }
451 unsigned getLineNumber() const { return getUnsignedField(3); }
452 unsigned getColumnNumber() const { return getUnsignedField(4); }
456 /// DILexicalBlockFile - This is a wrapper for a lexical block with
457 /// a filename change.
458 class DILexicalBlockFile : public DIScope {
460 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
461 DIScope getContext() const {
462 if (getScope().isSubprogram())
464 return getScope().getContext();
466 unsigned getLineNumber() const { return getScope().getLineNumber(); }
467 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
468 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
472 /// DINameSpace - A wrapper for a C++ style name space.
473 class DINameSpace : public DIScope {
474 friend class DIDescriptor;
475 void printInternal(raw_ostream &OS) const;
477 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
478 DIScope getContext() const { return getFieldAs<DIScope>(2); }
479 StringRef getName() const { return getStringField(3); }
480 unsigned getLineNumber() const { return getUnsignedField(4); }
484 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
485 class DITemplateTypeParameter : public DIDescriptor {
487 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
489 DIScope getContext() const { return getFieldAs<DIScope>(1); }
490 StringRef getName() const { return getStringField(2); }
491 DIType getType() const { return getFieldAs<DIType>(3); }
492 StringRef getFilename() const {
493 return getFieldAs<DIFile>(4).getFilename();
495 StringRef getDirectory() const {
496 return getFieldAs<DIFile>(4).getDirectory();
498 unsigned getLineNumber() const { return getUnsignedField(5); }
499 unsigned getColumnNumber() const { return getUnsignedField(6); }
503 /// DITemplateValueParameter - This is a wrapper for template value parameter.
504 class DITemplateValueParameter : public DIDescriptor {
506 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
508 DIScope getContext() const { return getFieldAs<DIScope>(1); }
509 StringRef getName() const { return getStringField(2); }
510 DIType getType() const { return getFieldAs<DIType>(3); }
511 Value *getValue() const;
512 StringRef getFilename() const {
513 return getFieldAs<DIFile>(5).getFilename();
515 StringRef getDirectory() const {
516 return getFieldAs<DIFile>(5).getDirectory();
518 unsigned getLineNumber() const { return getUnsignedField(6); }
519 unsigned getColumnNumber() const { return getUnsignedField(7); }
523 /// DIGlobalVariable - This is a wrapper for a global variable.
524 class DIGlobalVariable : public DIDescriptor {
525 friend class DIDescriptor;
526 void printInternal(raw_ostream &OS) const;
528 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
530 DIScope getContext() const { return getFieldAs<DIScope>(2); }
531 StringRef getName() const { return getStringField(3); }
532 StringRef getDisplayName() const { return getStringField(4); }
533 StringRef getLinkageName() const { return getStringField(5); }
534 StringRef getFilename() const {
535 return getFieldAs<DIFile>(6).getFilename();
537 StringRef getDirectory() const {
538 return getFieldAs<DIFile>(6).getDirectory();
542 unsigned getLineNumber() const { return getUnsignedField(7); }
543 DIType getType() const { return getFieldAs<DIType>(8); }
544 unsigned isLocalToUnit() const { return getUnsignedField(9); }
545 unsigned isDefinition() const { return getUnsignedField(10); }
547 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
548 Constant *getConstant() const { return getConstantField(11); }
549 DIDerivedType getStaticDataMemberDeclaration() const {
550 return getFieldAs<DIDerivedType>(12);
553 /// Verify - Verify that a global variable descriptor is well formed.
557 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
559 class DIVariable : public DIDescriptor {
560 friend class DIDescriptor;
561 void printInternal(raw_ostream &OS) const;
563 explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {}
565 DIScope getContext() const { return getFieldAs<DIScope>(1); }
566 StringRef getName() const { return getStringField(2); }
567 DIFile getFile() const { return getFieldAs<DIFile>(3); }
568 unsigned getLineNumber() const {
569 return (getUnsignedField(4) << 8) >> 8;
571 unsigned getArgNumber() const {
572 unsigned L = getUnsignedField(4);
575 DIType getType() const { return getFieldAs<DIType>(5); }
577 /// isArtificial - Return true if this variable is marked as "artificial".
578 bool isArtificial() const {
579 return (getUnsignedField(6) & FlagArtificial) != 0;
582 bool isObjectPointer() const {
583 return (getUnsignedField(6) & FlagObjectPointer) != 0;
586 /// \brief Return true if this variable is represented as a pointer.
587 bool isIndirect() const {
588 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
591 /// getInlinedAt - If this variable is inlined then return inline location.
592 MDNode *getInlinedAt() const;
594 /// Verify - Verify that a variable descriptor is well formed.
597 /// HasComplexAddr - Return true if the variable has a complex address.
598 bool hasComplexAddress() const {
599 return getNumAddrElements() > 0;
602 unsigned getNumAddrElements() const;
604 uint64_t getAddrElement(unsigned Idx) const {
605 return getUInt64Field(Idx+8);
608 /// isBlockByrefVariable - Return true if the variable was declared as
609 /// a "__block" variable (Apple Blocks).
610 bool isBlockByrefVariable() const {
611 return getType().isBlockByrefStruct();
614 /// isInlinedFnArgument - Return true if this variable provides debugging
615 /// information for an inlined function arguments.
616 bool isInlinedFnArgument(const Function *CurFn);
618 void printExtendedName(raw_ostream &OS) const;
621 /// DILocation - This object holds location information. This object
622 /// is not associated with any DWARF tag.
623 class DILocation : public DIDescriptor {
625 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
627 unsigned getLineNumber() const { return getUnsignedField(0); }
628 unsigned getColumnNumber() const { return getUnsignedField(1); }
629 DIScope getScope() const { return getFieldAs<DIScope>(2); }
630 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
631 StringRef getFilename() const { return getScope().getFilename(); }
632 StringRef getDirectory() const { return getScope().getDirectory(); }
636 class DIObjCProperty : public DIDescriptor {
637 friend class DIDescriptor;
638 void printInternal(raw_ostream &OS) const;
640 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
642 StringRef getObjCPropertyName() const { return getStringField(1); }
643 DIFile getFile() const { return getFieldAs<DIFile>(2); }
644 unsigned getLineNumber() const { return getUnsignedField(3); }
646 StringRef getObjCPropertyGetterName() const {
647 return getStringField(4);
649 StringRef getObjCPropertySetterName() const {
650 return getStringField(5);
652 bool isReadOnlyObjCProperty() const {
653 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
655 bool isReadWriteObjCProperty() const {
656 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
658 bool isAssignObjCProperty() const {
659 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
661 bool isRetainObjCProperty() const {
662 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
664 bool isCopyObjCProperty() const {
665 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
667 bool isNonAtomicObjCProperty() const {
668 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
671 DIType getType() const { return getFieldAs<DIType>(7); }
673 /// Verify - Verify that a derived type descriptor is well formed.
677 /// \brief An imported module (C++ using directive or similar).
678 class DIImportedEntity : public DIDescriptor {
679 friend class DIDescriptor;
680 void printInternal(raw_ostream &OS) const;
682 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
683 DIScope getContext() const { return getFieldAs<DIScope>(1); }
684 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
685 unsigned getLineNumber() const { return getUnsignedField(3); }
686 StringRef getName() const { return getStringField(4); }
690 /// getDISubprogram - Find subprogram that is enclosing this scope.
691 DISubprogram getDISubprogram(const MDNode *Scope);
693 /// getDICompositeType - Find underlying composite type.
694 DICompositeType getDICompositeType(DIType T);
696 /// isSubprogramContext - Return true if Context is either a subprogram
697 /// or another context nested inside a subprogram.
698 bool isSubprogramContext(const MDNode *Context);
700 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
701 /// to hold function specific information.
702 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
704 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
705 /// suitable to hold function specific information.
706 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
708 /// createInlinedVariable - Create a new inlined variable based on current
710 /// @param DV Current Variable.
711 /// @param InlinedScope Location at current variable is inlined.
712 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
713 LLVMContext &VMContext);
715 /// cleanseInlinedVariable - Remove inlined scope from the variable.
716 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
718 /// DebugInfoFinder tries to list all debug info MDNodes in a module. To
719 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
720 /// processDeclare and processValue. processModule will go through
721 /// all DICompileUnits and list debug info MDNodes used by the CUs.
722 class DebugInfoFinder {
724 /// processModule - Process entire module and collect debug info
726 void processModule(const Module &M);
728 /// processDeclare - Process DbgDeclareInst.
729 void processDeclare(const DbgDeclareInst *DDI);
730 /// Process DbgValueInst.
731 void processValue(const DbgValueInst *DVI);
736 /// processType - Process DIType.
737 void processType(DIType DT);
739 /// processLexicalBlock - Process DILexicalBlock.
740 void processLexicalBlock(DILexicalBlock LB);
742 /// processSubprogram - Process DISubprogram.
743 void processSubprogram(DISubprogram SP);
745 /// processLocation - Process DILocation.
746 void processLocation(DILocation Loc);
748 void processScope(DIScope Scope);
750 /// addCompileUnit - Add compile unit into CUs.
751 bool addCompileUnit(DICompileUnit CU);
753 /// addGlobalVariable - Add global variable into GVs.
754 bool addGlobalVariable(DIGlobalVariable DIG);
756 // addSubprogram - Add subprogram into SPs.
757 bool addSubprogram(DISubprogram SP);
759 /// addType - Add type into Tys.
760 bool addType(DIType DT);
762 bool addScope(DIScope Scope);
765 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
766 iterator compile_unit_begin() const { return CUs.begin(); }
767 iterator compile_unit_end() const { return CUs.end(); }
768 iterator subprogram_begin() const { return SPs.begin(); }
769 iterator subprogram_end() const { return SPs.end(); }
770 iterator global_variable_begin() const { return GVs.begin(); }
771 iterator global_variable_end() const { return GVs.end(); }
772 iterator type_begin() const { return TYs.begin(); }
773 iterator type_end() const { return TYs.end(); }
774 iterator scope_begin() const { return Scopes.begin(); }
775 iterator scope_end() const { return Scopes.end(); }
777 unsigned compile_unit_count() const { return CUs.size(); }
778 unsigned global_variable_count() const { return GVs.size(); }
779 unsigned subprogram_count() const { return SPs.size(); }
780 unsigned type_count() const { return TYs.size(); }
781 unsigned scope_count() const { return Scopes.size(); }
784 SmallVector<MDNode *, 8> CUs; // Compile Units
785 SmallVector<MDNode *, 8> SPs; // Subprograms
786 SmallVector<MDNode *, 8> GVs; // Global Variables;
787 SmallVector<MDNode *, 8> TYs; // Types
788 SmallVector<MDNode *, 8> Scopes; // Scopes
789 SmallPtrSet<MDNode *, 64> NodesSeen;
791 } // end namespace llvm