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"
43 class DILexicalBlockFile;
47 class DIImportedModule;
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
70 const MDNode *DbgNode;
72 StringRef getStringField(unsigned Elt) const;
73 unsigned getUnsignedField(unsigned Elt) const {
74 return (unsigned)getUInt64Field(Elt);
76 uint64_t getUInt64Field(unsigned Elt) const;
77 int64_t getInt64Field(unsigned Elt) const;
78 DIDescriptor getDescriptorField(unsigned Elt) const;
80 template <typename DescTy>
81 DescTy getFieldAs(unsigned Elt) const {
82 return DescTy(getDescriptorField(Elt));
85 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
86 Constant *getConstantField(unsigned Elt) const;
87 Function *getFunctionField(unsigned Elt) const;
88 void replaceFunctionField(unsigned Elt, Function *F);
91 explicit DIDescriptor() : DbgNode(0) {}
92 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
93 explicit DIDescriptor(const DIFile F);
94 explicit DIDescriptor(const DISubprogram F);
95 explicit DIDescriptor(const DILexicalBlockFile F);
96 explicit DIDescriptor(const DILexicalBlock F);
97 explicit DIDescriptor(const DIVariable F);
98 explicit DIDescriptor(const DIType F);
102 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
103 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
105 unsigned getTag() const {
106 return getUnsignedField(0) & ~LLVMDebugVersionMask;
109 bool isDerivedType() const;
110 bool isCompositeType() const;
111 bool isBasicType() const;
112 bool isVariable() const;
113 bool isSubprogram() const;
114 bool isGlobalVariable() const;
115 bool isScope() const;
117 bool isCompileUnit() const;
118 bool isNameSpace() const;
119 bool isLexicalBlockFile() const;
120 bool isLexicalBlock() const;
121 bool isSubrange() const;
122 bool isEnumerator() const;
124 bool isGlobal() const;
125 bool isUnspecifiedParameter() const;
126 bool isTemplateTypeParameter() const;
127 bool isTemplateValueParameter() const;
128 bool isObjCProperty() const;
129 bool isImportedModule() const;
131 /// print - print descriptor.
132 void print(raw_ostream &OS) const;
134 /// dump - print descriptor to dbgs() with a newline.
138 /// DISubrange - This is used to represent ranges, for array bounds.
139 class DISubrange : public DIDescriptor {
140 friend class DIDescriptor;
141 void printInternal(raw_ostream &OS) const;
143 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
145 int64_t getLo() const { return getInt64Field(1); }
146 int64_t getCount() const { return getInt64Field(2); }
150 /// DIArray - This descriptor holds an array of descriptors.
151 class DIArray : public DIDescriptor {
153 explicit DIArray(const MDNode *N = 0)
156 unsigned getNumElements() const;
157 DIDescriptor getElement(unsigned Idx) const {
158 return getDescriptorField(Idx);
162 /// DIScope - A base class for various scopes.
163 class DIScope : public DIDescriptor {
165 friend class DIDescriptor;
166 void printInternal(raw_ostream &OS) const;
168 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
170 StringRef getFilename() const;
171 StringRef getDirectory() const;
172 DIArray getImportedModules() const { return getFieldAs<DIArray>(2); }
175 /// DIFile - This is a wrapper for a file.
176 class DIFile : public DIScope {
177 friend class DIDescriptor;
179 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
180 if (DbgNode && !isFile())
183 MDNode *getFileNode() const;
187 /// DICompileUnit - A wrapper for a compile unit.
188 class DICompileUnit : public DIScope {
189 friend class DIDescriptor;
190 void printInternal(raw_ostream &OS) const;
192 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
194 unsigned getLanguage() const { return getUnsignedField(3); }
195 StringRef getProducer() const { return getStringField(4); }
197 bool isOptimized() const { return getUnsignedField(5) != 0; }
198 StringRef getFlags() const { return getStringField(6); }
199 unsigned getRunTimeVersion() const { return getUnsignedField(7); }
201 DIArray getEnumTypes() const;
202 DIArray getRetainedTypes() const;
203 DIArray getSubprograms() const;
204 DIArray getGlobalVariables() const;
206 StringRef getSplitDebugFilename() const { return getStringField(12); }
208 /// Verify - Verify that a compile unit is well formed.
212 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
213 /// FIXME: it seems strange that this doesn't have either a reference to the
214 /// type/precision or a file/line pair for location info.
215 class DIEnumerator : public DIDescriptor {
216 friend class DIDescriptor;
217 void printInternal(raw_ostream &OS) const;
219 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
221 StringRef getName() const { return getStringField(1); }
222 uint64_t getEnumValue() const { return getUInt64Field(2); }
226 /// DIType - This is a wrapper for a type.
227 /// FIXME: Types should be factored much better so that CV qualifiers and
228 /// others do not require a huge and empty descriptor full of zeros.
229 class DIType : public DIScope {
231 friend class DIDescriptor;
232 void printInternal(raw_ostream &OS) const;
233 // This ctor is used when the Tag has already been validated by a derived
235 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
237 /// Verify - Verify that a type descriptor is well formed.
239 explicit DIType(const MDNode *N);
242 DIScope getContext() const { return getFieldAs<DIScope>(3); }
243 StringRef getName() const { return getStringField(4); }
244 unsigned getLineNumber() const { return getUnsignedField(5); }
245 uint64_t getSizeInBits() const { return getUInt64Field(6); }
246 uint64_t getAlignInBits() const { return getUInt64Field(7); }
247 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
248 // carry this is just plain insane.
249 uint64_t getOffsetInBits() const { return getUInt64Field(8); }
250 unsigned getFlags() const { return getUnsignedField(9); }
251 bool isPrivate() const {
252 return (getFlags() & FlagPrivate) != 0;
254 bool isProtected() const {
255 return (getFlags() & FlagProtected) != 0;
257 bool isForwardDecl() const {
258 return (getFlags() & FlagFwdDecl) != 0;
260 // isAppleBlock - Return true if this is the Apple Blocks extension.
261 bool isAppleBlockExtension() const {
262 return (getFlags() & FlagAppleBlock) != 0;
264 bool isBlockByrefStruct() const {
265 return (getFlags() & FlagBlockByrefStruct) != 0;
267 bool isVirtual() const {
268 return (getFlags() & FlagVirtual) != 0;
270 bool isArtificial() const {
271 return (getFlags() & FlagArtificial) != 0;
273 bool isObjectPointer() const {
274 return (getFlags() & FlagObjectPointer) != 0;
276 bool isObjcClassComplete() const {
277 return (getFlags() & FlagObjcClassComplete) != 0;
279 bool isVector() const {
280 return (getFlags() & FlagVector) != 0;
282 bool isStaticMember() const {
283 return (getFlags() & FlagStaticMember) != 0;
285 bool isValid() const {
286 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
289 /// isUnsignedDIType - Return true if type encoding is unsigned.
290 bool isUnsignedDIType();
292 /// replaceAllUsesWith - Replace all uses of debug info referenced by
294 void replaceAllUsesWith(DIDescriptor &D);
295 void replaceAllUsesWith(MDNode *D);
298 /// DIBasicType - A basic type, like 'int' or 'float'.
299 class DIBasicType : public DIType {
301 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
303 unsigned getEncoding() const { return getUnsignedField(10); }
305 /// Verify - Verify that a basic type descriptor is well formed.
309 /// DIDerivedType - A simple derived type, like a const qualified type,
310 /// a typedef, a pointer or reference, et cetera. Or, a data member of
311 /// a class/struct/union.
312 class DIDerivedType : public DIType {
313 friend class DIDescriptor;
314 void printInternal(raw_ostream &OS) const;
316 explicit DIDerivedType(const MDNode *N, bool, bool)
317 : DIType(N, true, true) {}
319 explicit DIDerivedType(const MDNode *N = 0)
320 : DIType(N, true, true) {}
322 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(10); }
324 /// getOriginalTypeSize - If this type is derived from a base type then
325 /// return base type size.
326 uint64_t getOriginalTypeSize() const;
328 /// getObjCProperty - Return property node, if this ivar is
329 /// associated with one.
330 MDNode *getObjCProperty() const;
332 DIType getClassType() const {
333 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
334 return getFieldAs<DIType>(11);
337 Constant *getConstant() const {
338 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
339 return getConstantField(11);
342 /// Verify - Verify that a derived type descriptor is well formed.
346 /// DICompositeType - This descriptor holds a type that can refer to multiple
347 /// other types, like a function or struct.
348 /// FIXME: Why is this a DIDerivedType??
349 class DICompositeType : public DIDerivedType {
350 friend class DIDescriptor;
351 void printInternal(raw_ostream &OS) const;
353 explicit DICompositeType(const MDNode *N = 0)
354 : DIDerivedType(N, true, true) {
355 if (N && !isCompositeType())
359 DIArray getTypeArray() const { return getFieldAs<DIArray>(11); }
360 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
361 unsigned getRunTimeLang() const { return getUnsignedField(12); }
362 DICompositeType getContainingType() const {
363 return getFieldAs<DICompositeType>(13);
365 void setContainingType(DICompositeType ContainingType);
366 DIArray getTemplateParams() const { return getFieldAs<DIArray>(14); }
368 /// Verify - Verify that a composite type descriptor is well formed.
372 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
373 class DITemplateTypeParameter : public DIDescriptor {
375 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
377 DIScope getContext() const { return getFieldAs<DIScope>(1); }
378 StringRef getName() const { return getStringField(2); }
379 DIType getType() const { return getFieldAs<DIType>(3); }
380 StringRef getFilename() const {
381 return getFieldAs<DIFile>(4).getFilename();
383 StringRef getDirectory() const {
384 return getFieldAs<DIFile>(4).getDirectory();
386 unsigned getLineNumber() const { return getUnsignedField(5); }
387 unsigned getColumnNumber() const { return getUnsignedField(6); }
391 /// DITemplateValueParameter - This is a wrapper for template value parameter.
392 class DITemplateValueParameter : public DIDescriptor {
394 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
396 DIScope getContext() const { return getFieldAs<DIScope>(1); }
397 StringRef getName() const { return getStringField(2); }
398 DIType getType() const { return getFieldAs<DIType>(3); }
399 uint64_t getValue() const { return getUInt64Field(4); }
400 StringRef getFilename() const {
401 return getFieldAs<DIFile>(5).getFilename();
403 StringRef getDirectory() const {
404 return getFieldAs<DIFile>(5).getDirectory();
406 unsigned getLineNumber() const { return getUnsignedField(6); }
407 unsigned getColumnNumber() const { return getUnsignedField(7); }
411 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
412 class DISubprogram : public DIScope {
413 friend class DIDescriptor;
414 void printInternal(raw_ostream &OS) const;
416 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
418 DIScope getContext() const { return getFieldAs<DIScope>(3); }
419 StringRef getName() const { return getStringField(4); }
420 StringRef getDisplayName() const { return getStringField(5); }
421 StringRef getLinkageName() const { return getStringField(6); }
422 unsigned getLineNumber() const { return getUnsignedField(7); }
423 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
425 /// getReturnTypeName - Subprogram return types are encoded either as
426 /// DIType or as DICompositeType.
427 StringRef getReturnTypeName() const {
428 DICompositeType DCT(getFieldAs<DICompositeType>(8));
430 DIArray A = DCT.getTypeArray();
431 DIType T(A.getElement(0));
434 DIType T(getFieldAs<DIType>(8));
438 /// isLocalToUnit - Return true if this subprogram is local to the current
439 /// compile unit, like 'static' in C.
440 unsigned isLocalToUnit() const { return getUnsignedField(9); }
441 unsigned isDefinition() const { return getUnsignedField(10); }
443 unsigned getVirtuality() const { return getUnsignedField(11); }
444 unsigned getVirtualIndex() const { return getUnsignedField(12); }
446 DICompositeType getContainingType() const {
447 return getFieldAs<DICompositeType>(13);
450 unsigned getFlags() const {
451 return getUnsignedField(14);
454 unsigned isArtificial() const {
455 return (getFlags() & FlagArtificial) != 0;
457 /// isPrivate - Return true if this subprogram has "private"
458 /// access specifier.
459 bool isPrivate() const {
460 return (getFlags() & FlagPrivate) != 0;
462 /// isProtected - Return true if this subprogram has "protected"
463 /// access specifier.
464 bool isProtected() const {
465 return (getFlags() & FlagProtected) != 0;
467 /// isExplicit - Return true if this subprogram is marked as explicit.
468 bool isExplicit() const {
469 return (getFlags() & FlagExplicit) != 0;
471 /// isPrototyped - Return true if this subprogram is prototyped.
472 bool isPrototyped() const {
473 return (getFlags() & FlagPrototyped) != 0;
476 unsigned isOptimized() const;
478 /// getScopeLineNumber - Get the beginning of the scope of the
479 /// function, not necessarily where the name of the program
481 unsigned getScopeLineNumber() const { return getUnsignedField(20); }
483 /// Verify - Verify that a subprogram descriptor is well formed.
486 /// describes - Return true if this subprogram provides debugging
487 /// information for the function F.
488 bool describes(const Function *F);
490 Function *getFunction() const { return getFunctionField(16); }
491 void replaceFunction(Function *F) { replaceFunctionField(16, F); }
492 DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
493 DISubprogram getFunctionDeclaration() const {
494 return getFieldAs<DISubprogram>(18);
496 MDNode *getVariablesNodes() const;
497 DIArray getVariables() const;
500 /// DIGlobalVariable - This is a wrapper for a global variable.
501 class DIGlobalVariable : public DIDescriptor {
502 friend class DIDescriptor;
503 void printInternal(raw_ostream &OS) const;
505 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
507 DIScope getContext() const { return getFieldAs<DIScope>(2); }
508 StringRef getName() const { return getStringField(3); }
509 StringRef getDisplayName() const { return getStringField(4); }
510 StringRef getLinkageName() const { return getStringField(5); }
511 StringRef getFilename() const {
512 return getFieldAs<DIFile>(6).getFilename();
514 StringRef getDirectory() const {
515 return getFieldAs<DIFile>(6).getDirectory();
519 unsigned getLineNumber() const { return getUnsignedField(7); }
520 DIType getType() const { return getFieldAs<DIType>(8); }
521 unsigned isLocalToUnit() const { return getUnsignedField(9); }
522 unsigned isDefinition() const { return getUnsignedField(10); }
524 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
525 Constant *getConstant() const { return getConstantField(11); }
526 DIDerivedType getStaticDataMemberDeclaration() const {
527 return getFieldAs<DIDerivedType>(12);
530 /// Verify - Verify that a global variable descriptor is well formed.
534 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
536 class DIVariable : public DIDescriptor {
537 friend class DIDescriptor;
538 void printInternal(raw_ostream &OS) const;
540 explicit DIVariable(const MDNode *N = 0)
543 DIScope getContext() const { return getFieldAs<DIScope>(1); }
544 StringRef getName() const { return getStringField(2); }
545 DIFile getFile() const { return getFieldAs<DIFile>(3); }
546 unsigned getLineNumber() const {
547 return (getUnsignedField(4) << 8) >> 8;
549 unsigned getArgNumber() const {
550 unsigned L = getUnsignedField(4);
553 DIType getType() const { return getFieldAs<DIType>(5); }
555 /// isArtificial - Return true if this variable is marked as "artificial".
556 bool isArtificial() const {
557 return (getUnsignedField(6) & FlagArtificial) != 0;
560 bool isObjectPointer() const {
561 return (getUnsignedField(6) & FlagObjectPointer) != 0;
564 /// getInlinedAt - If this variable is inlined then return inline location.
565 MDNode *getInlinedAt() const;
567 /// Verify - Verify that a variable descriptor is well formed.
570 /// HasComplexAddr - Return true if the variable has a complex address.
571 bool hasComplexAddress() const {
572 return getNumAddrElements() > 0;
575 unsigned getNumAddrElements() const;
577 uint64_t getAddrElement(unsigned Idx) const {
578 return getUInt64Field(Idx+8);
581 /// isBlockByrefVariable - Return true if the variable was declared as
582 /// a "__block" variable (Apple Blocks).
583 bool isBlockByrefVariable() const {
584 return getType().isBlockByrefStruct();
587 /// isInlinedFnArgument - Return true if this variable provides debugging
588 /// information for an inlined function arguments.
589 bool isInlinedFnArgument(const Function *CurFn);
591 void printExtendedName(raw_ostream &OS) const;
594 /// DILexicalBlock - This is a wrapper for a lexical block.
595 class DILexicalBlock : public DIScope {
597 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
598 DIScope getContext() const { return getFieldAs<DIScope>(3); }
599 unsigned getLineNumber() const { return getUnsignedField(4); }
600 unsigned getColumnNumber() const { return getUnsignedField(5); }
604 /// DILexicalBlockFile - This is a wrapper for a lexical block with
605 /// a filename change.
606 class DILexicalBlockFile : public DIScope {
608 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
609 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
610 unsigned getLineNumber() const { return getScope().getLineNumber(); }
611 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
612 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(3); }
616 /// DINameSpace - A wrapper for a C++ style name space.
617 class DINameSpace : public DIScope {
618 friend class DIDescriptor;
619 void printInternal(raw_ostream &OS) const;
621 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
622 DIScope getContext() const { return getFieldAs<DIScope>(3); }
623 StringRef getName() const { return getStringField(4); }
624 unsigned getLineNumber() const { return getUnsignedField(5); }
628 /// DILocation - This object holds location information. This object
629 /// is not associated with any DWARF tag.
630 class DILocation : public DIDescriptor {
632 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
634 unsigned getLineNumber() const { return getUnsignedField(0); }
635 unsigned getColumnNumber() const { return getUnsignedField(1); }
636 DIScope getScope() const { return getFieldAs<DIScope>(2); }
637 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
638 StringRef getFilename() const { return getScope().getFilename(); }
639 StringRef getDirectory() const { return getScope().getDirectory(); }
643 class DIObjCProperty : public DIDescriptor {
644 friend class DIDescriptor;
645 void printInternal(raw_ostream &OS) const;
647 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
649 StringRef getObjCPropertyName() const { return getStringField(1); }
650 DIFile getFile() const { return getFieldAs<DIFile>(2); }
651 unsigned getLineNumber() const { return getUnsignedField(3); }
653 StringRef getObjCPropertyGetterName() const {
654 return getStringField(4);
656 StringRef getObjCPropertySetterName() const {
657 return getStringField(5);
659 bool isReadOnlyObjCProperty() {
660 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
662 bool isReadWriteObjCProperty() {
663 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
665 bool isAssignObjCProperty() {
666 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
668 bool isRetainObjCProperty() {
669 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
671 bool isCopyObjCProperty() {
672 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
674 bool isNonAtomicObjCProperty() {
675 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
678 DIType getType() const { return getFieldAs<DIType>(7); }
680 /// Verify - Verify that a derived type descriptor is well formed.
684 class DIImportedModule : public DIDescriptor {
685 friend class DIDescriptor;
686 void printInternal(raw_ostream &OS) const;
688 explicit DIImportedModule(const MDNode *N) : DIDescriptor(N) { }
689 DINameSpace getNameSpace() const { return getFieldAs<DINameSpace>(1); }
693 /// getDISubprogram - Find subprogram that is enclosing this scope.
694 DISubprogram getDISubprogram(const MDNode *Scope);
696 /// getDICompositeType - Find underlying composite type.
697 DICompositeType getDICompositeType(DIType T);
699 /// isSubprogramContext - Return true if Context is either a subprogram
700 /// or another context nested inside a subprogram.
701 bool isSubprogramContext(const MDNode *Context);
703 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
704 /// to hold function specific information.
705 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
707 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
708 /// suitable to hold function specific information.
709 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
711 /// createInlinedVariable - Create a new inlined variable based on current
713 /// @param DV Current Variable.
714 /// @param InlinedScope Location at current variable is inlined.
715 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
716 LLVMContext &VMContext);
718 /// cleanseInlinedVariable - Remove inlined scope from the variable.
719 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
721 class DebugInfoFinder {
723 /// processModule - Process entire module and collect debug info
725 void processModule(const Module &M);
728 /// processType - Process DIType.
729 void processType(DIType DT);
731 /// processLexicalBlock - Process DILexicalBlock.
732 void processLexicalBlock(DILexicalBlock LB);
734 /// processSubprogram - Process DISubprogram.
735 void processSubprogram(DISubprogram SP);
737 /// processDeclare - Process DbgDeclareInst.
738 void processDeclare(const DbgDeclareInst *DDI);
740 /// processLocation - Process DILocation.
741 void processLocation(DILocation Loc);
743 /// addCompileUnit - Add compile unit into CUs.
744 bool addCompileUnit(DICompileUnit CU);
746 /// addGlobalVariable - Add global variable into GVs.
747 bool addGlobalVariable(DIGlobalVariable DIG);
749 // addSubprogram - Add subprogram into SPs.
750 bool addSubprogram(DISubprogram SP);
752 /// addType - Add type into Tys.
753 bool addType(DIType DT);
756 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
757 iterator compile_unit_begin() const { return CUs.begin(); }
758 iterator compile_unit_end() const { return CUs.end(); }
759 iterator subprogram_begin() const { return SPs.begin(); }
760 iterator subprogram_end() const { return SPs.end(); }
761 iterator global_variable_begin() const { return GVs.begin(); }
762 iterator global_variable_end() const { return GVs.end(); }
763 iterator type_begin() const { return TYs.begin(); }
764 iterator type_end() const { return TYs.end(); }
766 unsigned compile_unit_count() const { return CUs.size(); }
767 unsigned global_variable_count() const { return GVs.size(); }
768 unsigned subprogram_count() const { return SPs.size(); }
769 unsigned type_count() const { return TYs.size(); }
772 SmallVector<MDNode *, 8> CUs; // Compile Units
773 SmallVector<MDNode *, 8> SPs; // Subprograms
774 SmallVector<MDNode *, 8> GVs; // Global Variables;
775 SmallVector<MDNode *, 8> TYs; // Types
776 SmallPtrSet<MDNode *, 64> NodesSeen;
778 } // end namespace llvm