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,
61 FlagObjcClassComplete = 1 << 9
64 const MDNode *DbgNode;
66 StringRef getStringField(unsigned Elt) const;
67 unsigned getUnsignedField(unsigned Elt) const {
68 return (unsigned)getUInt64Field(Elt);
70 uint64_t getUInt64Field(unsigned Elt) const;
71 DIDescriptor getDescriptorField(unsigned Elt) const;
73 template <typename DescTy>
74 DescTy getFieldAs(unsigned Elt) const {
75 return DescTy(getDescriptorField(Elt));
78 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
79 Constant *getConstantField(unsigned Elt) const;
80 Function *getFunctionField(unsigned Elt) const;
83 explicit DIDescriptor() : DbgNode(0) {}
84 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
85 explicit DIDescriptor(const DIFile F);
86 explicit DIDescriptor(const DISubprogram F);
87 explicit DIDescriptor(const DILexicalBlock F);
88 explicit DIDescriptor(const DIVariable F);
89 explicit DIDescriptor(const DIType F);
91 bool Verify() const { return DbgNode != 0; }
93 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
94 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
96 unsigned getVersion() const {
97 return getUnsignedField(0) & LLVMDebugVersionMask;
100 unsigned getTag() const {
101 return getUnsignedField(0) & ~LLVMDebugVersionMask;
104 /// print - print descriptor.
105 void print(raw_ostream &OS) const;
107 /// dump - print descriptor to dbgs() with a newline.
110 bool isDerivedType() const;
111 bool isCompositeType() const;
112 bool isBasicType() const;
113 bool isVariable() const;
114 bool isSubprogram() const;
115 bool isGlobalVariable() const;
116 bool isScope() const;
118 bool isCompileUnit() const;
119 bool isNameSpace() const;
120 bool isLexicalBlock() const;
121 bool isSubrange() const;
122 bool isEnumerator() const;
124 bool isGlobal() const;
125 bool isUnspecifiedParameter() const;
126 bool isTemplateTypeParameter() const;
127 bool isTemplateValueParameter() const;
130 /// DISubrange - This is used to represent ranges, for array bounds.
131 class DISubrange : public DIDescriptor {
133 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
135 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
136 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
139 /// DIArray - This descriptor holds an array of descriptors.
140 class DIArray : public DIDescriptor {
142 explicit DIArray(const MDNode *N = 0)
145 unsigned getNumElements() const;
146 DIDescriptor getElement(unsigned Idx) const {
147 return getDescriptorField(Idx);
151 /// DIScope - A base class for various scopes.
152 class DIScope : public DIDescriptor {
154 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
155 virtual ~DIScope() {}
157 StringRef getFilename() const;
158 StringRef getDirectory() const;
161 /// DICompileUnit - A wrapper for a compile unit.
162 class DICompileUnit : public DIScope {
164 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
166 unsigned getLanguage() const { return getUnsignedField(2); }
167 StringRef getFilename() const { return getStringField(3); }
168 StringRef getDirectory() const { return getStringField(4); }
169 StringRef getProducer() const { return getStringField(5); }
171 /// isMain - Each input file is encoded as a separate compile unit in LLVM
172 /// debugging information output. However, many target specific tool chains
173 /// prefer to encode only one compile unit in an object file. In this
174 /// situation, the LLVM code generator will include debugging information
175 /// entities in the compile unit that is marked as main compile unit. The
176 /// code generator accepts maximum one main compile unit per module. If a
177 /// module does not contain any main compile unit then the code generator
178 /// will emit multiple compile units in the output object file.
180 bool isMain() const { return getUnsignedField(6) != 0; }
181 bool isOptimized() const { return getUnsignedField(7) != 0; }
182 StringRef getFlags() const { return getStringField(8); }
183 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
185 /// Verify - Verify that a compile unit is well formed.
188 /// print - print compile unit.
189 void print(raw_ostream &OS) const;
191 /// dump - print compile unit to dbgs() with a newline.
195 /// DIFile - This is a wrapper for a file.
196 class DIFile : public DIScope {
198 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
199 if (DbgNode && !isFile())
202 StringRef getFilename() const { return getStringField(1); }
203 StringRef getDirectory() const { return getStringField(2); }
204 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
207 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
208 /// FIXME: it seems strange that this doesn't have either a reference to the
209 /// type/precision or a file/line pair for location info.
210 class DIEnumerator : public DIDescriptor {
212 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
214 StringRef getName() const { return getStringField(1); }
215 uint64_t getEnumValue() const { return getUInt64Field(2); }
218 /// DIType - This is a wrapper for a type.
219 /// FIXME: Types should be factored much better so that CV qualifiers and
220 /// others do not require a huge and empty descriptor full of zeros.
221 class DIType : public DIScope {
224 // This ctor is used when the Tag has already been validated by a derived
226 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
230 /// Verify - Verify that a type descriptor is well formed.
233 explicit DIType(const MDNode *N);
237 DIScope getContext() const { return getFieldAs<DIScope>(1); }
238 StringRef getName() const { return getStringField(2); }
239 DICompileUnit getCompileUnit() const{
240 if (getVersion() == llvm::LLVMDebugVersion7)
241 return getFieldAs<DICompileUnit>(3);
243 return getFieldAs<DIFile>(3).getCompileUnit();
245 DIFile getFile() const { return getFieldAs<DIFile>(3); }
246 unsigned getLineNumber() const { return getUnsignedField(4); }
247 uint64_t getSizeInBits() const { return getUInt64Field(5); }
248 uint64_t getAlignInBits() const { return getUInt64Field(6); }
249 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
250 // carry this is just plain insane.
251 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
252 unsigned getFlags() const { return getUnsignedField(8); }
253 bool isPrivate() const {
254 return (getFlags() & FlagPrivate) != 0;
256 bool isProtected() const {
257 return (getFlags() & FlagProtected) != 0;
259 bool isForwardDecl() const {
260 return (getFlags() & FlagFwdDecl) != 0;
262 // isAppleBlock - Return true if this is the Apple Blocks extension.
263 bool isAppleBlockExtension() const {
264 return (getFlags() & FlagAppleBlock) != 0;
266 bool isBlockByrefStruct() const {
267 return (getFlags() & FlagBlockByrefStruct) != 0;
269 bool isVirtual() const {
270 return (getFlags() & FlagVirtual) != 0;
272 bool isArtificial() const {
273 return (getFlags() & FlagArtificial) != 0;
275 bool isObjcClassComplete() const {
276 return (getFlags() & FlagObjcClassComplete) != 0;
278 bool isValid() const {
279 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
281 StringRef getDirectory() const {
282 if (getVersion() == llvm::LLVMDebugVersion7)
283 return getCompileUnit().getDirectory();
285 return getFieldAs<DIFile>(3).getDirectory();
287 StringRef getFilename() const {
288 if (getVersion() == llvm::LLVMDebugVersion7)
289 return getCompileUnit().getFilename();
291 return getFieldAs<DIFile>(3).getFilename();
294 /// replaceAllUsesWith - Replace all uses of debug info referenced by
296 void replaceAllUsesWith(DIDescriptor &D);
297 void replaceAllUsesWith(MDNode *D);
299 /// print - print type.
300 void print(raw_ostream &OS) const;
302 /// dump - print type to dbgs() with a newline.
306 /// DIBasicType - A basic type, like 'int' or 'float'.
307 class DIBasicType : public DIType {
309 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
311 unsigned getEncoding() const { return getUnsignedField(9); }
313 /// Verify - Verify that a basic type descriptor is well formed.
316 /// print - print basic type.
317 void print(raw_ostream &OS) const;
319 /// dump - print basic type to dbgs() with a newline.
323 /// DIDerivedType - A simple derived type, like a const qualified type,
324 /// a typedef, a pointer or reference, etc.
325 class DIDerivedType : public DIType {
327 explicit DIDerivedType(const MDNode *N, bool, bool)
328 : DIType(N, true, true) {}
330 explicit DIDerivedType(const MDNode *N = 0)
331 : DIType(N, true, true) {}
333 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
335 /// getOriginalTypeSize - If this type is derived from a base type then
336 /// return base type size.
337 uint64_t getOriginalTypeSize() const;
339 StringRef getObjCPropertyName() const { return getStringField(10); }
340 StringRef getObjCPropertyGetterName() const {
341 return getStringField(11);
343 StringRef getObjCPropertySetterName() const {
344 return getStringField(12);
346 bool isReadOnlyObjCProperty() {
347 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
349 bool isReadWriteObjCProperty() {
350 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
352 bool isAssignObjCProperty() {
353 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
355 bool isRetainObjCProperty() {
356 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
358 bool isCopyObjCProperty() {
359 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
361 bool isNonAtomicObjCProperty() {
362 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
365 /// Verify - Verify that a derived type descriptor is well formed.
368 /// print - print derived type.
369 void print(raw_ostream &OS) const;
371 /// dump - print derived type to dbgs() with a newline.
375 /// DICompositeType - This descriptor holds a type that can refer to multiple
376 /// other types, like a function or struct.
377 /// FIXME: Why is this a DIDerivedType??
378 class DICompositeType : public DIDerivedType {
380 explicit DICompositeType(const MDNode *N = 0)
381 : DIDerivedType(N, true, true) {
382 if (N && !isCompositeType())
386 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
387 unsigned getRunTimeLang() const { return getUnsignedField(11); }
388 DICompositeType getContainingType() const {
389 return getFieldAs<DICompositeType>(12);
391 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
393 /// Verify - Verify that a composite type descriptor is well formed.
396 /// print - print composite type.
397 void print(raw_ostream &OS) const;
399 /// dump - print composite type to dbgs() with a newline.
403 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
404 class DITemplateTypeParameter : public DIDescriptor {
406 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
408 DIScope getContext() const { return getFieldAs<DIScope>(1); }
409 StringRef getName() const { return getStringField(2); }
410 DIType getType() const { return getFieldAs<DIType>(3); }
411 StringRef getFilename() const {
412 return getFieldAs<DIFile>(4).getFilename();
414 StringRef getDirectory() const {
415 return getFieldAs<DIFile>(4).getDirectory();
417 unsigned getLineNumber() const { return getUnsignedField(5); }
418 unsigned getColumnNumber() const { return getUnsignedField(6); }
421 /// DITemplateValueParameter - This is a wrapper for template value parameter.
422 class DITemplateValueParameter : public DIDescriptor {
424 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
426 DIScope getContext() const { return getFieldAs<DIScope>(1); }
427 StringRef getName() const { return getStringField(2); }
428 DIType getType() const { return getFieldAs<DIType>(3); }
429 uint64_t getValue() const { return getUInt64Field(4); }
430 StringRef getFilename() const {
431 return getFieldAs<DIFile>(5).getFilename();
433 StringRef getDirectory() const {
434 return getFieldAs<DIFile>(5).getDirectory();
436 unsigned getLineNumber() const { return getUnsignedField(6); }
437 unsigned getColumnNumber() const { return getUnsignedField(7); }
440 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
441 class DISubprogram : public DIScope {
443 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
445 DIScope getContext() const { return getFieldAs<DIScope>(2); }
446 StringRef getName() const { return getStringField(3); }
447 StringRef getDisplayName() const { return getStringField(4); }
448 StringRef getLinkageName() const { return getStringField(5); }
449 DICompileUnit getCompileUnit() const{
450 if (getVersion() == llvm::LLVMDebugVersion7)
451 return getFieldAs<DICompileUnit>(6);
453 return getFieldAs<DIFile>(6).getCompileUnit();
455 unsigned getLineNumber() const { return getUnsignedField(7); }
456 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
458 /// getReturnTypeName - Subprogram return types are encoded either as
459 /// DIType or as DICompositeType.
460 StringRef getReturnTypeName() const {
461 DICompositeType DCT(getFieldAs<DICompositeType>(8));
463 DIArray A = DCT.getTypeArray();
464 DIType T(A.getElement(0));
467 DIType T(getFieldAs<DIType>(8));
471 /// isLocalToUnit - Return true if this subprogram is local to the current
472 /// compile unit, like 'static' in C.
473 unsigned isLocalToUnit() const { return getUnsignedField(9); }
474 unsigned isDefinition() const { return getUnsignedField(10); }
476 unsigned getVirtuality() const { return getUnsignedField(11); }
477 unsigned getVirtualIndex() const { return getUnsignedField(12); }
479 DICompositeType getContainingType() const {
480 return getFieldAs<DICompositeType>(13);
482 unsigned isArtificial() const {
483 if (getVersion() <= llvm::LLVMDebugVersion8)
484 return getUnsignedField(14);
485 return (getUnsignedField(14) & FlagArtificial) != 0;
487 /// isPrivate - Return true if this subprogram has "private"
488 /// access specifier.
489 bool isPrivate() const {
490 if (getVersion() <= llvm::LLVMDebugVersion8)
492 return (getUnsignedField(14) & FlagPrivate) != 0;
494 /// isProtected - Return true if this subprogram has "protected"
495 /// access specifier.
496 bool isProtected() const {
497 if (getVersion() <= llvm::LLVMDebugVersion8)
499 return (getUnsignedField(14) & FlagProtected) != 0;
501 /// isExplicit - Return true if this subprogram is marked as explicit.
502 bool isExplicit() const {
503 if (getVersion() <= llvm::LLVMDebugVersion8)
505 return (getUnsignedField(14) & FlagExplicit) != 0;
507 /// isPrototyped - Return true if this subprogram is prototyped.
508 bool isPrototyped() const {
509 if (getVersion() <= llvm::LLVMDebugVersion8)
511 return (getUnsignedField(14) & FlagPrototyped) != 0;
514 unsigned isOptimized() const;
516 StringRef getFilename() const {
517 if (getVersion() == llvm::LLVMDebugVersion7)
518 return getCompileUnit().getFilename();
520 return getFieldAs<DIFile>(6).getFilename();
523 StringRef getDirectory() const {
524 if (getVersion() == llvm::LLVMDebugVersion7)
525 return getCompileUnit().getFilename();
527 return getFieldAs<DIFile>(6).getDirectory();
530 /// Verify - Verify that a subprogram descriptor is well formed.
533 /// print - print subprogram.
534 void print(raw_ostream &OS) const;
536 /// dump - print subprogram to dbgs() with a newline.
539 /// describes - Return true if this subprogram provides debugging
540 /// information for the function F.
541 bool describes(const Function *F);
543 Function *getFunction() const { return getFunctionField(16); }
544 DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
545 DISubprogram getFunctionDeclaration() const {
546 return getFieldAs<DISubprogram>(18);
550 /// DIGlobalVariable - This is a wrapper for a global variable.
551 class DIGlobalVariable : public DIDescriptor {
553 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
555 DIScope getContext() const { return getFieldAs<DIScope>(2); }
556 StringRef getName() const { return getStringField(3); }
557 StringRef getDisplayName() const { return getStringField(4); }
558 StringRef getLinkageName() const { return getStringField(5); }
559 DICompileUnit getCompileUnit() const{
560 if (getVersion() == llvm::LLVMDebugVersion7)
561 return getFieldAs<DICompileUnit>(6);
563 DIFile F = getFieldAs<DIFile>(6);
564 return F.getCompileUnit();
567 unsigned getLineNumber() const { return getUnsignedField(7); }
568 DIType getType() const { return getFieldAs<DIType>(8); }
569 unsigned isLocalToUnit() const { return getUnsignedField(9); }
570 unsigned isDefinition() const { return getUnsignedField(10); }
572 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
573 Constant *getConstant() const { return getConstantField(11); }
575 /// Verify - Verify that a global variable descriptor is well formed.
578 /// print - print global variable.
579 void print(raw_ostream &OS) const;
581 /// dump - print global variable to dbgs() with a newline.
585 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
587 class DIVariable : public DIDescriptor {
589 explicit DIVariable(const MDNode *N = 0)
592 DIScope getContext() const { return getFieldAs<DIScope>(1); }
593 StringRef getName() const { return getStringField(2); }
594 DICompileUnit getCompileUnit() const{
595 if (getVersion() == llvm::LLVMDebugVersion7)
596 return getFieldAs<DICompileUnit>(3);
598 DIFile F = getFieldAs<DIFile>(3);
599 return F.getCompileUnit();
601 unsigned getLineNumber() const {
602 return (getUnsignedField(4) << 8) >> 8;
604 unsigned getArgNumber() const {
605 unsigned L = getUnsignedField(4);
608 DIType getType() const { return getFieldAs<DIType>(5); }
610 /// isArtificial - Return true if this variable is marked as "artificial".
611 bool isArtificial() const {
612 if (getVersion() <= llvm::LLVMDebugVersion8)
614 return (getUnsignedField(6) & FlagArtificial) != 0;
617 /// getInlinedAt - If this variable is inlined then return inline location.
618 MDNode *getInlinedAt();
620 /// Verify - Verify that a variable descriptor is well formed.
623 /// HasComplexAddr - Return true if the variable has a complex address.
624 bool hasComplexAddress() const {
625 return getNumAddrElements() > 0;
628 unsigned getNumAddrElements() const;
630 uint64_t getAddrElement(unsigned Idx) const {
631 if (getVersion() <= llvm::LLVMDebugVersion8)
632 return getUInt64Field(Idx+6);
633 if (getVersion() == llvm::LLVMDebugVersion9)
634 return getUInt64Field(Idx+7);
635 return getUInt64Field(Idx+8);
638 /// isBlockByrefVariable - Return true if the variable was declared as
639 /// a "__block" variable (Apple Blocks).
640 bool isBlockByrefVariable() const {
641 return getType().isBlockByrefStruct();
644 /// isInlinedFnArgument - Return trule if this variable provides debugging
645 /// information for an inlined function arguments.
646 bool isInlinedFnArgument(const Function *CurFn);
648 /// print - print variable.
649 void print(raw_ostream &OS) const;
651 /// dump - print variable to dbgs() with a newline.
655 /// DILexicalBlock - This is a wrapper for a lexical block.
656 class DILexicalBlock : public DIScope {
658 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
659 DIScope getContext() const { return getFieldAs<DIScope>(1); }
660 unsigned getLineNumber() const { return getUnsignedField(2); }
661 unsigned getColumnNumber() const { return getUnsignedField(3); }
662 StringRef getDirectory() const {
663 StringRef dir = getFieldAs<DIFile>(4).getDirectory();
664 return !dir.empty() ? dir : getContext().getDirectory();
666 StringRef getFilename() const {
667 StringRef filename = getFieldAs<DIFile>(4).getFilename();
668 return !filename.empty() ? filename : getContext().getFilename();
672 /// DINameSpace - A wrapper for a C++ style name space.
673 class DINameSpace : public DIScope {
675 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
676 DIScope getContext() const { return getFieldAs<DIScope>(1); }
677 StringRef getName() const { return getStringField(2); }
678 StringRef getDirectory() const {
679 return getFieldAs<DIFile>(3).getDirectory();
681 StringRef getFilename() const {
682 return getFieldAs<DIFile>(3).getFilename();
684 DICompileUnit getCompileUnit() const{
685 if (getVersion() == llvm::LLVMDebugVersion7)
686 return getFieldAs<DICompileUnit>(3);
688 return getFieldAs<DIFile>(3).getCompileUnit();
690 unsigned getLineNumber() const { return getUnsignedField(4); }
694 /// DILocation - This object holds location information. This object
695 /// is not associated with any DWARF tag.
696 class DILocation : public DIDescriptor {
698 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
700 unsigned getLineNumber() const { return getUnsignedField(0); }
701 unsigned getColumnNumber() const { return getUnsignedField(1); }
702 DIScope getScope() const { return getFieldAs<DIScope>(2); }
703 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
704 StringRef getFilename() const { return getScope().getFilename(); }
705 StringRef getDirectory() const { return getScope().getDirectory(); }
709 /// getDISubprogram - Find subprogram that is enclosing this scope.
710 DISubprogram getDISubprogram(const MDNode *Scope);
712 /// getDICompositeType - Find underlying composite type.
713 DICompositeType getDICompositeType(DIType T);
715 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
716 /// to hold function specific information.
717 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, StringRef Name);
719 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
720 /// suitable to hold function specific information.
721 NamedMDNode *getFnSpecificMDNode(const Module &M, StringRef Name);
723 /// createInlinedVariable - Create a new inlined variable based on current
725 /// @param DV Current Variable.
726 /// @param InlinedScope Location at current variable is inlined.
727 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
728 LLVMContext &VMContext);
730 /// cleanseInlinedVariable - Remove inlined scope from the variable.
731 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
733 class DebugInfoFinder {
735 /// processModule - Process entire module and collect debug info
737 void processModule(Module &M);
740 /// processType - Process DIType.
741 void processType(DIType DT);
743 /// processLexicalBlock - Process DILexicalBlock.
744 void processLexicalBlock(DILexicalBlock LB);
746 /// processSubprogram - Process DISubprogram.
747 void processSubprogram(DISubprogram SP);
749 /// processDeclare - Process DbgDeclareInst.
750 void processDeclare(DbgDeclareInst *DDI);
752 /// processLocation - Process DILocation.
753 void processLocation(DILocation Loc);
755 /// addCompileUnit - Add compile unit into CUs.
756 bool addCompileUnit(DICompileUnit CU);
758 /// addGlobalVariable - Add global variable into GVs.
759 bool addGlobalVariable(DIGlobalVariable DIG);
761 // addSubprogram - Add subprgoram into SPs.
762 bool addSubprogram(DISubprogram SP);
764 /// addType - Add type into Tys.
765 bool addType(DIType DT);
768 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
769 iterator compile_unit_begin() const { return CUs.begin(); }
770 iterator compile_unit_end() const { return CUs.end(); }
771 iterator subprogram_begin() const { return SPs.begin(); }
772 iterator subprogram_end() const { return SPs.end(); }
773 iterator global_variable_begin() const { return GVs.begin(); }
774 iterator global_variable_end() const { return GVs.end(); }
775 iterator type_begin() const { return TYs.begin(); }
776 iterator type_end() const { return TYs.end(); }
778 unsigned compile_unit_count() const { return CUs.size(); }
779 unsigned global_variable_count() const { return GVs.size(); }
780 unsigned subprogram_count() const { return SPs.size(); }
781 unsigned type_count() const { return TYs.size(); }
784 SmallVector<MDNode *, 8> CUs; // Compile Units
785 SmallVector<MDNode *, 8> SPs; // Subprograms
786 SmallVector<MDNode *, 8> GVs; // Global Variables;
787 SmallVector<MDNode *, 8> TYs; // Types
788 SmallPtrSet<MDNode *, 64> NodesSeen;
790 } // end namespace llvm