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); }
396 StringRef getFilename() const {
397 if (getVersion() == llvm::LLVMDebugVersion7)
398 return getCompileUnit().getFilename();
400 DIFile F = getFieldAs<DIFile>(6);
401 return F.getFilename();
404 StringRef getDirectory() const {
405 if (getVersion() == llvm::LLVMDebugVersion7)
406 return getCompileUnit().getFilename();
408 DIFile F = getFieldAs<DIFile>(6);
409 return F.getDirectory();
412 /// Verify - Verify that a subprogram descriptor is well formed.
415 /// dump - print subprogram.
418 /// describes - Return true if this subprogram provides debugging
419 /// information for the function F.
420 bool describes(const Function *F);
423 /// DIGlobalVariable - This is a wrapper for a global variable.
424 class DIGlobalVariable : public DIGlobal {
426 explicit DIGlobalVariable(MDNode *N = 0) : DIGlobal(N) {}
428 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
430 /// Verify - Verify that a global variable descriptor is well formed.
433 /// dump - print global variable.
437 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
439 class DIVariable : public DIDescriptor {
441 explicit DIVariable(MDNode *N = 0)
444 DIScope getContext() const { return getFieldAs<DIScope>(1); }
445 StringRef getName() const { return getStringField(2); }
446 DICompileUnit getCompileUnit() const{
447 if (getVersion() == llvm::LLVMDebugVersion7)
448 return getFieldAs<DICompileUnit>(3);
450 DIFile F = getFieldAs<DIFile>(3);
451 return F.getCompileUnit();
453 unsigned getLineNumber() const { return getUnsignedField(4); }
454 DIType getType() const { return getFieldAs<DIType>(5); }
457 /// Verify - Verify that a variable descriptor is well formed.
460 /// HasComplexAddr - Return true if the variable has a complex address.
461 bool hasComplexAddress() const {
462 return getNumAddrElements() > 0;
465 unsigned getNumAddrElements() const;
467 uint64_t getAddrElement(unsigned Idx) const {
468 return getUInt64Field(Idx+6);
471 /// isBlockByrefVariable - Return true if the variable was declared as
472 /// a "__block" variable (Apple Blocks).
473 bool isBlockByrefVariable() const {
474 return getType().isBlockByrefStruct();
477 /// isInlinedFnArgument - Return trule if this variable provides debugging
478 /// information for an inlined function arguments.
479 bool isInlinedFnArgument(const Function *CurFn);
481 /// dump - print variable.
485 /// DILexicalBlock - This is a wrapper for a lexical block.
486 class DILexicalBlock : public DIScope {
488 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {}
489 DIScope getContext() const { return getFieldAs<DIScope>(1); }
490 StringRef getDirectory() const { return getContext().getDirectory(); }
491 StringRef getFilename() const { return getContext().getFilename(); }
492 unsigned getLineNumber() const { return getUnsignedField(2); }
493 unsigned getColumnNumber() const { return getUnsignedField(3); }
496 /// DINameSpace - A wrapper for a C++ style name space.
497 class DINameSpace : public DIScope {
499 explicit DINameSpace(MDNode *N = 0) : DIScope(N) {}
500 DIScope getContext() const { return getFieldAs<DIScope>(1); }
501 StringRef getName() const { return getStringField(2); }
502 StringRef getDirectory() const { return getContext().getDirectory(); }
503 StringRef getFilename() const { return getContext().getFilename(); }
504 DICompileUnit getCompileUnit() const{
505 if (getVersion() == llvm::LLVMDebugVersion7)
506 return getFieldAs<DICompileUnit>(3);
508 DIFile F = getFieldAs<DIFile>(3);
509 return F.getCompileUnit();
511 unsigned getLineNumber() const { return getUnsignedField(4); }
514 /// DILocation - This object holds location information. This object
515 /// is not associated with any DWARF tag.
516 class DILocation : public DIDescriptor {
518 explicit DILocation(MDNode *N) : DIDescriptor(N) { }
520 unsigned getLineNumber() const { return getUnsignedField(0); }
521 unsigned getColumnNumber() const { return getUnsignedField(1); }
522 DIScope getScope() const { return getFieldAs<DIScope>(2); }
523 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
524 StringRef getFilename() const { return getScope().getFilename(); }
525 StringRef getDirectory() const { return getScope().getDirectory(); }
529 /// DIFactory - This object assists with the construction of the various
533 LLVMContext& VMContext;
535 Function *DeclareFn; // llvm.dbg.declare
536 Function *ValueFn; // llvm.dbg.value
538 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
539 void operator=(const DIFactory&); // DO NOT IMPLEMENT
541 enum ComplexAddrKind { OpPlus=1, OpDeref };
543 explicit DIFactory(Module &m);
545 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
546 /// This implicitly uniques the arrays created.
547 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
549 /// GetOrCreateSubrange - Create a descriptor for a value range. This
550 /// implicitly uniques the values returned.
551 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
553 /// CreateCompileUnit - Create a new descriptor for the specified compile
555 DICompileUnit CreateCompileUnit(unsigned LangID,
560 bool isOptimized = false,
561 StringRef Flags = "",
562 unsigned RunTimeVer = 0);
564 /// CreateFile - Create a new descriptor for the specified file.
565 DIFile CreateFile(StringRef Filename, StringRef Directory, DICompileUnit CU);
567 /// CreateEnumerator - Create a single enumerator value.
568 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
570 /// CreateBasicType - Create a basic type like int, float, etc.
571 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
572 DIFile F, unsigned LineNumber,
573 uint64_t SizeInBits, uint64_t AlignInBits,
574 uint64_t OffsetInBits, unsigned Flags,
577 /// CreateBasicType - Create a basic type like int, float, etc.
578 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
579 DIFile F, unsigned LineNumber,
580 Constant *SizeInBits, Constant *AlignInBits,
581 Constant *OffsetInBits, unsigned Flags,
584 /// CreateDerivedType - Create a derived type like const qualified type,
585 /// pointer, typedef, etc.
586 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
590 uint64_t SizeInBits, uint64_t AlignInBits,
591 uint64_t OffsetInBits, unsigned Flags,
594 /// CreateDerivedType - Create a derived type like const qualified type,
595 /// pointer, typedef, etc.
596 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
600 Constant *SizeInBits,
601 Constant *AlignInBits,
602 Constant *OffsetInBits, unsigned Flags,
605 /// CreateCompositeType - Create a composite type like array, struct, etc.
606 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
611 uint64_t AlignInBits,
612 uint64_t OffsetInBits, unsigned Flags,
615 unsigned RunTimeLang = 0,
616 MDNode *ContainingType = 0);
618 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
619 DIType CreateArtificialType(DIType Ty);
621 /// CreateCompositeType - Create a composite type like array, struct, etc.
622 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
626 Constant *SizeInBits,
627 Constant *AlignInBits,
628 Constant *OffsetInBits,
632 unsigned RunTimeLang = 0);
634 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
635 /// See comments in DISubprogram for descriptions of these fields.
636 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
637 StringRef DisplayName,
638 StringRef LinkageName,
639 DIFile F, unsigned LineNo,
640 DIType Ty, bool isLocalToUnit,
645 bool isArtificial = 0);
647 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
648 /// given declaration.
649 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
651 /// CreateGlobalVariable - Create a new descriptor for the specified global.
653 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
654 StringRef DisplayName,
655 StringRef LinkageName,
657 unsigned LineNo, DIType Ty, bool isLocalToUnit,
658 bool isDefinition, llvm::GlobalVariable *GV);
660 /// CreateVariable - Create a new descriptor for the specified variable.
661 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
663 DIFile F, unsigned LineNo,
666 /// CreateComplexVariable - Create a new descriptor for the specified
667 /// variable which has a complex address expression for its address.
668 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
669 const std::string &Name,
670 DIFile F, unsigned LineNo,
672 SmallVector<Value *, 9> &addr);
674 /// CreateLexicalBlock - This creates a descriptor for a lexical block
675 /// with the specified parent context.
676 DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0,
679 /// CreateNameSpace - This creates new descriptor for a namespace
680 /// with the specified parent context.
681 DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
682 DIFile F, unsigned LineNo);
684 /// CreateLocation - Creates a debug info location.
685 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
686 DIScope S, DILocation OrigLoc);
688 /// CreateLocation - Creates a debug info location.
689 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
690 DIScope S, MDNode *OrigLoc = 0);
692 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
693 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
694 BasicBlock *InsertAtEnd);
696 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
697 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
698 Instruction *InsertBefore);
700 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
701 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
702 DIVariable D, BasicBlock *InsertAtEnd);
704 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
705 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
706 DIVariable D, Instruction *InsertBefore);
708 Constant *GetTagConstant(unsigned TAG);
711 bool getLocationInfo(const Value *V, std::string &DisplayName,
712 std::string &Type, unsigned &LineNo, std::string &File,
715 /// getDISubprogram - Find subprogram that is enclosing this scope.
716 DISubprogram getDISubprogram(MDNode *Scope);
718 /// getDICompositeType - Find underlying composite type.
719 DICompositeType getDICompositeType(DIType T);
721 class DebugInfoFinder {
723 /// processModule - Process entire module and collect debug info
725 void processModule(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(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 subprgoram into SPs.
750 bool addSubprogram(DISubprogram SP);
752 /// addType - Add type into Tys.
753 bool addType(DIType DT);
756 typedef SmallVector<MDNode *, 8>::iterator iterator;
757 iterator compile_unit_begin() { return CUs.begin(); }
758 iterator compile_unit_end() { return CUs.end(); }
759 iterator subprogram_begin() { return SPs.begin(); }
760 iterator subprogram_end() { return SPs.end(); }
761 iterator global_variable_begin() { return GVs.begin(); }
762 iterator global_variable_end() { return GVs.end(); }
763 iterator type_begin() { return TYs.begin(); }
764 iterator type_end() { return TYs.end(); }
766 unsigned compile_unit_count() { return CUs.size(); }
767 unsigned global_variable_count() { return GVs.size(); }
768 unsigned subprogram_count() { return SPs.size(); }
769 unsigned type_count() { 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