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 StringRef getFilename() const;
191 StringRef getDirectory() const;
194 /// DIType - This is a wrapper for a type.
195 /// FIXME: Types should be factored much better so that CV qualifiers and
196 /// others do not require a huge and empty descriptor full of zeros.
197 class DIType : public DIScope {
199 friend class DIDescriptor;
200 void printInternal(raw_ostream &OS) const;
203 DIType(const MDNode *N = 0) : DIScope(N) {}
205 /// Verify - Verify that a type descriptor is well formed.
208 DIScope getContext() const { return getFieldAs<DIScope>(2); }
209 StringRef getName() const { return getStringField(3); }
210 unsigned getLineNumber() const { return getUnsignedField(4); }
211 uint64_t getSizeInBits() const { return getUInt64Field(5); }
212 uint64_t getAlignInBits() const { return getUInt64Field(6); }
213 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
214 // carry this is just plain insane.
215 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
216 unsigned getFlags() const { return getUnsignedField(8); }
217 bool isPrivate() const {
218 return (getFlags() & FlagPrivate) != 0;
220 bool isProtected() const {
221 return (getFlags() & FlagProtected) != 0;
223 bool isForwardDecl() const {
224 return (getFlags() & FlagFwdDecl) != 0;
226 // isAppleBlock - Return true if this is the Apple Blocks extension.
227 bool isAppleBlockExtension() const {
228 return (getFlags() & FlagAppleBlock) != 0;
230 bool isBlockByrefStruct() const {
231 return (getFlags() & FlagBlockByrefStruct) != 0;
233 bool isVirtual() const {
234 return (getFlags() & FlagVirtual) != 0;
236 bool isArtificial() const {
237 return (getFlags() & FlagArtificial) != 0;
239 bool isObjectPointer() const {
240 return (getFlags() & FlagObjectPointer) != 0;
242 bool isObjcClassComplete() const {
243 return (getFlags() & FlagObjcClassComplete) != 0;
245 bool isVector() const {
246 return (getFlags() & FlagVector) != 0;
248 bool isStaticMember() const {
249 return (getFlags() & FlagStaticMember) != 0;
251 bool isValid() const {
252 return DbgNode && isType();
255 /// isUnsignedDIType - Return true if type encoding is unsigned.
256 bool isUnsignedDIType();
258 /// replaceAllUsesWith - Replace all uses of debug info referenced by
260 void replaceAllUsesWith(DIDescriptor &D);
261 void replaceAllUsesWith(MDNode *D);
264 /// DIBasicType - A basic type, like 'int' or 'float'.
265 class DIBasicType : public DIType {
267 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
269 unsigned getEncoding() const { return getUnsignedField(9); }
271 /// Verify - Verify that a basic type descriptor is well formed.
275 /// DIDerivedType - A simple derived type, like a const qualified type,
276 /// a typedef, a pointer or reference, et cetera. Or, a data member of
277 /// a class/struct/union.
278 class DIDerivedType : public DIType {
279 friend class DIDescriptor;
280 void printInternal(raw_ostream &OS) const;
283 explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {}
285 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
287 /// getOriginalTypeSize - If this type is derived from a base type then
288 /// return base type size.
289 uint64_t getOriginalTypeSize() const;
291 /// getObjCProperty - Return property node, if this ivar is
292 /// associated with one.
293 MDNode *getObjCProperty() const;
295 DIType getClassType() const {
296 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
297 return getFieldAs<DIType>(10);
300 Constant *getConstant() const {
301 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
302 return getConstantField(10);
305 /// Verify - Verify that a derived type descriptor is well formed.
309 /// DICompositeType - This descriptor holds a type that can refer to multiple
310 /// other types, like a function or struct.
311 /// DICompositeType is derived from DIDerivedType because some
312 /// composite types (such as enums) can be derived from basic types
313 // FIXME: Make this derive from DIType directly & just store the
314 // base type in a single DIType field.
315 class DICompositeType : public DIDerivedType {
316 friend class DIDescriptor;
317 void printInternal(raw_ostream &OS) const;
319 explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {}
321 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
322 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
323 unsigned getRunTimeLang() const { return getUnsignedField(11); }
324 DICompositeType getContainingType() const {
325 return getFieldAs<DICompositeType>(12);
327 void setContainingType(DICompositeType ContainingType);
328 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
330 /// Verify - Verify that a composite type descriptor is well formed.
334 /// DIFile - This is a wrapper for a file.
335 class DIFile : public DIScope {
336 friend class DIDescriptor;
338 explicit DIFile(const MDNode *N = 0) : DIScope(N) {}
339 MDNode *getFileNode() const;
343 /// DICompileUnit - A wrapper for a compile unit.
344 class DICompileUnit : public DIScope {
345 friend class DIDescriptor;
346 void printInternal(raw_ostream &OS) const;
348 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
350 unsigned getLanguage() const { return getUnsignedField(2); }
351 StringRef getProducer() const { return getStringField(3); }
353 bool isOptimized() const { return getUnsignedField(4) != 0; }
354 StringRef getFlags() const { return getStringField(5); }
355 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
357 DIArray getEnumTypes() const;
358 DIArray getRetainedTypes() const;
359 DIArray getSubprograms() const;
360 DIArray getGlobalVariables() const;
361 DIArray getImportedEntities() const;
363 StringRef getSplitDebugFilename() const { return getStringField(12); }
365 /// Verify - Verify that a compile unit is well formed.
369 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
370 class DISubprogram : public DIScope {
371 friend class DIDescriptor;
372 void printInternal(raw_ostream &OS) const;
374 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
376 DIScope getContext() const { return getFieldAs<DIScope>(2); }
377 StringRef getName() const { return getStringField(3); }
378 StringRef getDisplayName() const { return getStringField(4); }
379 StringRef getLinkageName() const { return getStringField(5); }
380 unsigned getLineNumber() const { return getUnsignedField(6); }
381 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
383 /// isLocalToUnit - Return true if this subprogram is local to the current
384 /// compile unit, like 'static' in C.
385 unsigned isLocalToUnit() const { return getUnsignedField(8); }
386 unsigned isDefinition() const { return getUnsignedField(9); }
388 unsigned getVirtuality() const { return getUnsignedField(10); }
389 unsigned getVirtualIndex() const { return getUnsignedField(11); }
391 DICompositeType getContainingType() const {
392 return getFieldAs<DICompositeType>(12);
395 unsigned getFlags() const {
396 return getUnsignedField(13);
399 unsigned isArtificial() const {
400 return (getUnsignedField(13) & FlagArtificial) != 0;
402 /// isPrivate - Return true if this subprogram has "private"
403 /// access specifier.
404 bool isPrivate() const {
405 return (getUnsignedField(13) & FlagPrivate) != 0;
407 /// isProtected - Return true if this subprogram has "protected"
408 /// access specifier.
409 bool isProtected() const {
410 return (getUnsignedField(13) & FlagProtected) != 0;
412 /// isExplicit - Return true if this subprogram is marked as explicit.
413 bool isExplicit() const {
414 return (getUnsignedField(13) & FlagExplicit) != 0;
416 /// isPrototyped - Return true if this subprogram is prototyped.
417 bool isPrototyped() const {
418 return (getUnsignedField(13) & FlagPrototyped) != 0;
421 unsigned isOptimized() const;
423 /// Verify - Verify that a subprogram descriptor is well formed.
426 /// describes - Return true if this subprogram provides debugging
427 /// information for the function F.
428 bool describes(const Function *F);
430 Function *getFunction() const { return getFunctionField(15); }
431 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
432 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
433 DISubprogram getFunctionDeclaration() const {
434 return getFieldAs<DISubprogram>(17);
436 MDNode *getVariablesNodes() const;
437 DIArray getVariables() const;
439 /// getScopeLineNumber - Get the beginning of the scope of the
440 /// function, not necessarily where the name of the program
442 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
445 /// DILexicalBlock - This is a wrapper for a lexical block.
446 class DILexicalBlock : public DIScope {
448 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
449 DIScope getContext() const { return getFieldAs<DIScope>(2); }
450 unsigned getLineNumber() const { return getUnsignedField(3); }
451 unsigned getColumnNumber() const { return getUnsignedField(4); }
455 /// DILexicalBlockFile - This is a wrapper for a lexical block with
456 /// a filename change.
457 class DILexicalBlockFile : public DIScope {
459 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
460 DIScope getContext() const {
461 if (getScope().isSubprogram())
463 return getScope().getContext();
465 unsigned getLineNumber() const { return getScope().getLineNumber(); }
466 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
467 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
471 /// DINameSpace - A wrapper for a C++ style name space.
472 class DINameSpace : public DIScope {
473 friend class DIDescriptor;
474 void printInternal(raw_ostream &OS) const;
476 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
477 DIScope getContext() const { return getFieldAs<DIScope>(2); }
478 StringRef getName() const { return getStringField(3); }
479 unsigned getLineNumber() const { return getUnsignedField(4); }
483 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
484 class DITemplateTypeParameter : public DIDescriptor {
486 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
488 DIScope getContext() const { return getFieldAs<DIScope>(1); }
489 StringRef getName() const { return getStringField(2); }
490 DIType getType() const { return getFieldAs<DIType>(3); }
491 StringRef getFilename() const {
492 return getFieldAs<DIFile>(4).getFilename();
494 StringRef getDirectory() const {
495 return getFieldAs<DIFile>(4).getDirectory();
497 unsigned getLineNumber() const { return getUnsignedField(5); }
498 unsigned getColumnNumber() const { return getUnsignedField(6); }
502 /// DITemplateValueParameter - This is a wrapper for template value parameter.
503 class DITemplateValueParameter : public DIDescriptor {
505 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
507 DIScope getContext() const { return getFieldAs<DIScope>(1); }
508 StringRef getName() const { return getStringField(2); }
509 DIType getType() const { return getFieldAs<DIType>(3); }
510 Value *getValue() const;
511 StringRef getFilename() const {
512 return getFieldAs<DIFile>(5).getFilename();
514 StringRef getDirectory() const {
515 return getFieldAs<DIFile>(5).getDirectory();
517 unsigned getLineNumber() const { return getUnsignedField(6); }
518 unsigned getColumnNumber() const { return getUnsignedField(7); }
522 /// DIGlobalVariable - This is a wrapper for a global variable.
523 class DIGlobalVariable : public DIDescriptor {
524 friend class DIDescriptor;
525 void printInternal(raw_ostream &OS) const;
527 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
529 DIScope getContext() const { return getFieldAs<DIScope>(2); }
530 StringRef getName() const { return getStringField(3); }
531 StringRef getDisplayName() const { return getStringField(4); }
532 StringRef getLinkageName() const { return getStringField(5); }
533 StringRef getFilename() const {
534 return getFieldAs<DIFile>(6).getFilename();
536 StringRef getDirectory() const {
537 return getFieldAs<DIFile>(6).getDirectory();
541 unsigned getLineNumber() const { return getUnsignedField(7); }
542 DIType getType() const { return getFieldAs<DIType>(8); }
543 unsigned isLocalToUnit() const { return getUnsignedField(9); }
544 unsigned isDefinition() const { return getUnsignedField(10); }
546 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
547 Constant *getConstant() const { return getConstantField(11); }
548 DIDerivedType getStaticDataMemberDeclaration() const {
549 return getFieldAs<DIDerivedType>(12);
552 /// Verify - Verify that a global variable descriptor is well formed.
556 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
558 class DIVariable : public DIDescriptor {
559 friend class DIDescriptor;
560 void printInternal(raw_ostream &OS) const;
562 explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {}
564 DIScope getContext() const { return getFieldAs<DIScope>(1); }
565 StringRef getName() const { return getStringField(2); }
566 DIFile getFile() const { return getFieldAs<DIFile>(3); }
567 unsigned getLineNumber() const {
568 return (getUnsignedField(4) << 8) >> 8;
570 unsigned getArgNumber() const {
571 unsigned L = getUnsignedField(4);
574 DIType getType() const { return getFieldAs<DIType>(5); }
576 /// isArtificial - Return true if this variable is marked as "artificial".
577 bool isArtificial() const {
578 return (getUnsignedField(6) & FlagArtificial) != 0;
581 bool isObjectPointer() const {
582 return (getUnsignedField(6) & FlagObjectPointer) != 0;
585 /// \brief Return true if this variable is represented as a pointer.
586 bool isIndirect() const {
587 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
590 /// getInlinedAt - If this variable is inlined then return inline location.
591 MDNode *getInlinedAt() const;
593 /// Verify - Verify that a variable descriptor is well formed.
596 /// HasComplexAddr - Return true if the variable has a complex address.
597 bool hasComplexAddress() const {
598 return getNumAddrElements() > 0;
601 unsigned getNumAddrElements() const;
603 uint64_t getAddrElement(unsigned Idx) const {
604 return getUInt64Field(Idx+8);
607 /// isBlockByrefVariable - Return true if the variable was declared as
608 /// a "__block" variable (Apple Blocks).
609 bool isBlockByrefVariable() const {
610 return getType().isBlockByrefStruct();
613 /// isInlinedFnArgument - Return true if this variable provides debugging
614 /// information for an inlined function arguments.
615 bool isInlinedFnArgument(const Function *CurFn);
617 void printExtendedName(raw_ostream &OS) const;
620 /// DILocation - This object holds location information. This object
621 /// is not associated with any DWARF tag.
622 class DILocation : public DIDescriptor {
624 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
626 unsigned getLineNumber() const { return getUnsignedField(0); }
627 unsigned getColumnNumber() const { return getUnsignedField(1); }
628 DIScope getScope() const { return getFieldAs<DIScope>(2); }
629 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
630 StringRef getFilename() const { return getScope().getFilename(); }
631 StringRef getDirectory() const { return getScope().getDirectory(); }
635 class DIObjCProperty : public DIDescriptor {
636 friend class DIDescriptor;
637 void printInternal(raw_ostream &OS) const;
639 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
641 StringRef getObjCPropertyName() const { return getStringField(1); }
642 DIFile getFile() const { return getFieldAs<DIFile>(2); }
643 unsigned getLineNumber() const { return getUnsignedField(3); }
645 StringRef getObjCPropertyGetterName() const {
646 return getStringField(4);
648 StringRef getObjCPropertySetterName() const {
649 return getStringField(5);
651 bool isReadOnlyObjCProperty() const {
652 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
654 bool isReadWriteObjCProperty() const {
655 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
657 bool isAssignObjCProperty() const {
658 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
660 bool isRetainObjCProperty() const {
661 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
663 bool isCopyObjCProperty() const {
664 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
666 bool isNonAtomicObjCProperty() const {
667 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
670 DIType getType() const { return getFieldAs<DIType>(7); }
672 /// Verify - Verify that a derived type descriptor is well formed.
676 /// \brief An imported module (C++ using directive or similar).
677 class DIImportedEntity : public DIDescriptor {
678 friend class DIDescriptor;
679 void printInternal(raw_ostream &OS) const;
681 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
682 DIScope getContext() const { return getFieldAs<DIScope>(1); }
683 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
684 unsigned getLineNumber() const { return getUnsignedField(3); }
685 StringRef getName() const { return getStringField(4); }
689 /// getDISubprogram - Find subprogram that is enclosing this scope.
690 DISubprogram getDISubprogram(const MDNode *Scope);
692 /// getDICompositeType - Find underlying composite type.
693 DICompositeType getDICompositeType(DIType T);
695 /// isSubprogramContext - Return true if Context is either a subprogram
696 /// or another context nested inside a subprogram.
697 bool isSubprogramContext(const MDNode *Context);
699 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
700 /// to hold function specific information.
701 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
703 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
704 /// suitable to hold function specific information.
705 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
707 /// createInlinedVariable - Create a new inlined variable based on current
709 /// @param DV Current Variable.
710 /// @param InlinedScope Location at current variable is inlined.
711 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
712 LLVMContext &VMContext);
714 /// cleanseInlinedVariable - Remove inlined scope from the variable.
715 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
717 /// DebugInfoFinder tries to list all debug info MDNodes in a module. To
718 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
719 /// processDeclare and processValue. processModule will go through
720 /// all DICompileUnits and list debug info MDNodes used by the CUs.
721 class DebugInfoFinder {
723 /// processModule - Process entire module and collect debug info
725 void processModule(const Module &M);
727 /// processDeclare - Process DbgDeclareInst.
728 void processDeclare(const DbgDeclareInst *DDI);
729 /// Process DbgValueInst.
730 void processValue(const DbgValueInst *DVI);
735 /// processType - Process DIType.
736 void processType(DIType DT);
738 /// processLexicalBlock - Process DILexicalBlock.
739 void processLexicalBlock(DILexicalBlock LB);
741 /// processSubprogram - Process DISubprogram.
742 void processSubprogram(DISubprogram SP);
744 /// processLocation - Process DILocation.
745 void processLocation(DILocation Loc);
747 void processScope(DIScope Scope);
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);
761 bool addScope(DIScope Scope);
764 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
765 iterator compile_unit_begin() const { return CUs.begin(); }
766 iterator compile_unit_end() const { return CUs.end(); }
767 iterator subprogram_begin() const { return SPs.begin(); }
768 iterator subprogram_end() const { return SPs.end(); }
769 iterator global_variable_begin() const { return GVs.begin(); }
770 iterator global_variable_end() const { return GVs.end(); }
771 iterator type_begin() const { return TYs.begin(); }
772 iterator type_end() const { return TYs.end(); }
773 iterator scope_begin() const { return Scopes.begin(); }
774 iterator scope_end() const { return Scopes.end(); }
776 unsigned compile_unit_count() const { return CUs.size(); }
777 unsigned global_variable_count() const { return GVs.size(); }
778 unsigned subprogram_count() const { return SPs.size(); }
779 unsigned type_count() const { return TYs.size(); }
780 unsigned scope_count() const { return Scopes.size(); }
783 SmallVector<MDNode *, 8> CUs; // Compile Units
784 SmallVector<MDNode *, 8> SPs; // Subprograms
785 SmallVector<MDNode *, 8> GVs; // Global Variables;
786 SmallVector<MDNode *, 8> TYs; // Types
787 SmallVector<MDNode *, 8> Scopes; // Scopes
788 SmallPtrSet<MDNode *, 64> NodesSeen;
790 } // end namespace llvm