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_ANALYSIS_DEBUGINFO_H
18 #define LLVM_ANALYSIS_DEBUGINFO_H
20 #include "llvm/Metadata.h" // FIXME: Should not need this.
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/SmallPtrSet.h"
23 #include "llvm/Support/Dwarf.h" // FIXME: Should not need this.
33 struct DbgStopPointInst;
34 struct DbgDeclareInst;
35 struct DbgFuncStartInst;
36 struct DbgRegionStartInst;
37 struct DbgRegionEndInst;
39 struct DebugLocTracker;
42 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
43 /// This should not be stored in a container, because underly MDNode may
44 /// change in certain situations.
49 /// DIDescriptor constructor. If the specified node is non-null, check
50 /// to make sure that the tag in the descriptor matches 'RequiredTag'. If
51 /// not, the debug info is corrupt and we ignore it.
52 DIDescriptor(MDNode *N, unsigned RequiredTag);
54 StringRef getStringField(unsigned Elt) const;
55 unsigned getUnsignedField(unsigned Elt) const {
56 return (unsigned)getUInt64Field(Elt);
58 uint64_t getUInt64Field(unsigned Elt) const;
59 DIDescriptor getDescriptorField(unsigned Elt) const;
61 template <typename DescTy>
62 DescTy getFieldAs(unsigned Elt) const {
63 return DescTy(getDescriptorField(Elt).getNode());
66 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
69 explicit DIDescriptor() : DbgNode(0) {}
70 explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
72 bool isNull() const { return DbgNode == 0; }
74 MDNode *getNode() const { return DbgNode; }
76 unsigned getVersion() const {
77 return getUnsignedField(0) & LLVMDebugVersionMask;
80 unsigned getTag() const {
81 return getUnsignedField(0) & ~LLVMDebugVersionMask;
84 /// ValidDebugInfo - Return true if N represents valid debug info value.
85 static bool ValidDebugInfo(MDNode *N, unsigned OptLevel);
87 /// dump - print descriptor.
90 bool isDerivedType() const;
91 bool isCompositeType() const;
92 bool isBasicType() const;
93 bool isVariable() const;
94 bool isSubprogram() const;
95 bool isGlobalVariable() const;
97 bool isCompileUnit() const;
98 bool isNameSpace() const;
99 bool isLexicalBlock() const;
100 bool isSubrange() const;
101 bool isEnumerator() const;
103 bool isGlobal() const;
106 /// DISubrange - This is used to represent ranges, for array bounds.
107 class DISubrange : public DIDescriptor {
109 explicit DISubrange(MDNode *N = 0)
110 : DIDescriptor(N, dwarf::DW_TAG_subrange_type) {}
112 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
113 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
116 /// DIArray - This descriptor holds an array of descriptors.
117 class DIArray : public DIDescriptor {
119 explicit DIArray(MDNode *N = 0)
122 unsigned getNumElements() const;
123 DIDescriptor getElement(unsigned Idx) const {
124 return getDescriptorField(Idx);
128 /// DIScope - A base class for various scopes.
129 class DIScope : public DIDescriptor {
131 explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {
132 if (DbgNode && !isScope())
135 virtual ~DIScope() {}
137 StringRef getFilename() const;
138 StringRef getDirectory() const;
141 /// DICompileUnit - A wrapper for a compile unit.
142 class DICompileUnit : public DIScope {
144 explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {
145 if (DbgNode && !isCompileUnit())
149 unsigned getLanguage() const { return getUnsignedField(2); }
150 StringRef getFilename() const { return getStringField(3); }
151 StringRef getDirectory() const { return getStringField(4); }
152 StringRef getProducer() const { return getStringField(5); }
154 /// isMain - Each input file is encoded as a separate compile unit in LLVM
155 /// debugging information output. However, many target specific tool chains
156 /// prefer to encode only one compile unit in an object file. In this
157 /// situation, the LLVM code generator will include debugging information
158 /// entities in the compile unit that is marked as main compile unit. The
159 /// code generator accepts maximum one main compile unit per module. If a
160 /// module does not contain any main compile unit then the code generator
161 /// will emit multiple compile units in the output object file.
163 bool isMain() const { return getUnsignedField(6); }
164 bool isOptimized() const { return getUnsignedField(7); }
165 StringRef getFlags() const { return getStringField(8); }
166 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
168 /// Verify - Verify that a compile unit is well formed.
171 /// dump - print compile unit.
175 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
176 /// FIXME: it seems strange that this doesn't have either a reference to the
177 /// type/precision or a file/line pair for location info.
178 class DIEnumerator : public DIDescriptor {
180 explicit DIEnumerator(MDNode *N = 0)
181 : DIDescriptor(N, dwarf::DW_TAG_enumerator) {}
183 StringRef getName() const { return getStringField(1); }
184 uint64_t getEnumValue() const { return getUInt64Field(2); }
187 /// DIType - This is a wrapper for a type.
188 /// FIXME: Types should be factored much better so that CV qualifiers and
189 /// others do not require a huge and empty descriptor full of zeros.
190 class DIType : public DIDescriptor {
193 FlagPrivate = 1 << 0,
194 FlagProtected = 1 << 1,
195 FlagFwdDecl = 1 << 2,
196 FlagAppleBlock = 1 << 3,
197 FlagBlockByrefStruct = 1 << 4,
202 DIType(MDNode *N, unsigned Tag)
203 : DIDescriptor(N, Tag) {}
204 // This ctor is used when the Tag has already been validated by a derived
206 DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
210 /// Verify - Verify that a type descriptor is well formed.
213 explicit DIType(MDNode *N);
217 DIDescriptor getContext() const { return getDescriptorField(1); }
218 StringRef getName() const { return getStringField(2); }
219 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
220 unsigned getLineNumber() const { return getUnsignedField(4); }
221 uint64_t getSizeInBits() const { return getUInt64Field(5); }
222 uint64_t getAlignInBits() const { return getUInt64Field(6); }
223 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
224 // carry this is just plain insane.
225 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
226 unsigned getFlags() const { return getUnsignedField(8); }
227 bool isPrivate() const {
228 return (getFlags() & FlagPrivate) != 0;
230 bool isProtected() const {
231 return (getFlags() & FlagProtected) != 0;
233 bool isForwardDecl() const {
234 return (getFlags() & FlagFwdDecl) != 0;
236 // isAppleBlock - Return true if this is the Apple Blocks extension.
237 bool isAppleBlockExtension() const {
238 return (getFlags() & FlagAppleBlock) != 0;
240 bool isBlockByrefStruct() const {
241 return (getFlags() & FlagBlockByrefStruct) != 0;
243 bool isVirtual() const {
244 return (getFlags() & FlagVirtual) != 0;
247 /// dump - print type.
251 /// DIBasicType - A basic type, like 'int' or 'float'.
252 class DIBasicType : public DIType {
254 explicit DIBasicType(MDNode *N = 0)
255 : DIType(N, dwarf::DW_TAG_base_type) {}
257 unsigned getEncoding() const { return getUnsignedField(9); }
259 /// dump - print basic type.
263 /// DIDerivedType - A simple derived type, like a const qualified type,
264 /// a typedef, a pointer or reference, etc.
265 class DIDerivedType : public DIType {
267 explicit DIDerivedType(MDNode *N, bool, bool)
268 : DIType(N, true, true) {}
270 explicit DIDerivedType(MDNode *N = 0)
271 : DIType(N, true, true) {
272 if (DbgNode && !isDerivedType())
276 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
278 /// getOriginalTypeSize - If this type is derived from a base type then
279 /// return base type size.
280 uint64_t getOriginalTypeSize() const;
281 /// dump - print derived type.
284 /// replaceAllUsesWith - Replace all uses of debug info referenced by
285 /// this descriptor. After this completes, the current debug info value
287 void replaceAllUsesWith(DIDescriptor &D);
290 /// DICompositeType - This descriptor holds a type that can refer to multiple
291 /// other types, like a function or struct.
292 /// FIXME: Why is this a DIDerivedType??
293 class DICompositeType : public DIDerivedType {
295 explicit DICompositeType(MDNode *N = 0)
296 : DIDerivedType(N, true, true) {
297 if (N && !isCompositeType())
301 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
302 unsigned getRunTimeLang() const { return getUnsignedField(11); }
304 /// Verify - Verify that a composite type descriptor is well formed.
307 /// dump - print composite type.
311 /// DIGlobal - This is a common class for global variables and subprograms.
312 class DIGlobal : public DIDescriptor {
314 explicit DIGlobal(MDNode *N, unsigned RequiredTag)
315 : DIDescriptor(N, RequiredTag) {}
318 virtual ~DIGlobal() {}
320 DIDescriptor getContext() const { return getDescriptorField(2); }
321 StringRef getName() const { return getStringField(3); }
322 StringRef getDisplayName() const { return getStringField(4); }
323 StringRef getLinkageName() const { return getStringField(5); }
324 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
325 unsigned getLineNumber() const { return getUnsignedField(7); }
326 DIType getType() const { return getFieldAs<DIType>(8); }
328 /// isLocalToUnit - Return true if this subprogram is local to the current
329 /// compile unit, like 'static' in C.
330 unsigned isLocalToUnit() const { return getUnsignedField(9); }
331 unsigned isDefinition() const { return getUnsignedField(10); }
333 /// dump - print global.
337 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
338 class DISubprogram : public DIScope {
340 explicit DISubprogram(MDNode *N = 0) : DIScope(N) {
341 if (DbgNode && !isSubprogram())
345 DIDescriptor getContext() const { return getDescriptorField(2); }
346 StringRef getName() const { return getStringField(3); }
347 StringRef getDisplayName() const { return getStringField(4); }
348 StringRef getLinkageName() const { return getStringField(5); }
349 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
350 unsigned getLineNumber() const { return getUnsignedField(7); }
351 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
353 /// getReturnTypeName - Subprogram return types are encoded either as
354 /// DIType or as DICompositeType.
355 StringRef getReturnTypeName() const {
356 DICompositeType DCT(getFieldAs<DICompositeType>(8));
358 DIArray A = DCT.getTypeArray();
359 DIType T(A.getElement(0).getNode());
362 DIType T(getFieldAs<DIType>(8));
366 /// isLocalToUnit - Return true if this subprogram is local to the current
367 /// compile unit, like 'static' in C.
368 unsigned isLocalToUnit() const { return getUnsignedField(9); }
369 unsigned isDefinition() const { return getUnsignedField(10); }
371 unsigned getVirtuality() const {
372 if (DbgNode->getNumElements() < 14)
374 return getUnsignedField(11);
377 unsigned getVirtualIndex() const {
378 if (DbgNode->getNumElements() < 14)
380 return getUnsignedField(12);
383 DICompositeType getContainingType() const {
384 assert (DbgNode->getNumElements() >= 14 && "Invalid type!");
385 return getFieldAs<DICompositeType>(13);
388 StringRef getFilename() const { return getCompileUnit().getFilename();}
389 StringRef getDirectory() const { return getCompileUnit().getDirectory();}
391 /// Verify - Verify that a subprogram descriptor is well formed.
394 /// dump - print subprogram.
397 /// describes - Return true if this subprogram provides debugging
398 /// information for the function F.
399 bool describes(const Function *F);
402 /// DIGlobalVariable - This is a wrapper for a global variable.
403 class DIGlobalVariable : public DIGlobal {
405 explicit DIGlobalVariable(MDNode *N = 0)
406 : DIGlobal(N, dwarf::DW_TAG_variable) {}
408 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
410 /// Verify - Verify that a global variable descriptor is well formed.
413 /// dump - print global variable.
417 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
419 class DIVariable : public DIDescriptor {
421 explicit DIVariable(MDNode *N = 0)
423 if (DbgNode && !isVariable())
427 DIDescriptor getContext() const { return getDescriptorField(1); }
428 StringRef getName() const { return getStringField(2); }
429 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
430 unsigned getLineNumber() const { return getUnsignedField(4); }
431 DIType getType() const { return getFieldAs<DIType>(5); }
434 /// Verify - Verify that a variable descriptor is well formed.
437 /// HasComplexAddr - Return true if the variable has a complex address.
438 bool hasComplexAddress() const {
439 return getNumAddrElements() > 0;
442 unsigned getNumAddrElements() const { return DbgNode->getNumElements()-6; }
444 uint64_t getAddrElement(unsigned Idx) const {
445 return getUInt64Field(Idx+6);
448 /// isBlockByrefVariable - Return true if the variable was declared as
449 /// a "__block" variable (Apple Blocks).
450 bool isBlockByrefVariable() const {
451 return getType().isBlockByrefStruct();
454 /// dump - print variable.
458 /// DILexicalBlock - This is a wrapper for a lexical block.
459 class DILexicalBlock : public DIScope {
461 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {
462 if (DbgNode && !isLexicalBlock())
465 DIScope getContext() const { return getFieldAs<DIScope>(1); }
466 StringRef getDirectory() const { return getContext().getDirectory(); }
467 StringRef getFilename() const { return getContext().getFilename(); }
470 /// DINameSpace - A wrapper for a C++ style name space.
471 class DINameSpace : public DIScope {
473 explicit DINameSpace(MDNode *N = 0) : DIScope(N) {
474 if (DbgNode && !isNameSpace())
478 DIScope getContext() const { return getFieldAs<DIScope>(1); }
479 StringRef getName() const { return getStringField(2); }
480 StringRef getDirectory() const { return getContext().getDirectory(); }
481 StringRef getFilename() const { return getContext().getFilename(); }
482 DICompileUnit getCompileUnit() const { return getFieldAs<DICompileUnit>(3);}
483 unsigned getLineNumber() const { return getUnsignedField(4); }
486 /// DILocation - This object holds location information. This object
487 /// is not associated with any DWARF tag.
488 class DILocation : public DIDescriptor {
490 explicit DILocation(MDNode *N) : DIDescriptor(N) { ; }
492 unsigned getLineNumber() const { return getUnsignedField(0); }
493 unsigned getColumnNumber() const { return getUnsignedField(1); }
494 DIScope getScope() const { return getFieldAs<DIScope>(2); }
495 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
496 StringRef getFilename() const { return getScope().getFilename(); }
497 StringRef getDirectory() const { return getScope().getDirectory(); }
500 /// DIFactory - This object assists with the construction of the various
504 LLVMContext& VMContext;
506 const Type *EmptyStructPtr; // "{}*".
507 Function *DeclareFn; // llvm.dbg.declare
508 Function *ValueFn; // llvm.dbg.value
510 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
511 void operator=(const DIFactory&); // DO NOT IMPLEMENT
513 enum ComplexAddrKind { OpPlus=1, OpDeref };
515 explicit DIFactory(Module &m);
517 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
518 /// This implicitly uniques the arrays created.
519 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
521 /// GetOrCreateSubrange - Create a descriptor for a value range. This
522 /// implicitly uniques the values returned.
523 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
525 /// CreateCompileUnit - Create a new descriptor for the specified compile
527 DICompileUnit CreateCompileUnit(unsigned LangID,
532 bool isOptimized = false,
533 StringRef Flags = "",
534 unsigned RunTimeVer = 0);
536 /// CreateEnumerator - Create a single enumerator value.
537 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
539 /// CreateBasicType - Create a basic type like int, float, etc.
540 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
541 DICompileUnit CompileUnit, unsigned LineNumber,
542 uint64_t SizeInBits, uint64_t AlignInBits,
543 uint64_t OffsetInBits, unsigned Flags,
546 /// CreateBasicType - Create a basic type like int, float, etc.
547 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
548 DICompileUnit CompileUnit, unsigned LineNumber,
549 Constant *SizeInBits, Constant *AlignInBits,
550 Constant *OffsetInBits, unsigned Flags,
553 /// CreateDerivedType - Create a derived type like const qualified type,
554 /// pointer, typedef, etc.
555 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
557 DICompileUnit CompileUnit,
559 uint64_t SizeInBits, uint64_t AlignInBits,
560 uint64_t OffsetInBits, unsigned Flags,
563 /// CreateDerivedType - Create a derived type like const qualified type,
564 /// pointer, typedef, etc.
565 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
567 DICompileUnit CompileUnit,
569 Constant *SizeInBits, Constant *AlignInBits,
570 Constant *OffsetInBits, unsigned Flags,
573 /// CreateCompositeType - Create a composite type like array, struct, etc.
574 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
576 DICompileUnit CompileUnit,
579 uint64_t AlignInBits,
580 uint64_t OffsetInBits, unsigned Flags,
583 unsigned RunTimeLang = 0);
585 /// CreateCompositeType - Create a composite type like array, struct, etc.
586 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
588 DICompileUnit CompileUnit,
590 Constant *SizeInBits,
591 Constant *AlignInBits,
592 Constant *OffsetInBits, unsigned Flags,
595 unsigned RunTimeLang = 0);
597 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
598 /// See comments in DISubprogram for descriptions of these fields.
599 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
600 StringRef DisplayName,
601 StringRef LinkageName,
602 DICompileUnit CompileUnit, unsigned LineNo,
603 DIType Type, bool isLocalToUnit,
609 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
610 /// given declaration.
611 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
613 /// CreateGlobalVariable - Create a new descriptor for the specified global.
615 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
616 StringRef DisplayName,
617 StringRef LinkageName,
618 DICompileUnit CompileUnit,
619 unsigned LineNo, DIType Type, bool isLocalToUnit,
620 bool isDefinition, llvm::GlobalVariable *GV);
622 /// CreateVariable - Create a new descriptor for the specified variable.
623 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
625 DICompileUnit CompileUnit, unsigned LineNo,
628 /// CreateComplexVariable - Create a new descriptor for the specified
629 /// variable which has a complex address expression for its address.
630 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
631 const std::string &Name,
632 DICompileUnit CompileUnit, unsigned LineNo,
634 SmallVector<Value *, 9> &addr);
636 /// CreateLexicalBlock - This creates a descriptor for a lexical block
637 /// with the specified parent context.
638 DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
640 /// CreateNameSpace - This creates new descriptor for a namespace
641 /// with the specified parent context.
642 DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
643 DICompileUnit CU, unsigned LineNo);
645 /// CreateLocation - Creates a debug info location.
646 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
647 DIScope S, DILocation OrigLoc);
649 /// CreateLocation - Creates a debug info location.
650 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
651 DIScope S, MDNode *OrigLoc = 0);
653 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
654 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
655 BasicBlock *InsertAtEnd);
657 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
658 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
659 Instruction *InsertBefore);
661 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
662 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
663 DIVariable D, BasicBlock *InsertAtEnd);
665 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
666 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
667 DIVariable D, Instruction *InsertBefore);
669 Constant *GetTagConstant(unsigned TAG);
672 /// Finds the stoppoint coressponding to this instruction, that is the
673 /// stoppoint that dominates this instruction
674 const DbgStopPointInst *findStopPoint(const Instruction *Inst);
676 /// Finds the stoppoint corresponding to first real (non-debug intrinsic)
677 /// instruction in this Basic Block, and returns the stoppoint for it.
678 const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB);
680 /// Finds the dbg.declare intrinsic corresponding to this value if any.
681 /// It looks through pointer casts too.
682 const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true);
684 /// Find the debug info descriptor corresponding to this global variable.
685 Value *findDbgGlobalDeclare(GlobalVariable *V);
687 bool getLocationInfo(const Value *V, std::string &DisplayName,
688 std::string &Type, unsigned &LineNo, std::string &File,
691 /// ExtractDebugLocation - Extract debug location information
692 /// from llvm.dbg.stoppoint intrinsic.
693 DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI,
694 DebugLocTracker &DebugLocInfo);
696 /// ExtractDebugLocation - Extract debug location information
698 DebugLoc ExtractDebugLocation(DILocation &Loc,
699 DebugLocTracker &DebugLocInfo);
701 /// ExtractDebugLocation - Extract debug location information
702 /// from llvm.dbg.func_start intrinsic.
703 DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI,
704 DebugLocTracker &DebugLocInfo);
706 /// getDISubprogram - Find subprogram that is enclosing this scope.
707 DISubprogram getDISubprogram(MDNode *Scope);
709 /// getDICompositeType - Find underlying composite type.
710 DICompositeType getDICompositeType(DIType T);
712 class DebugInfoFinder {
714 /// processModule - Process entire module and collect debug info
716 void processModule(Module &M);
719 /// processType - Process DIType.
720 void processType(DIType DT);
722 /// processLexicalBlock - Process DILexicalBlock.
723 void processLexicalBlock(DILexicalBlock LB);
725 /// processSubprogram - Process DISubprogram.
726 void processSubprogram(DISubprogram SP);
728 /// processDeclare - Process DbgDeclareInst.
729 void processDeclare(DbgDeclareInst *DDI);
731 /// processLocation - Process DILocation.
732 void processLocation(DILocation Loc);
734 /// addCompileUnit - Add compile unit into CUs.
735 bool addCompileUnit(DICompileUnit CU);
737 /// addGlobalVariable - Add global variable into GVs.
738 bool addGlobalVariable(DIGlobalVariable DIG);
740 // addSubprogram - Add subprgoram into SPs.
741 bool addSubprogram(DISubprogram SP);
743 /// addType - Add type into Tys.
744 bool addType(DIType DT);
747 typedef SmallVector<MDNode *, 8>::iterator iterator;
748 iterator compile_unit_begin() { return CUs.begin(); }
749 iterator compile_unit_end() { return CUs.end(); }
750 iterator subprogram_begin() { return SPs.begin(); }
751 iterator subprogram_end() { return SPs.end(); }
752 iterator global_variable_begin() { return GVs.begin(); }
753 iterator global_variable_end() { return GVs.end(); }
754 iterator type_begin() { return TYs.begin(); }
755 iterator type_end() { return TYs.end(); }
757 unsigned compile_unit_count() { return CUs.size(); }
758 unsigned global_variable_count() { return GVs.size(); }
759 unsigned subprogram_count() { return SPs.size(); }
760 unsigned type_count() { return TYs.size(); }
763 SmallVector<MDNode *, 8> CUs; // Compile Units
764 SmallVector<MDNode *, 8> SPs; // Subprograms
765 SmallVector<MDNode *, 8> GVs; // Global Variables;
766 SmallVector<MDNode *, 8> TYs; // Types
767 SmallPtrSet<MDNode *, 64> NodesSeen;
769 } // end namespace llvm