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"
46 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
47 /// This should not be stored in a container, because underly MDNode may
48 /// change in certain situations.
53 FlagProtected = 1 << 1,
55 FlagAppleBlock = 1 << 3,
56 FlagBlockByrefStruct = 1 << 4,
58 FlagArtificial = 1 << 6,
59 FlagExplicit = 1 << 7,
60 FlagPrototyped = 1 << 8
63 const MDNode *DbgNode;
65 StringRef getStringField(unsigned Elt) const;
66 unsigned getUnsignedField(unsigned Elt) const {
67 return (unsigned)getUInt64Field(Elt);
69 uint64_t getUInt64Field(unsigned Elt) const;
70 DIDescriptor getDescriptorField(unsigned Elt) const;
72 template <typename DescTy>
73 DescTy getFieldAs(unsigned Elt) const {
74 return DescTy(getDescriptorField(Elt));
77 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
78 Constant *getConstantField(unsigned Elt) const;
79 Function *getFunctionField(unsigned Elt) const;
82 explicit DIDescriptor() : DbgNode(0) {}
83 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
84 explicit DIDescriptor(const DIFile F);
85 explicit DIDescriptor(const DISubprogram F);
86 explicit DIDescriptor(const DILexicalBlock F);
87 explicit DIDescriptor(const DIVariable F);
88 explicit DIDescriptor(const DIType F);
90 bool Verify() const { return DbgNode != 0; }
92 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
93 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
95 unsigned getVersion() const {
96 return getUnsignedField(0) & LLVMDebugVersionMask;
99 unsigned getTag() const {
100 return getUnsignedField(0) & ~LLVMDebugVersionMask;
103 /// print - print descriptor.
104 void print(raw_ostream &OS) const;
106 /// dump - print descriptor to dbgs() with a newline.
109 bool isDerivedType() const;
110 bool isCompositeType() const;
111 bool isBasicType() const;
112 bool isVariable() const;
113 bool isSubprogram() const;
114 bool isGlobalVariable() const;
115 bool isScope() const;
117 bool isCompileUnit() const;
118 bool isNameSpace() const;
119 bool isLexicalBlock() const;
120 bool isSubrange() const;
121 bool isEnumerator() const;
123 bool isGlobal() const;
124 bool isUnspecifiedParameter() const;
125 bool isTemplateTypeParameter() const;
126 bool isTemplateValueParameter() const;
129 /// DISubrange - This is used to represent ranges, for array bounds.
130 class DISubrange : public DIDescriptor {
132 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
134 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
135 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
138 /// DIArray - This descriptor holds an array of descriptors.
139 class DIArray : public DIDescriptor {
141 explicit DIArray(const MDNode *N = 0)
144 unsigned getNumElements() const;
145 DIDescriptor getElement(unsigned Idx) const {
146 return getDescriptorField(Idx);
150 /// DIScope - A base class for various scopes.
151 class DIScope : public DIDescriptor {
153 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
154 virtual ~DIScope() {}
156 StringRef getFilename() const;
157 StringRef getDirectory() const;
160 /// DICompileUnit - A wrapper for a compile unit.
161 class DICompileUnit : public DIScope {
163 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
165 unsigned getLanguage() const { return getUnsignedField(2); }
166 StringRef getFilename() const { return getStringField(3); }
167 StringRef getDirectory() const { return getStringField(4); }
168 StringRef getProducer() const { return getStringField(5); }
170 /// isMain - Each input file is encoded as a separate compile unit in LLVM
171 /// debugging information output. However, many target specific tool chains
172 /// prefer to encode only one compile unit in an object file. In this
173 /// situation, the LLVM code generator will include debugging information
174 /// entities in the compile unit that is marked as main compile unit. The
175 /// code generator accepts maximum one main compile unit per module. If a
176 /// module does not contain any main compile unit then the code generator
177 /// will emit multiple compile units in the output object file.
179 bool isMain() const { return getUnsignedField(6) != 0; }
180 bool isOptimized() const { return getUnsignedField(7) != 0; }
181 StringRef getFlags() const { return getStringField(8); }
182 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
184 /// Verify - Verify that a compile unit is well formed.
187 /// print - print compile unit.
188 void print(raw_ostream &OS) const;
190 /// dump - print compile unit to dbgs() with a newline.
194 /// DIFile - This is a wrapper for a file.
195 class DIFile : public DIScope {
197 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
198 if (DbgNode && !isFile())
201 StringRef getFilename() const { return getStringField(1); }
202 StringRef getDirectory() const { return getStringField(2); }
203 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
206 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
207 /// FIXME: it seems strange that this doesn't have either a reference to the
208 /// type/precision or a file/line pair for location info.
209 class DIEnumerator : public DIDescriptor {
211 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
213 StringRef getName() const { return getStringField(1); }
214 uint64_t getEnumValue() const { return getUInt64Field(2); }
217 /// DIType - This is a wrapper for a type.
218 /// FIXME: Types should be factored much better so that CV qualifiers and
219 /// others do not require a huge and empty descriptor full of zeros.
220 class DIType : public DIScope {
223 // This ctor is used when the Tag has already been validated by a derived
225 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
229 /// Verify - Verify that a type descriptor is well formed.
232 explicit DIType(const MDNode *N);
236 DIScope getContext() const { return getFieldAs<DIScope>(1); }
237 StringRef getName() const { return getStringField(2); }
238 DICompileUnit getCompileUnit() const{
239 if (getVersion() == llvm::LLVMDebugVersion7)
240 return getFieldAs<DICompileUnit>(3);
242 return getFieldAs<DIFile>(3).getCompileUnit();
244 DIFile getFile() const { return getFieldAs<DIFile>(3); }
245 unsigned getLineNumber() const { return getUnsignedField(4); }
246 uint64_t getSizeInBits() const { return getUInt64Field(5); }
247 uint64_t getAlignInBits() const { return getUInt64Field(6); }
248 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
249 // carry this is just plain insane.
250 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
251 unsigned getFlags() const { return getUnsignedField(8); }
252 bool isPrivate() const {
253 return (getFlags() & FlagPrivate) != 0;
255 bool isProtected() const {
256 return (getFlags() & FlagProtected) != 0;
258 bool isForwardDecl() const {
259 return (getFlags() & FlagFwdDecl) != 0;
261 // isAppleBlock - Return true if this is the Apple Blocks extension.
262 bool isAppleBlockExtension() const {
263 return (getFlags() & FlagAppleBlock) != 0;
265 bool isBlockByrefStruct() const {
266 return (getFlags() & FlagBlockByrefStruct) != 0;
268 bool isVirtual() const {
269 return (getFlags() & FlagVirtual) != 0;
271 bool isArtificial() const {
272 return (getFlags() & FlagArtificial) != 0;
274 bool isValid() const {
275 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
277 StringRef getDirectory() const {
278 if (getVersion() == llvm::LLVMDebugVersion7)
279 return getCompileUnit().getDirectory();
281 return getFieldAs<DIFile>(3).getDirectory();
283 StringRef getFilename() const {
284 if (getVersion() == llvm::LLVMDebugVersion7)
285 return getCompileUnit().getFilename();
287 return getFieldAs<DIFile>(3).getFilename();
290 /// replaceAllUsesWith - Replace all uses of debug info referenced by
292 void replaceAllUsesWith(DIDescriptor &D);
293 void replaceAllUsesWith(MDNode *D);
295 /// print - print type.
296 void print(raw_ostream &OS) const;
298 /// dump - print type to dbgs() with a newline.
302 /// DIBasicType - A basic type, like 'int' or 'float'.
303 class DIBasicType : public DIType {
305 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
307 unsigned getEncoding() const { return getUnsignedField(9); }
309 /// Verify - Verify that a basic type descriptor is well formed.
312 /// print - print basic type.
313 void print(raw_ostream &OS) const;
315 /// dump - print basic type to dbgs() with a newline.
319 /// DIDerivedType - A simple derived type, like a const qualified type,
320 /// a typedef, a pointer or reference, etc.
321 class DIDerivedType : public DIType {
323 explicit DIDerivedType(const MDNode *N, bool, bool)
324 : DIType(N, true, true) {}
326 explicit DIDerivedType(const MDNode *N = 0)
327 : DIType(N, true, true) {}
329 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
331 /// getOriginalTypeSize - If this type is derived from a base type then
332 /// return base type size.
333 uint64_t getOriginalTypeSize() const;
335 StringRef getObjCPropertyName() const { return getStringField(10); }
336 StringRef getObjCPropertyGetterName() const {
337 return getStringField(11);
339 StringRef getObjCPropertySetterName() const {
340 return getStringField(12);
342 bool isReadOnlyObjCProperty() {
343 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
345 bool isReadWriteObjCProperty() {
346 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
348 bool isAssignObjCProperty() {
349 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
351 bool isRetainObjCProperty() {
352 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
354 bool isCopyObjCProperty() {
355 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
357 bool isNonAtomicObjCProperty() {
358 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
361 /// Verify - Verify that a derived type descriptor is well formed.
364 /// print - print derived type.
365 void print(raw_ostream &OS) const;
367 /// dump - print derived type to dbgs() with a newline.
371 /// DICompositeType - This descriptor holds a type that can refer to multiple
372 /// other types, like a function or struct.
373 /// FIXME: Why is this a DIDerivedType??
374 class DICompositeType : public DIDerivedType {
376 explicit DICompositeType(const MDNode *N = 0)
377 : DIDerivedType(N, true, true) {
378 if (N && !isCompositeType())
382 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
383 unsigned getRunTimeLang() const { return getUnsignedField(11); }
384 DICompositeType getContainingType() const {
385 return getFieldAs<DICompositeType>(12);
387 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
389 /// Verify - Verify that a composite type descriptor is well formed.
392 /// print - print composite type.
393 void print(raw_ostream &OS) const;
395 /// dump - print composite type to dbgs() with a newline.
399 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
400 class DITemplateTypeParameter : public DIDescriptor {
402 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
404 DIScope getContext() const { return getFieldAs<DIScope>(1); }
405 StringRef getName() const { return getStringField(2); }
406 DIType getType() const { return getFieldAs<DIType>(3); }
407 StringRef getFilename() const {
408 return getFieldAs<DIFile>(4).getFilename();
410 StringRef getDirectory() const {
411 return getFieldAs<DIFile>(4).getDirectory();
413 unsigned getLineNumber() const { return getUnsignedField(5); }
414 unsigned getColumnNumber() const { return getUnsignedField(6); }
417 /// DITemplateValueParameter - This is a wrapper for template value parameter.
418 class DITemplateValueParameter : public DIDescriptor {
420 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
422 DIScope getContext() const { return getFieldAs<DIScope>(1); }
423 StringRef getName() const { return getStringField(2); }
424 DIType getType() const { return getFieldAs<DIType>(3); }
425 uint64_t getValue() const { return getUInt64Field(4); }
426 StringRef getFilename() const {
427 return getFieldAs<DIFile>(5).getFilename();
429 StringRef getDirectory() const {
430 return getFieldAs<DIFile>(5).getDirectory();
432 unsigned getLineNumber() const { return getUnsignedField(6); }
433 unsigned getColumnNumber() const { return getUnsignedField(7); }
436 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
437 class DISubprogram : public DIScope {
439 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
441 DIScope getContext() const { return getFieldAs<DIScope>(2); }
442 StringRef getName() const { return getStringField(3); }
443 StringRef getDisplayName() const { return getStringField(4); }
444 StringRef getLinkageName() const { return getStringField(5); }
445 DICompileUnit getCompileUnit() const{
446 if (getVersion() == llvm::LLVMDebugVersion7)
447 return getFieldAs<DICompileUnit>(6);
449 return getFieldAs<DIFile>(6).getCompileUnit();
451 unsigned getLineNumber() const { return getUnsignedField(7); }
452 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
454 /// getReturnTypeName - Subprogram return types are encoded either as
455 /// DIType or as DICompositeType.
456 StringRef getReturnTypeName() const {
457 DICompositeType DCT(getFieldAs<DICompositeType>(8));
459 DIArray A = DCT.getTypeArray();
460 DIType T(A.getElement(0));
463 DIType T(getFieldAs<DIType>(8));
467 /// isLocalToUnit - Return true if this subprogram is local to the current
468 /// compile unit, like 'static' in C.
469 unsigned isLocalToUnit() const { return getUnsignedField(9); }
470 unsigned isDefinition() const { return getUnsignedField(10); }
472 unsigned getVirtuality() const { return getUnsignedField(11); }
473 unsigned getVirtualIndex() const { return getUnsignedField(12); }
475 DICompositeType getContainingType() const {
476 return getFieldAs<DICompositeType>(13);
478 unsigned isArtificial() const {
479 if (getVersion() <= llvm::LLVMDebugVersion8)
480 return getUnsignedField(14);
481 return (getUnsignedField(14) & FlagArtificial) != 0;
483 /// isPrivate - Return true if this subprogram has "private"
484 /// access specifier.
485 bool isPrivate() const {
486 if (getVersion() <= llvm::LLVMDebugVersion8)
488 return (getUnsignedField(14) & FlagPrivate) != 0;
490 /// isProtected - Return true if this subprogram has "protected"
491 /// access specifier.
492 bool isProtected() const {
493 if (getVersion() <= llvm::LLVMDebugVersion8)
495 return (getUnsignedField(14) & FlagProtected) != 0;
497 /// isExplicit - Return true if this subprogram is marked as explicit.
498 bool isExplicit() const {
499 if (getVersion() <= llvm::LLVMDebugVersion8)
501 return (getUnsignedField(14) & FlagExplicit) != 0;
503 /// isPrototyped - Return true if this subprogram is prototyped.
504 bool isPrototyped() const {
505 if (getVersion() <= llvm::LLVMDebugVersion8)
507 return (getUnsignedField(14) & FlagPrototyped) != 0;
510 unsigned isOptimized() const;
512 StringRef getFilename() const {
513 if (getVersion() == llvm::LLVMDebugVersion7)
514 return getCompileUnit().getFilename();
516 return getFieldAs<DIFile>(6).getFilename();
519 StringRef getDirectory() const {
520 if (getVersion() == llvm::LLVMDebugVersion7)
521 return getCompileUnit().getFilename();
523 return getFieldAs<DIFile>(6).getDirectory();
526 /// Verify - Verify that a subprogram descriptor is well formed.
529 /// print - print subprogram.
530 void print(raw_ostream &OS) const;
532 /// dump - print subprogram to dbgs() with a newline.
535 /// describes - Return true if this subprogram provides debugging
536 /// information for the function F.
537 bool describes(const Function *F);
539 Function *getFunction() const { return getFunctionField(16); }
540 DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
543 /// DIGlobalVariable - This is a wrapper for a global variable.
544 class DIGlobalVariable : public DIDescriptor {
546 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
548 DIScope getContext() const { return getFieldAs<DIScope>(2); }
549 StringRef getName() const { return getStringField(3); }
550 StringRef getDisplayName() const { return getStringField(4); }
551 StringRef getLinkageName() const { return getStringField(5); }
552 DICompileUnit getCompileUnit() const{
553 if (getVersion() == llvm::LLVMDebugVersion7)
554 return getFieldAs<DICompileUnit>(6);
556 DIFile F = getFieldAs<DIFile>(6);
557 return F.getCompileUnit();
560 unsigned getLineNumber() const { return getUnsignedField(7); }
561 DIType getType() const { return getFieldAs<DIType>(8); }
562 unsigned isLocalToUnit() const { return getUnsignedField(9); }
563 unsigned isDefinition() const { return getUnsignedField(10); }
565 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
566 Constant *getConstant() const { return getConstantField(11); }
568 /// Verify - Verify that a global variable descriptor is well formed.
571 /// print - print global variable.
572 void print(raw_ostream &OS) const;
574 /// dump - print global variable to dbgs() with a newline.
578 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
580 class DIVariable : public DIDescriptor {
582 explicit DIVariable(const MDNode *N = 0)
585 DIScope getContext() const { return getFieldAs<DIScope>(1); }
586 StringRef getName() const { return getStringField(2); }
587 DICompileUnit getCompileUnit() const{
588 if (getVersion() == llvm::LLVMDebugVersion7)
589 return getFieldAs<DICompileUnit>(3);
591 DIFile F = getFieldAs<DIFile>(3);
592 return F.getCompileUnit();
594 unsigned getLineNumber() const {
595 return (getUnsignedField(4) << 8) >> 8;
597 unsigned getArgNumber() const {
598 unsigned L = getUnsignedField(4);
601 DIType getType() const { return getFieldAs<DIType>(5); }
603 /// isArtificial - Return true if this variable is marked as "artificial".
604 bool isArtificial() const {
605 if (getVersion() <= llvm::LLVMDebugVersion8)
607 return (getUnsignedField(6) & FlagArtificial) != 0;
611 /// Verify - Verify that a variable descriptor is well formed.
614 /// HasComplexAddr - Return true if the variable has a complex address.
615 bool hasComplexAddress() const {
616 return getNumAddrElements() > 0;
619 unsigned getNumAddrElements() const;
621 uint64_t getAddrElement(unsigned Idx) const {
622 return getUInt64Field(Idx+6);
625 /// isBlockByrefVariable - Return true if the variable was declared as
626 /// a "__block" variable (Apple Blocks).
627 bool isBlockByrefVariable() const {
628 return getType().isBlockByrefStruct();
631 /// isInlinedFnArgument - Return trule if this variable provides debugging
632 /// information for an inlined function arguments.
633 bool isInlinedFnArgument(const Function *CurFn);
635 /// print - print variable.
636 void print(raw_ostream &OS) const;
638 /// dump - print variable to dbgs() with a newline.
642 /// DILexicalBlock - This is a wrapper for a lexical block.
643 class DILexicalBlock : public DIScope {
645 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
646 DIScope getContext() const { return getFieldAs<DIScope>(1); }
647 unsigned getLineNumber() const { return getUnsignedField(2); }
648 unsigned getColumnNumber() const { return getUnsignedField(3); }
649 StringRef getDirectory() const {
650 StringRef dir = getFieldAs<DIFile>(4).getDirectory();
651 return !dir.empty() ? dir : getContext().getDirectory();
653 StringRef getFilename() const {
654 StringRef filename = getFieldAs<DIFile>(4).getFilename();
655 return !filename.empty() ? filename : getContext().getFilename();
659 /// DINameSpace - A wrapper for a C++ style name space.
660 class DINameSpace : public DIScope {
662 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
663 DIScope getContext() const { return getFieldAs<DIScope>(1); }
664 StringRef getName() const { return getStringField(2); }
665 StringRef getDirectory() const {
666 return getFieldAs<DIFile>(3).getDirectory();
668 StringRef getFilename() const {
669 return getFieldAs<DIFile>(3).getFilename();
671 DICompileUnit getCompileUnit() const{
672 if (getVersion() == llvm::LLVMDebugVersion7)
673 return getFieldAs<DICompileUnit>(3);
675 return getFieldAs<DIFile>(3).getCompileUnit();
677 unsigned getLineNumber() const { return getUnsignedField(4); }
681 /// DILocation - This object holds location information. This object
682 /// is not associated with any DWARF tag.
683 class DILocation : public DIDescriptor {
685 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
687 unsigned getLineNumber() const { return getUnsignedField(0); }
688 unsigned getColumnNumber() const { return getUnsignedField(1); }
689 DIScope getScope() const { return getFieldAs<DIScope>(2); }
690 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
691 StringRef getFilename() const { return getScope().getFilename(); }
692 StringRef getDirectory() const { return getScope().getDirectory(); }
696 /// getDISubprogram - Find subprogram that is enclosing this scope.
697 DISubprogram getDISubprogram(const MDNode *Scope);
699 /// getDICompositeType - Find underlying composite type.
700 DICompositeType getDICompositeType(DIType T);
702 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
703 /// to hold function specific information.
704 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, StringRef Name);
706 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
707 /// suitable to hold function specific information.
708 NamedMDNode *getFnSpecificMDNode(const Module &M, StringRef Name);
710 class DebugInfoFinder {
712 /// processModule - Process entire module and collect debug info
714 void processModule(Module &M);
717 /// processType - Process DIType.
718 void processType(DIType DT);
720 /// processLexicalBlock - Process DILexicalBlock.
721 void processLexicalBlock(DILexicalBlock LB);
723 /// processSubprogram - Process DISubprogram.
724 void processSubprogram(DISubprogram SP);
726 /// processDeclare - Process DbgDeclareInst.
727 void processDeclare(DbgDeclareInst *DDI);
729 /// processLocation - Process DILocation.
730 void processLocation(DILocation Loc);
732 /// addCompileUnit - Add compile unit into CUs.
733 bool addCompileUnit(DICompileUnit CU);
735 /// addGlobalVariable - Add global variable into GVs.
736 bool addGlobalVariable(DIGlobalVariable DIG);
738 // addSubprogram - Add subprgoram into SPs.
739 bool addSubprogram(DISubprogram SP);
741 /// addType - Add type into Tys.
742 bool addType(DIType DT);
745 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
746 iterator compile_unit_begin() const { return CUs.begin(); }
747 iterator compile_unit_end() const { return CUs.end(); }
748 iterator subprogram_begin() const { return SPs.begin(); }
749 iterator subprogram_end() const { return SPs.end(); }
750 iterator global_variable_begin() const { return GVs.begin(); }
751 iterator global_variable_end() const { return GVs.end(); }
752 iterator type_begin() const { return TYs.begin(); }
753 iterator type_end() const { return TYs.end(); }
755 unsigned compile_unit_count() const { return CUs.size(); }
756 unsigned global_variable_count() const { return GVs.size(); }
757 unsigned subprogram_count() const { return SPs.size(); }
758 unsigned type_count() const { return TYs.size(); }
761 SmallVector<MDNode *, 8> CUs; // Compile Units
762 SmallVector<MDNode *, 8> SPs; // Subprograms
763 SmallVector<MDNode *, 8> GVs; // Global Variables;
764 SmallVector<MDNode *, 8> TYs; // Types
765 SmallPtrSet<MDNode *, 64> NodesSeen;
767 } // end namespace llvm