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/ADT/SmallVector.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/Dwarf.h"
39 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
40 /// This should not be stored in a container, because underly MDNode may
41 /// change in certain situations.
44 const MDNode *DbgNode;
46 StringRef getStringField(unsigned Elt) const;
47 unsigned getUnsignedField(unsigned Elt) const {
48 return (unsigned)getUInt64Field(Elt);
50 uint64_t getUInt64Field(unsigned Elt) const;
51 DIDescriptor getDescriptorField(unsigned Elt) const;
53 template <typename DescTy>
54 DescTy getFieldAs(unsigned Elt) const {
55 return DescTy(getDescriptorField(Elt));
58 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
61 explicit DIDescriptor() : DbgNode(0) {}
62 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
64 bool Verify() const { return DbgNode != 0; }
66 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
67 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
69 unsigned getVersion() const {
70 return getUnsignedField(0) & LLVMDebugVersionMask;
73 unsigned getTag() const {
74 return getUnsignedField(0) & ~LLVMDebugVersionMask;
77 /// print - print descriptor.
78 void print(raw_ostream &OS) const;
80 /// dump - print descriptor to dbgs() with a newline.
83 bool isDerivedType() const;
84 bool isCompositeType() const;
85 bool isBasicType() const;
86 bool isVariable() const;
87 bool isSubprogram() const;
88 bool isGlobalVariable() const;
91 bool isCompileUnit() const;
92 bool isNameSpace() const;
93 bool isLexicalBlock() const;
94 bool isSubrange() const;
95 bool isEnumerator() const;
97 bool isGlobal() const;
100 /// DISubrange - This is used to represent ranges, for array bounds.
101 class DISubrange : public DIDescriptor {
103 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
105 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
106 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
109 /// DIArray - This descriptor holds an array of descriptors.
110 class DIArray : public DIDescriptor {
112 explicit DIArray(const MDNode *N = 0)
115 unsigned getNumElements() const;
116 DIDescriptor getElement(unsigned Idx) const {
117 return getDescriptorField(Idx);
121 /// DIScope - A base class for various scopes.
122 class DIScope : public DIDescriptor {
124 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
125 virtual ~DIScope() {}
127 StringRef getFilename() const;
128 StringRef getDirectory() const;
131 /// DICompileUnit - A wrapper for a compile unit.
132 class DICompileUnit : public DIScope {
134 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
136 unsigned getLanguage() const { return getUnsignedField(2); }
137 StringRef getFilename() const { return getStringField(3); }
138 StringRef getDirectory() const { return getStringField(4); }
139 StringRef getProducer() const { return getStringField(5); }
141 /// isMain - Each input file is encoded as a separate compile unit in LLVM
142 /// debugging information output. However, many target specific tool chains
143 /// prefer to encode only one compile unit in an object file. In this
144 /// situation, the LLVM code generator will include debugging information
145 /// entities in the compile unit that is marked as main compile unit. The
146 /// code generator accepts maximum one main compile unit per module. If a
147 /// module does not contain any main compile unit then the code generator
148 /// will emit multiple compile units in the output object file.
150 bool isMain() const { return getUnsignedField(6); }
151 bool isOptimized() const { return getUnsignedField(7); }
152 StringRef getFlags() const { return getStringField(8); }
153 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
155 /// Verify - Verify that a compile unit is well formed.
158 /// print - print compile unit.
159 void print(raw_ostream &OS) const;
161 /// dump - print compile unit to dbgs() with a newline.
165 /// DIFile - This is a wrapper for a file.
166 class DIFile : public DIScope {
168 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
169 if (DbgNode && !isFile())
172 StringRef getFilename() const { return getStringField(1); }
173 StringRef getDirectory() const { return getStringField(2); }
174 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
177 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
178 /// FIXME: it seems strange that this doesn't have either a reference to the
179 /// type/precision or a file/line pair for location info.
180 class DIEnumerator : public DIDescriptor {
182 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
184 StringRef getName() const { return getStringField(1); }
185 uint64_t getEnumValue() const { return getUInt64Field(2); }
188 /// DIType - This is a wrapper for a type.
189 /// FIXME: Types should be factored much better so that CV qualifiers and
190 /// others do not require a huge and empty descriptor full of zeros.
191 class DIType : public DIScope {
194 FlagPrivate = 1 << 0,
195 FlagProtected = 1 << 1,
196 FlagFwdDecl = 1 << 2,
197 FlagAppleBlock = 1 << 3,
198 FlagBlockByrefStruct = 1 << 4,
199 FlagVirtual = 1 << 5,
200 FlagArtificial = 1 << 6 // To identify artificial arguments in
201 // a subroutine type. e.g. "this" in c++.
205 // This ctor is used when the Tag has already been validated by a derived
207 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
211 /// Verify - Verify that a type descriptor is well formed.
214 explicit DIType(const MDNode *N);
218 DIScope getContext() const { return getFieldAs<DIScope>(1); }
219 StringRef getName() const { return getStringField(2); }
220 DICompileUnit getCompileUnit() const{
221 if (getVersion() == llvm::LLVMDebugVersion7)
222 return getFieldAs<DICompileUnit>(3);
224 DIFile F = getFieldAs<DIFile>(3);
225 return F.getCompileUnit();
227 unsigned getLineNumber() const { return getUnsignedField(4); }
228 uint64_t getSizeInBits() const { return getUInt64Field(5); }
229 uint64_t getAlignInBits() const { return getUInt64Field(6); }
230 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
231 // carry this is just plain insane.
232 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
233 unsigned getFlags() const { return getUnsignedField(8); }
234 bool isPrivate() const {
235 return (getFlags() & FlagPrivate) != 0;
237 bool isProtected() const {
238 return (getFlags() & FlagProtected) != 0;
240 bool isForwardDecl() const {
241 return (getFlags() & FlagFwdDecl) != 0;
243 // isAppleBlock - Return true if this is the Apple Blocks extension.
244 bool isAppleBlockExtension() const {
245 return (getFlags() & FlagAppleBlock) != 0;
247 bool isBlockByrefStruct() const {
248 return (getFlags() & FlagBlockByrefStruct) != 0;
250 bool isVirtual() const {
251 return (getFlags() & FlagVirtual) != 0;
253 bool isArtificial() const {
254 return (getFlags() & FlagArtificial) != 0;
256 bool isValid() const {
257 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
259 StringRef getFilename() const { return getCompileUnit().getFilename();}
260 StringRef getDirectory() const { return getCompileUnit().getDirectory();}
262 /// print - print type.
263 void print(raw_ostream &OS) const;
265 /// dump - print type to dbgs() with a newline.
269 /// DIBasicType - A basic type, like 'int' or 'float'.
270 class DIBasicType : public DIType {
272 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
274 unsigned getEncoding() const { return getUnsignedField(9); }
276 /// print - print basic type.
277 void print(raw_ostream &OS) const;
279 /// dump - print basic type to dbgs() with a newline.
283 /// DIDerivedType - A simple derived type, like a const qualified type,
284 /// a typedef, a pointer or reference, etc.
285 class DIDerivedType : public DIType {
287 explicit DIDerivedType(const MDNode *N, bool, bool)
288 : DIType(N, true, true) {}
290 explicit DIDerivedType(const MDNode *N = 0)
291 : DIType(N, true, true) {}
293 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
295 /// getOriginalTypeSize - If this type is derived from a base type then
296 /// return base type size.
297 uint64_t getOriginalTypeSize() const;
299 /// print - print derived type.
300 void print(raw_ostream &OS) const;
302 /// dump - print derived type to dbgs() with a newline.
305 /// replaceAllUsesWith - Replace all uses of debug info referenced by
306 /// this descriptor. After this completes, the current debug info value
308 void replaceAllUsesWith(DIDescriptor &D);
311 /// DICompositeType - This descriptor holds a type that can refer to multiple
312 /// other types, like a function or struct.
313 /// FIXME: Why is this a DIDerivedType??
314 class DICompositeType : public DIDerivedType {
316 explicit DICompositeType(const MDNode *N = 0)
317 : DIDerivedType(N, true, true) {
318 if (N && !isCompositeType())
322 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
323 unsigned getRunTimeLang() const { return getUnsignedField(11); }
324 DICompositeType getContainingType() const {
325 return getFieldAs<DICompositeType>(12);
328 /// Verify - Verify that a composite type descriptor is well formed.
331 /// print - print composite type.
332 void print(raw_ostream &OS) const;
334 /// dump - print composite type to dbgs() with a newline.
338 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
339 class DISubprogram : public DIScope {
341 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
343 DIScope getContext() const { return getFieldAs<DIScope>(2); }
344 StringRef getName() const { return getStringField(3); }
345 StringRef getDisplayName() const { return getStringField(4); }
346 StringRef getLinkageName() const { return getStringField(5); }
347 DICompileUnit getCompileUnit() const{
348 if (getVersion() == llvm::LLVMDebugVersion7)
349 return getFieldAs<DICompileUnit>(6);
351 DIFile F = getFieldAs<DIFile>(6);
352 return F.getCompileUnit();
354 unsigned getLineNumber() const { return getUnsignedField(7); }
355 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
357 /// getReturnTypeName - Subprogram return types are encoded either as
358 /// DIType or as DICompositeType.
359 StringRef getReturnTypeName() const {
360 DICompositeType DCT(getFieldAs<DICompositeType>(8));
362 DIArray A = DCT.getTypeArray();
363 DIType T(A.getElement(0));
366 DIType T(getFieldAs<DIType>(8));
370 /// isLocalToUnit - Return true if this subprogram is local to the current
371 /// compile unit, like 'static' in C.
372 unsigned isLocalToUnit() const { return getUnsignedField(9); }
373 unsigned isDefinition() const { return getUnsignedField(10); }
375 unsigned getVirtuality() const { return getUnsignedField(11); }
376 unsigned getVirtualIndex() const { return getUnsignedField(12); }
378 DICompositeType getContainingType() const {
379 return getFieldAs<DICompositeType>(13);
381 unsigned isArtificial() const { return getUnsignedField(14); }
382 unsigned isOptimized() const;
384 StringRef getFilename() const {
385 if (getVersion() == llvm::LLVMDebugVersion7)
386 return getCompileUnit().getFilename();
388 DIFile F = getFieldAs<DIFile>(6);
389 return F.getFilename();
392 StringRef getDirectory() const {
393 if (getVersion() == llvm::LLVMDebugVersion7)
394 return getCompileUnit().getFilename();
396 DIFile F = getFieldAs<DIFile>(6);
397 return F.getDirectory();
400 /// Verify - Verify that a subprogram descriptor is well formed.
403 /// print - print subprogram.
404 void print(raw_ostream &OS) const;
406 /// dump - print subprogram to dbgs() with a newline.
409 /// describes - Return true if this subprogram provides debugging
410 /// information for the function F.
411 bool describes(const Function *F);
414 /// DIGlobalVariable - This is a wrapper for a global variable.
415 class DIGlobalVariable : public DIDescriptor {
417 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
419 DIScope getContext() const { return getFieldAs<DIScope>(2); }
420 StringRef getName() const { return getStringField(3); }
421 StringRef getDisplayName() const { return getStringField(4); }
422 StringRef getLinkageName() const { return getStringField(5); }
423 DICompileUnit getCompileUnit() const{
424 if (getVersion() == llvm::LLVMDebugVersion7)
425 return getFieldAs<DICompileUnit>(6);
427 DIFile F = getFieldAs<DIFile>(6);
428 return F.getCompileUnit();
431 unsigned getLineNumber() const { return getUnsignedField(7); }
432 DIType getType() const { return getFieldAs<DIType>(8); }
433 unsigned isLocalToUnit() const { return getUnsignedField(9); }
434 unsigned isDefinition() const { return getUnsignedField(10); }
436 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
438 /// Verify - Verify that a global variable descriptor is well formed.
441 /// print - print global variable.
442 void print(raw_ostream &OS) const;
444 /// dump - print global variable to dbgs() with a newline.
448 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
450 class DIVariable : public DIDescriptor {
452 explicit DIVariable(const MDNode *N = 0)
455 DIScope getContext() const { return getFieldAs<DIScope>(1); }
456 StringRef getName() const { return getStringField(2); }
457 DICompileUnit getCompileUnit() const{
458 if (getVersion() == llvm::LLVMDebugVersion7)
459 return getFieldAs<DICompileUnit>(3);
461 DIFile F = getFieldAs<DIFile>(3);
462 return F.getCompileUnit();
464 unsigned getLineNumber() const { return getUnsignedField(4); }
465 DIType getType() const { return getFieldAs<DIType>(5); }
468 /// Verify - Verify that a variable descriptor is well formed.
471 /// HasComplexAddr - Return true if the variable has a complex address.
472 bool hasComplexAddress() const {
473 return getNumAddrElements() > 0;
476 unsigned getNumAddrElements() const;
478 uint64_t getAddrElement(unsigned Idx) const {
479 return getUInt64Field(Idx+6);
482 /// isBlockByrefVariable - Return true if the variable was declared as
483 /// a "__block" variable (Apple Blocks).
484 bool isBlockByrefVariable() const {
485 return getType().isBlockByrefStruct();
488 /// isInlinedFnArgument - Return trule if this variable provides debugging
489 /// information for an inlined function arguments.
490 bool isInlinedFnArgument(const Function *CurFn);
492 /// print - print variable.
493 void print(raw_ostream &OS) const;
495 /// dump - print variable to dbgs() with a newline.
499 /// DILexicalBlock - This is a wrapper for a lexical block.
500 class DILexicalBlock : public DIScope {
502 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
503 DIScope getContext() const { return getFieldAs<DIScope>(1); }
504 StringRef getDirectory() const { return getContext().getDirectory(); }
505 StringRef getFilename() const { return getContext().getFilename(); }
506 unsigned getLineNumber() const { return getUnsignedField(2); }
507 unsigned getColumnNumber() const { return getUnsignedField(3); }
510 /// DINameSpace - A wrapper for a C++ style name space.
511 class DINameSpace : public DIScope {
513 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
514 DIScope getContext() const { return getFieldAs<DIScope>(1); }
515 StringRef getName() const { return getStringField(2); }
516 StringRef getDirectory() const { return getContext().getDirectory(); }
517 StringRef getFilename() const { return getContext().getFilename(); }
518 DICompileUnit getCompileUnit() const{
519 if (getVersion() == llvm::LLVMDebugVersion7)
520 return getFieldAs<DICompileUnit>(3);
522 DIFile F = getFieldAs<DIFile>(3);
523 return F.getCompileUnit();
525 unsigned getLineNumber() const { return getUnsignedField(4); }
529 /// DILocation - This object holds location information. This object
530 /// is not associated with any DWARF tag.
531 class DILocation : public DIDescriptor {
533 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
535 unsigned getLineNumber() const { return getUnsignedField(0); }
536 unsigned getColumnNumber() const { return getUnsignedField(1); }
537 DIScope getScope() const { return getFieldAs<DIScope>(2); }
538 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
539 StringRef getFilename() const { return getScope().getFilename(); }
540 StringRef getDirectory() const { return getScope().getDirectory(); }
544 /// DIFactory - This object assists with the construction of the various
548 LLVMContext& VMContext;
550 Function *DeclareFn; // llvm.dbg.declare
551 Function *ValueFn; // llvm.dbg.value
553 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
554 void operator=(const DIFactory&); // DO NOT IMPLEMENT
556 enum ComplexAddrKind { OpPlus=1, OpDeref };
558 explicit DIFactory(Module &m);
560 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
561 /// This implicitly uniques the arrays created.
562 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
564 /// GetOrCreateSubrange - Create a descriptor for a value range. This
565 /// implicitly uniques the values returned.
566 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
568 /// CreateCompileUnit - Create a new descriptor for the specified compile
570 DICompileUnit CreateCompileUnit(unsigned LangID,
575 bool isOptimized = false,
576 StringRef Flags = "",
577 unsigned RunTimeVer = 0);
579 /// CreateFile - Create a new descriptor for the specified file.
580 DIFile CreateFile(StringRef Filename, StringRef Directory, DICompileUnit CU);
582 /// CreateEnumerator - Create a single enumerator value.
583 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
585 /// CreateBasicType - Create a basic type like int, float, etc.
586 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
587 DIFile F, unsigned LineNumber,
588 uint64_t SizeInBits, uint64_t AlignInBits,
589 uint64_t OffsetInBits, unsigned Flags,
592 /// CreateBasicType - Create a basic type like int, float, etc.
593 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
594 DIFile F, unsigned LineNumber,
595 Constant *SizeInBits, Constant *AlignInBits,
596 Constant *OffsetInBits, unsigned Flags,
599 /// CreateDerivedType - Create a derived type like const qualified type,
600 /// pointer, typedef, etc.
601 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
605 uint64_t SizeInBits, uint64_t AlignInBits,
606 uint64_t OffsetInBits, unsigned Flags,
609 /// CreateDerivedType - Create a derived type like const qualified type,
610 /// pointer, typedef, etc.
611 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
615 Constant *SizeInBits,
616 Constant *AlignInBits,
617 Constant *OffsetInBits, unsigned Flags,
620 /// CreateCompositeType - Create a composite type like array, struct, etc.
621 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
626 uint64_t AlignInBits,
627 uint64_t OffsetInBits, unsigned Flags,
630 unsigned RunTimeLang = 0,
631 MDNode *ContainingType = 0);
633 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
634 DIType CreateArtificialType(DIType Ty);
636 /// CreateCompositeType - Create a composite type like array, struct, etc.
637 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
641 Constant *SizeInBits,
642 Constant *AlignInBits,
643 Constant *OffsetInBits,
647 unsigned RunTimeLang = 0);
649 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
650 /// See comments in DISubprogram for descriptions of these fields.
651 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
652 StringRef DisplayName,
653 StringRef LinkageName,
654 DIFile F, unsigned LineNo,
655 DIType Ty, bool isLocalToUnit,
660 bool isArtificial = 0,
661 bool isOptimized = false);
663 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
664 /// given declaration.
665 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
667 /// CreateGlobalVariable - Create a new descriptor for the specified global.
669 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
670 StringRef DisplayName,
671 StringRef LinkageName,
673 unsigned LineNo, DIType Ty, bool isLocalToUnit,
674 bool isDefinition, llvm::GlobalVariable *GV);
676 /// CreateVariable - Create a new descriptor for the specified variable.
677 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
679 DIFile F, unsigned LineNo,
680 DIType Ty, bool OptimizedBuild = false);
682 /// CreateComplexVariable - Create a new descriptor for the specified
683 /// variable which has a complex address expression for its address.
684 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
685 const std::string &Name,
686 DIFile F, unsigned LineNo,
688 SmallVector<Value *, 9> &addr);
690 /// CreateLexicalBlock - This creates a descriptor for a lexical block
691 /// with the specified parent context.
692 DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0,
695 /// CreateNameSpace - This creates new descriptor for a namespace
696 /// with the specified parent context.
697 DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
698 DIFile F, unsigned LineNo);
700 /// CreateLocation - Creates a debug info location.
701 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
702 DIScope S, DILocation OrigLoc);
704 /// CreateLocation - Creates a debug info location.
705 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
706 DIScope S, MDNode *OrigLoc = 0);
708 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
709 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
710 BasicBlock *InsertAtEnd);
712 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
713 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
714 Instruction *InsertBefore);
716 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
717 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
718 DIVariable D, BasicBlock *InsertAtEnd);
720 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
721 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
722 DIVariable D, Instruction *InsertBefore);
724 Constant *GetTagConstant(unsigned TAG);
727 bool getLocationInfo(const Value *V, std::string &DisplayName,
728 std::string &Type, unsigned &LineNo, std::string &File,
731 /// getDISubprogram - Find subprogram that is enclosing this scope.
732 DISubprogram getDISubprogram(const MDNode *Scope);
734 /// getDICompositeType - Find underlying composite type.
735 DICompositeType getDICompositeType(DIType T);
737 class DebugInfoFinder {
739 /// processModule - Process entire module and collect debug info
741 void processModule(Module &M);
744 /// processType - Process DIType.
745 void processType(DIType DT);
747 /// processLexicalBlock - Process DILexicalBlock.
748 void processLexicalBlock(DILexicalBlock LB);
750 /// processSubprogram - Process DISubprogram.
751 void processSubprogram(DISubprogram SP);
753 /// processDeclare - Process DbgDeclareInst.
754 void processDeclare(DbgDeclareInst *DDI);
756 /// processLocation - Process DILocation.
757 void processLocation(DILocation Loc);
759 /// addCompileUnit - Add compile unit into CUs.
760 bool addCompileUnit(DICompileUnit CU);
762 /// addGlobalVariable - Add global variable into GVs.
763 bool addGlobalVariable(DIGlobalVariable DIG);
765 // addSubprogram - Add subprgoram into SPs.
766 bool addSubprogram(DISubprogram SP);
768 /// addType - Add type into Tys.
769 bool addType(DIType DT);
772 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
773 iterator compile_unit_begin() const { return CUs.begin(); }
774 iterator compile_unit_end() const { return CUs.end(); }
775 iterator subprogram_begin() const { return SPs.begin(); }
776 iterator subprogram_end() const { return SPs.end(); }
777 iterator global_variable_begin() const { return GVs.begin(); }
778 iterator global_variable_end() const { return GVs.end(); }
779 iterator type_begin() const { return TYs.begin(); }
780 iterator type_end() const { return TYs.end(); }
782 unsigned compile_unit_count() const { return CUs.size(); }
783 unsigned global_variable_count() const { return GVs.size(); }
784 unsigned subprogram_count() const { return SPs.size(); }
785 unsigned type_count() const { return TYs.size(); }
788 SmallVector<MDNode *, 8> CUs; // Compile Units
789 SmallVector<MDNode *, 8> SPs; // Subprograms
790 SmallVector<MDNode *, 8> GVs; // Global Variables;
791 SmallVector<MDNode *, 8> TYs; // Types
792 SmallPtrSet<MDNode *, 64> NodesSeen;
794 } // end namespace llvm