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"
38 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
39 /// This should not be stored in a container, because underly MDNode may
40 /// change in certain situations.
45 StringRef getStringField(unsigned Elt) const;
46 unsigned getUnsignedField(unsigned Elt) const {
47 return (unsigned)getUInt64Field(Elt);
49 uint64_t getUInt64Field(unsigned Elt) const;
50 DIDescriptor getDescriptorField(unsigned Elt) const;
52 template <typename DescTy>
53 DescTy getFieldAs(unsigned Elt) const {
54 return DescTy(getDescriptorField(Elt).getNode());
57 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
60 explicit DIDescriptor() : DbgNode(0) {}
61 explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
63 bool Verify() const { return DbgNode != 0; }
65 MDNode *getNode() const { return DbgNode; }
67 unsigned getVersion() const {
68 return getUnsignedField(0) & LLVMDebugVersionMask;
71 unsigned getTag() const {
72 return getUnsignedField(0) & ~LLVMDebugVersionMask;
75 /// ValidDebugInfo - Return true if N represents valid debug info value.
76 static bool ValidDebugInfo(MDNode *N, unsigned OptLevel);
78 /// dump - print descriptor.
81 bool isDerivedType() const;
82 bool isCompositeType() const;
83 bool isBasicType() const;
84 bool isVariable() const;
85 bool isSubprogram() const;
86 bool isGlobalVariable() const;
89 bool isCompileUnit() const;
90 bool isNameSpace() const;
91 bool isLexicalBlock() const;
92 bool isSubrange() const;
93 bool isEnumerator() const;
95 bool isGlobal() const;
98 /// DISubrange - This is used to represent ranges, for array bounds.
99 class DISubrange : public DIDescriptor {
101 explicit DISubrange(MDNode *N = 0) : DIDescriptor(N) {}
103 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
104 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
107 /// DIArray - This descriptor holds an array of descriptors.
108 class DIArray : public DIDescriptor {
110 explicit DIArray(MDNode *N = 0)
113 unsigned getNumElements() const;
114 DIDescriptor getElement(unsigned Idx) const {
115 return getDescriptorField(Idx);
119 /// DIScope - A base class for various scopes.
120 class DIScope : public DIDescriptor {
122 explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {}
123 virtual ~DIScope() {}
125 StringRef getFilename() const;
126 StringRef getDirectory() const;
129 /// DICompileUnit - A wrapper for a compile unit.
130 class DICompileUnit : public DIScope {
132 explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {}
134 unsigned getLanguage() const { return getUnsignedField(2); }
135 StringRef getFilename() const { return getStringField(3); }
136 StringRef getDirectory() const { return getStringField(4); }
137 StringRef getProducer() const { return getStringField(5); }
139 /// isMain - Each input file is encoded as a separate compile unit in LLVM
140 /// debugging information output. However, many target specific tool chains
141 /// prefer to encode only one compile unit in an object file. In this
142 /// situation, the LLVM code generator will include debugging information
143 /// entities in the compile unit that is marked as main compile unit. The
144 /// code generator accepts maximum one main compile unit per module. If a
145 /// module does not contain any main compile unit then the code generator
146 /// will emit multiple compile units in the output object file.
148 bool isMain() const { return getUnsignedField(6); }
149 bool isOptimized() const { return getUnsignedField(7); }
150 StringRef getFlags() const { return getStringField(8); }
151 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
153 /// Verify - Verify that a compile unit is well formed.
156 /// dump - print compile unit.
160 /// DIFile - This is a wrapper for a file.
161 class DIFile : public DIScope {
163 explicit DIFile(MDNode *N = 0) : DIScope(N) {
164 if (DbgNode && !isFile())
167 StringRef getFilename() const { return getStringField(1); }
168 StringRef getDirectory() const { return getStringField(2); }
169 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
172 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
173 /// FIXME: it seems strange that this doesn't have either a reference to the
174 /// type/precision or a file/line pair for location info.
175 class DIEnumerator : public DIDescriptor {
177 explicit DIEnumerator(MDNode *N = 0) : DIDescriptor(N) {}
179 StringRef getName() const { return getStringField(1); }
180 uint64_t getEnumValue() const { return getUInt64Field(2); }
183 /// DIType - This is a wrapper for a type.
184 /// FIXME: Types should be factored much better so that CV qualifiers and
185 /// others do not require a huge and empty descriptor full of zeros.
186 class DIType : public DIScope {
189 FlagPrivate = 1 << 0,
190 FlagProtected = 1 << 1,
191 FlagFwdDecl = 1 << 2,
192 FlagAppleBlock = 1 << 3,
193 FlagBlockByrefStruct = 1 << 4,
194 FlagVirtual = 1 << 5,
195 FlagArtificial = 1 << 6 // To identify artificial arguments in
196 // a subroutine type. e.g. "this" in c++.
200 // This ctor is used when the Tag has already been validated by a derived
202 DIType(MDNode *N, bool, bool) : DIScope(N) {}
206 /// Verify - Verify that a type descriptor is well formed.
209 explicit DIType(MDNode *N);
213 DIScope getContext() const { return getFieldAs<DIScope>(1); }
214 StringRef getName() const { return getStringField(2); }
215 DICompileUnit getCompileUnit() const{
216 if (getVersion() == llvm::LLVMDebugVersion7)
217 return getFieldAs<DICompileUnit>(3);
219 DIFile F = getFieldAs<DIFile>(3);
220 return F.getCompileUnit();
222 unsigned getLineNumber() const { return getUnsignedField(4); }
223 uint64_t getSizeInBits() const { return getUInt64Field(5); }
224 uint64_t getAlignInBits() const { return getUInt64Field(6); }
225 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
226 // carry this is just plain insane.
227 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
228 unsigned getFlags() const { return getUnsignedField(8); }
229 bool isPrivate() const {
230 return (getFlags() & FlagPrivate) != 0;
232 bool isProtected() const {
233 return (getFlags() & FlagProtected) != 0;
235 bool isForwardDecl() const {
236 return (getFlags() & FlagFwdDecl) != 0;
238 // isAppleBlock - Return true if this is the Apple Blocks extension.
239 bool isAppleBlockExtension() const {
240 return (getFlags() & FlagAppleBlock) != 0;
242 bool isBlockByrefStruct() const {
243 return (getFlags() & FlagBlockByrefStruct) != 0;
245 bool isVirtual() const {
246 return (getFlags() & FlagVirtual) != 0;
248 bool isArtificial() const {
249 return (getFlags() & FlagArtificial) != 0;
251 bool isValid() const {
252 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
254 StringRef getFilename() const { return getCompileUnit().getFilename();}
255 StringRef getDirectory() const { return getCompileUnit().getDirectory();}
256 /// dump - print type.
260 /// DIBasicType - A basic type, like 'int' or 'float'.
261 class DIBasicType : public DIType {
263 explicit DIBasicType(MDNode *N = 0) : DIType(N) {}
265 unsigned getEncoding() const { return getUnsignedField(9); }
267 /// dump - print basic type.
271 /// DIDerivedType - A simple derived type, like a const qualified type,
272 /// a typedef, a pointer or reference, etc.
273 class DIDerivedType : public DIType {
275 explicit DIDerivedType(MDNode *N, bool, bool)
276 : DIType(N, true, true) {}
278 explicit DIDerivedType(MDNode *N = 0)
279 : DIType(N, true, true) {}
281 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
283 /// getOriginalTypeSize - If this type is derived from a base type then
284 /// return base type size.
285 uint64_t getOriginalTypeSize() const;
286 /// dump - print derived type.
289 /// replaceAllUsesWith - Replace all uses of debug info referenced by
290 /// this descriptor. After this completes, the current debug info value
292 void replaceAllUsesWith(DIDescriptor &D);
295 /// DICompositeType - This descriptor holds a type that can refer to multiple
296 /// other types, like a function or struct.
297 /// FIXME: Why is this a DIDerivedType??
298 class DICompositeType : public DIDerivedType {
300 explicit DICompositeType(MDNode *N = 0)
301 : DIDerivedType(N, true, true) {
302 if (N && !isCompositeType())
306 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
307 unsigned getRunTimeLang() const { return getUnsignedField(11); }
308 DICompositeType getContainingType() const {
309 return getFieldAs<DICompositeType>(12);
312 /// Verify - Verify that a composite type descriptor is well formed.
315 /// dump - print composite type.
319 /// DIGlobal - This is a common class for global variables and subprograms.
320 class DIGlobal : public DIDescriptor {
322 explicit DIGlobal(MDNode *N) : DIDescriptor(N) {}
325 virtual ~DIGlobal() {}
327 DIScope getContext() const { return getFieldAs<DIScope>(2); }
328 StringRef getName() const { return getStringField(3); }
329 StringRef getDisplayName() const { return getStringField(4); }
330 StringRef getLinkageName() const { return getStringField(5); }
331 DICompileUnit getCompileUnit() const{
332 if (getVersion() == llvm::LLVMDebugVersion7)
333 return getFieldAs<DICompileUnit>(6);
335 DIFile F = getFieldAs<DIFile>(6);
336 return F.getCompileUnit();
339 unsigned getLineNumber() const { return getUnsignedField(7); }
340 DIType getType() const { return getFieldAs<DIType>(8); }
342 /// isLocalToUnit - Return true if this subprogram is local to the current
343 /// compile unit, like 'static' in C.
344 unsigned isLocalToUnit() const { return getUnsignedField(9); }
345 unsigned isDefinition() const { return getUnsignedField(10); }
347 /// dump - print global.
351 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
352 class DISubprogram : public DIScope {
354 explicit DISubprogram(MDNode *N = 0) : DIScope(N) {}
356 DIScope getContext() const { return getFieldAs<DIScope>(2); }
357 StringRef getName() const { return getStringField(3); }
358 StringRef getDisplayName() const { return getStringField(4); }
359 StringRef getLinkageName() const { return getStringField(5); }
360 DICompileUnit getCompileUnit() const{
361 if (getVersion() == llvm::LLVMDebugVersion7)
362 return getFieldAs<DICompileUnit>(6);
364 DIFile F = getFieldAs<DIFile>(6);
365 return F.getCompileUnit();
367 unsigned getLineNumber() const { return getUnsignedField(7); }
368 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
370 /// getReturnTypeName - Subprogram return types are encoded either as
371 /// DIType or as DICompositeType.
372 StringRef getReturnTypeName() const {
373 DICompositeType DCT(getFieldAs<DICompositeType>(8));
375 DIArray A = DCT.getTypeArray();
376 DIType T(A.getElement(0).getNode());
379 DIType T(getFieldAs<DIType>(8));
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(9); }
386 unsigned isDefinition() const { return getUnsignedField(10); }
388 unsigned getVirtuality() const { return getUnsignedField(11); }
389 unsigned getVirtualIndex() const { return getUnsignedField(12); }
391 DICompositeType getContainingType() const {
392 return getFieldAs<DICompositeType>(13);
394 unsigned isArtificial() const { return getUnsignedField(14); }
395 unsigned isOptimized() const;
397 StringRef getFilename() const {
398 if (getVersion() == llvm::LLVMDebugVersion7)
399 return getCompileUnit().getFilename();
401 DIFile F = getFieldAs<DIFile>(6);
402 return F.getFilename();
405 StringRef getDirectory() const {
406 if (getVersion() == llvm::LLVMDebugVersion7)
407 return getCompileUnit().getFilename();
409 DIFile F = getFieldAs<DIFile>(6);
410 return F.getDirectory();
413 /// Verify - Verify that a subprogram descriptor is well formed.
416 /// dump - print subprogram.
419 /// describes - Return true if this subprogram provides debugging
420 /// information for the function F.
421 bool describes(const Function *F);
424 /// DIGlobalVariable - This is a wrapper for a global variable.
425 class DIGlobalVariable : public DIGlobal {
427 explicit DIGlobalVariable(MDNode *N = 0) : DIGlobal(N) {}
429 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
431 /// Verify - Verify that a global variable descriptor is well formed.
434 /// dump - print global variable.
438 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
440 class DIVariable : public DIDescriptor {
442 explicit DIVariable(MDNode *N = 0)
445 DIScope getContext() const { return getFieldAs<DIScope>(1); }
446 StringRef getName() const { return getStringField(2); }
447 DICompileUnit getCompileUnit() const{
448 if (getVersion() == llvm::LLVMDebugVersion7)
449 return getFieldAs<DICompileUnit>(3);
451 DIFile F = getFieldAs<DIFile>(3);
452 return F.getCompileUnit();
454 unsigned getLineNumber() const { return getUnsignedField(4); }
455 DIType getType() const { return getFieldAs<DIType>(5); }
458 /// Verify - Verify that a variable descriptor is well formed.
461 /// HasComplexAddr - Return true if the variable has a complex address.
462 bool hasComplexAddress() const {
463 return getNumAddrElements() > 0;
466 unsigned getNumAddrElements() const;
468 uint64_t getAddrElement(unsigned Idx) const {
469 return getUInt64Field(Idx+6);
472 /// isBlockByrefVariable - Return true if the variable was declared as
473 /// a "__block" variable (Apple Blocks).
474 bool isBlockByrefVariable() const {
475 return getType().isBlockByrefStruct();
478 /// isInlinedFnArgument - Return trule if this variable provides debugging
479 /// information for an inlined function arguments.
480 bool isInlinedFnArgument(const Function *CurFn);
482 /// dump - print variable.
486 /// DILexicalBlock - This is a wrapper for a lexical block.
487 class DILexicalBlock : public DIScope {
489 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {}
490 DIScope getContext() const { return getFieldAs<DIScope>(1); }
491 StringRef getDirectory() const { return getContext().getDirectory(); }
492 StringRef getFilename() const { return getContext().getFilename(); }
493 unsigned getLineNumber() const { return getUnsignedField(2); }
494 unsigned getColumnNumber() const { return getUnsignedField(3); }
497 /// DINameSpace - A wrapper for a C++ style name space.
498 class DINameSpace : public DIScope {
500 explicit DINameSpace(MDNode *N = 0) : DIScope(N) {}
501 DIScope getContext() const { return getFieldAs<DIScope>(1); }
502 StringRef getName() const { return getStringField(2); }
503 StringRef getDirectory() const { return getContext().getDirectory(); }
504 StringRef getFilename() const { return getContext().getFilename(); }
505 DICompileUnit getCompileUnit() const{
506 if (getVersion() == llvm::LLVMDebugVersion7)
507 return getFieldAs<DICompileUnit>(3);
509 DIFile F = getFieldAs<DIFile>(3);
510 return F.getCompileUnit();
512 unsigned getLineNumber() const { return getUnsignedField(4); }
515 /// DILocation - This object holds location information. This object
516 /// is not associated with any DWARF tag.
517 class DILocation : public DIDescriptor {
519 explicit DILocation(MDNode *N) : DIDescriptor(N) { }
521 unsigned getLineNumber() const { return getUnsignedField(0); }
522 unsigned getColumnNumber() const { return getUnsignedField(1); }
523 DIScope getScope() const { return getFieldAs<DIScope>(2); }
524 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
525 StringRef getFilename() const { return getScope().getFilename(); }
526 StringRef getDirectory() const { return getScope().getDirectory(); }
530 /// DIFactory - This object assists with the construction of the various
534 LLVMContext& VMContext;
536 Function *DeclareFn; // llvm.dbg.declare
537 Function *ValueFn; // llvm.dbg.value
539 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
540 void operator=(const DIFactory&); // DO NOT IMPLEMENT
542 enum ComplexAddrKind { OpPlus=1, OpDeref };
544 explicit DIFactory(Module &m);
546 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
547 /// This implicitly uniques the arrays created.
548 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
550 /// GetOrCreateSubrange - Create a descriptor for a value range. This
551 /// implicitly uniques the values returned.
552 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
554 /// CreateCompileUnit - Create a new descriptor for the specified compile
556 DICompileUnit CreateCompileUnit(unsigned LangID,
561 bool isOptimized = false,
562 StringRef Flags = "",
563 unsigned RunTimeVer = 0);
565 /// CreateFile - Create a new descriptor for the specified file.
566 DIFile CreateFile(StringRef Filename, StringRef Directory, DICompileUnit CU);
568 /// CreateEnumerator - Create a single enumerator value.
569 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
571 /// CreateBasicType - Create a basic type like int, float, etc.
572 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
573 DIFile F, unsigned LineNumber,
574 uint64_t SizeInBits, uint64_t AlignInBits,
575 uint64_t OffsetInBits, unsigned Flags,
578 /// CreateBasicType - Create a basic type like int, float, etc.
579 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
580 DIFile F, unsigned LineNumber,
581 Constant *SizeInBits, Constant *AlignInBits,
582 Constant *OffsetInBits, unsigned Flags,
585 /// CreateDerivedType - Create a derived type like const qualified type,
586 /// pointer, typedef, etc.
587 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
591 uint64_t SizeInBits, uint64_t AlignInBits,
592 uint64_t OffsetInBits, unsigned Flags,
595 /// CreateDerivedType - Create a derived type like const qualified type,
596 /// pointer, typedef, etc.
597 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
601 Constant *SizeInBits,
602 Constant *AlignInBits,
603 Constant *OffsetInBits, unsigned Flags,
606 /// CreateCompositeType - Create a composite type like array, struct, etc.
607 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
612 uint64_t AlignInBits,
613 uint64_t OffsetInBits, unsigned Flags,
616 unsigned RunTimeLang = 0,
617 MDNode *ContainingType = 0);
619 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
620 DIType CreateArtificialType(DIType Ty);
622 /// CreateCompositeType - Create a composite type like array, struct, etc.
623 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
627 Constant *SizeInBits,
628 Constant *AlignInBits,
629 Constant *OffsetInBits,
633 unsigned RunTimeLang = 0);
635 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
636 /// See comments in DISubprogram for descriptions of these fields.
637 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
638 StringRef DisplayName,
639 StringRef LinkageName,
640 DIFile F, unsigned LineNo,
641 DIType Ty, bool isLocalToUnit,
646 bool isArtificial = 0,
647 bool isOptimized = false);
649 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
650 /// given declaration.
651 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
653 /// CreateGlobalVariable - Create a new descriptor for the specified global.
655 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
656 StringRef DisplayName,
657 StringRef LinkageName,
659 unsigned LineNo, DIType Ty, bool isLocalToUnit,
660 bool isDefinition, llvm::GlobalVariable *GV);
662 /// CreateVariable - Create a new descriptor for the specified variable.
663 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
665 DIFile F, unsigned LineNo,
668 /// CreateComplexVariable - Create a new descriptor for the specified
669 /// variable which has a complex address expression for its address.
670 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
671 const std::string &Name,
672 DIFile F, unsigned LineNo,
674 SmallVector<Value *, 9> &addr);
676 /// CreateLexicalBlock - This creates a descriptor for a lexical block
677 /// with the specified parent context.
678 DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0,
681 /// CreateNameSpace - This creates new descriptor for a namespace
682 /// with the specified parent context.
683 DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
684 DIFile F, unsigned LineNo);
686 /// CreateLocation - Creates a debug info location.
687 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
688 DIScope S, DILocation OrigLoc);
690 /// CreateLocation - Creates a debug info location.
691 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
692 DIScope S, MDNode *OrigLoc = 0);
694 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
695 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
696 BasicBlock *InsertAtEnd);
698 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
699 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
700 Instruction *InsertBefore);
702 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
703 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
704 DIVariable D, BasicBlock *InsertAtEnd);
706 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
707 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
708 DIVariable D, Instruction *InsertBefore);
710 Constant *GetTagConstant(unsigned TAG);
713 bool getLocationInfo(const Value *V, std::string &DisplayName,
714 std::string &Type, unsigned &LineNo, std::string &File,
717 /// getDISubprogram - Find subprogram that is enclosing this scope.
718 DISubprogram getDISubprogram(MDNode *Scope);
720 /// getDICompositeType - Find underlying composite type.
721 DICompositeType getDICompositeType(DIType T);
723 class DebugInfoFinder {
725 /// processModule - Process entire module and collect debug info
727 void processModule(Module &M);
730 /// processType - Process DIType.
731 void processType(DIType DT);
733 /// processLexicalBlock - Process DILexicalBlock.
734 void processLexicalBlock(DILexicalBlock LB);
736 /// processSubprogram - Process DISubprogram.
737 void processSubprogram(DISubprogram SP);
739 /// processDeclare - Process DbgDeclareInst.
740 void processDeclare(DbgDeclareInst *DDI);
742 /// processLocation - Process DILocation.
743 void processLocation(DILocation Loc);
745 /// addCompileUnit - Add compile unit into CUs.
746 bool addCompileUnit(DICompileUnit CU);
748 /// addGlobalVariable - Add global variable into GVs.
749 bool addGlobalVariable(DIGlobalVariable DIG);
751 // addSubprogram - Add subprgoram into SPs.
752 bool addSubprogram(DISubprogram SP);
754 /// addType - Add type into Tys.
755 bool addType(DIType DT);
758 typedef SmallVector<MDNode *, 8>::iterator iterator;
759 iterator compile_unit_begin() { return CUs.begin(); }
760 iterator compile_unit_end() { return CUs.end(); }
761 iterator subprogram_begin() { return SPs.begin(); }
762 iterator subprogram_end() { return SPs.end(); }
763 iterator global_variable_begin() { return GVs.begin(); }
764 iterator global_variable_end() { return GVs.end(); }
765 iterator type_begin() { return TYs.begin(); }
766 iterator type_end() { return TYs.end(); }
768 unsigned compile_unit_count() { return CUs.size(); }
769 unsigned global_variable_count() { return GVs.size(); }
770 unsigned subprogram_count() { return SPs.size(); }
771 unsigned type_count() { return TYs.size(); }
774 SmallVector<MDNode *, 8> CUs; // Compile Units
775 SmallVector<MDNode *, 8> SPs; // Subprograms
776 SmallVector<MDNode *, 8> GVs; // Global Variables;
777 SmallVector<MDNode *, 8> TYs; // Types
778 SmallPtrSet<MDNode *, 64> NodesSeen;
780 } // end namespace llvm