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 /// isUnsignedDIType - Return true if type encoding is unsigned.
295 bool isUnsignedDIType();
297 /// replaceAllUsesWith - Replace all uses of debug info referenced by
299 void replaceAllUsesWith(DIDescriptor &D);
300 void replaceAllUsesWith(MDNode *D);
302 /// print - print type.
303 void print(raw_ostream &OS) const;
305 /// dump - print type to dbgs() with a newline.
309 /// DIBasicType - A basic type, like 'int' or 'float'.
310 class DIBasicType : public DIType {
312 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
314 unsigned getEncoding() const { return getUnsignedField(9); }
316 /// Verify - Verify that a basic type descriptor is well formed.
319 /// print - print basic type.
320 void print(raw_ostream &OS) const;
322 /// dump - print basic type to dbgs() with a newline.
326 /// DIDerivedType - A simple derived type, like a const qualified type,
327 /// a typedef, a pointer or reference, etc.
328 class DIDerivedType : public DIType {
330 explicit DIDerivedType(const MDNode *N, bool, bool)
331 : DIType(N, true, true) {}
333 explicit DIDerivedType(const MDNode *N = 0)
334 : DIType(N, true, true) {}
336 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
338 /// getOriginalTypeSize - If this type is derived from a base type then
339 /// return base type size.
340 uint64_t getOriginalTypeSize() const;
342 StringRef getObjCPropertyName() const { return getStringField(10); }
343 StringRef getObjCPropertyGetterName() const {
344 return getStringField(11);
346 StringRef getObjCPropertySetterName() const {
347 return getStringField(12);
349 bool isReadOnlyObjCProperty() {
350 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
352 bool isReadWriteObjCProperty() {
353 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
355 bool isAssignObjCProperty() {
356 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
358 bool isRetainObjCProperty() {
359 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
361 bool isCopyObjCProperty() {
362 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
364 bool isNonAtomicObjCProperty() {
365 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
368 /// Verify - Verify that a derived type descriptor is well formed.
371 /// print - print derived type.
372 void print(raw_ostream &OS) const;
374 /// dump - print derived type to dbgs() with a newline.
378 /// DICompositeType - This descriptor holds a type that can refer to multiple
379 /// other types, like a function or struct.
380 /// FIXME: Why is this a DIDerivedType??
381 class DICompositeType : public DIDerivedType {
383 explicit DICompositeType(const MDNode *N = 0)
384 : DIDerivedType(N, true, true) {
385 if (N && !isCompositeType())
389 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
390 unsigned getRunTimeLang() const { return getUnsignedField(11); }
391 DICompositeType getContainingType() const {
392 return getFieldAs<DICompositeType>(12);
394 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
396 /// Verify - Verify that a composite type descriptor is well formed.
399 /// print - print composite type.
400 void print(raw_ostream &OS) const;
402 /// dump - print composite type to dbgs() with a newline.
406 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
407 class DITemplateTypeParameter : public DIDescriptor {
409 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
411 DIScope getContext() const { return getFieldAs<DIScope>(1); }
412 StringRef getName() const { return getStringField(2); }
413 DIType getType() const { return getFieldAs<DIType>(3); }
414 StringRef getFilename() const {
415 return getFieldAs<DIFile>(4).getFilename();
417 StringRef getDirectory() const {
418 return getFieldAs<DIFile>(4).getDirectory();
420 unsigned getLineNumber() const { return getUnsignedField(5); }
421 unsigned getColumnNumber() const { return getUnsignedField(6); }
424 /// DITemplateValueParameter - This is a wrapper for template value parameter.
425 class DITemplateValueParameter : public DIDescriptor {
427 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
429 DIScope getContext() const { return getFieldAs<DIScope>(1); }
430 StringRef getName() const { return getStringField(2); }
431 DIType getType() const { return getFieldAs<DIType>(3); }
432 uint64_t getValue() const { return getUInt64Field(4); }
433 StringRef getFilename() const {
434 return getFieldAs<DIFile>(5).getFilename();
436 StringRef getDirectory() const {
437 return getFieldAs<DIFile>(5).getDirectory();
439 unsigned getLineNumber() const { return getUnsignedField(6); }
440 unsigned getColumnNumber() const { return getUnsignedField(7); }
443 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
444 class DISubprogram : public DIScope {
446 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
448 DIScope getContext() const { return getFieldAs<DIScope>(2); }
449 StringRef getName() const { return getStringField(3); }
450 StringRef getDisplayName() const { return getStringField(4); }
451 StringRef getLinkageName() const { return getStringField(5); }
452 DICompileUnit getCompileUnit() const{
453 if (getVersion() == llvm::LLVMDebugVersion7)
454 return getFieldAs<DICompileUnit>(6);
456 return getFieldAs<DIFile>(6).getCompileUnit();
458 unsigned getLineNumber() const { return getUnsignedField(7); }
459 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
461 /// getReturnTypeName - Subprogram return types are encoded either as
462 /// DIType or as DICompositeType.
463 StringRef getReturnTypeName() const {
464 DICompositeType DCT(getFieldAs<DICompositeType>(8));
466 DIArray A = DCT.getTypeArray();
467 DIType T(A.getElement(0));
470 DIType T(getFieldAs<DIType>(8));
474 /// isLocalToUnit - Return true if this subprogram is local to the current
475 /// compile unit, like 'static' in C.
476 unsigned isLocalToUnit() const { return getUnsignedField(9); }
477 unsigned isDefinition() const { return getUnsignedField(10); }
479 unsigned getVirtuality() const { return getUnsignedField(11); }
480 unsigned getVirtualIndex() const { return getUnsignedField(12); }
482 DICompositeType getContainingType() const {
483 return getFieldAs<DICompositeType>(13);
485 unsigned isArtificial() const {
486 if (getVersion() <= llvm::LLVMDebugVersion8)
487 return getUnsignedField(14);
488 return (getUnsignedField(14) & FlagArtificial) != 0;
490 /// isPrivate - Return true if this subprogram has "private"
491 /// access specifier.
492 bool isPrivate() const {
493 if (getVersion() <= llvm::LLVMDebugVersion8)
495 return (getUnsignedField(14) & FlagPrivate) != 0;
497 /// isProtected - Return true if this subprogram has "protected"
498 /// access specifier.
499 bool isProtected() const {
500 if (getVersion() <= llvm::LLVMDebugVersion8)
502 return (getUnsignedField(14) & FlagProtected) != 0;
504 /// isExplicit - Return true if this subprogram is marked as explicit.
505 bool isExplicit() const {
506 if (getVersion() <= llvm::LLVMDebugVersion8)
508 return (getUnsignedField(14) & FlagExplicit) != 0;
510 /// isPrototyped - Return true if this subprogram is prototyped.
511 bool isPrototyped() const {
512 if (getVersion() <= llvm::LLVMDebugVersion8)
514 return (getUnsignedField(14) & FlagPrototyped) != 0;
517 unsigned isOptimized() const;
519 StringRef getFilename() const {
520 if (getVersion() == llvm::LLVMDebugVersion7)
521 return getCompileUnit().getFilename();
523 return getFieldAs<DIFile>(6).getFilename();
526 StringRef getDirectory() const {
527 if (getVersion() == llvm::LLVMDebugVersion7)
528 return getCompileUnit().getFilename();
530 return getFieldAs<DIFile>(6).getDirectory();
533 /// Verify - Verify that a subprogram descriptor is well formed.
536 /// print - print subprogram.
537 void print(raw_ostream &OS) const;
539 /// dump - print subprogram to dbgs() with a newline.
542 /// describes - Return true if this subprogram provides debugging
543 /// information for the function F.
544 bool describes(const Function *F);
546 Function *getFunction() const { return getFunctionField(16); }
547 DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
548 DISubprogram getFunctionDeclaration() const {
549 return getFieldAs<DISubprogram>(18);
553 /// DIGlobalVariable - This is a wrapper for a global variable.
554 class DIGlobalVariable : public DIDescriptor {
556 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
558 DIScope getContext() const { return getFieldAs<DIScope>(2); }
559 StringRef getName() const { return getStringField(3); }
560 StringRef getDisplayName() const { return getStringField(4); }
561 StringRef getLinkageName() const { return getStringField(5); }
562 DICompileUnit getCompileUnit() const{
563 if (getVersion() == llvm::LLVMDebugVersion7)
564 return getFieldAs<DICompileUnit>(6);
566 DIFile F = getFieldAs<DIFile>(6);
567 return F.getCompileUnit();
570 unsigned getLineNumber() const { return getUnsignedField(7); }
571 DIType getType() const { return getFieldAs<DIType>(8); }
572 unsigned isLocalToUnit() const { return getUnsignedField(9); }
573 unsigned isDefinition() const { return getUnsignedField(10); }
575 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
576 Constant *getConstant() const { return getConstantField(11); }
578 /// Verify - Verify that a global variable descriptor is well formed.
581 /// print - print global variable.
582 void print(raw_ostream &OS) const;
584 /// dump - print global variable to dbgs() with a newline.
588 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
590 class DIVariable : public DIDescriptor {
592 explicit DIVariable(const MDNode *N = 0)
595 DIScope getContext() const { return getFieldAs<DIScope>(1); }
596 StringRef getName() const { return getStringField(2); }
597 DICompileUnit getCompileUnit() const{
598 if (getVersion() == llvm::LLVMDebugVersion7)
599 return getFieldAs<DICompileUnit>(3);
601 DIFile F = getFieldAs<DIFile>(3);
602 return F.getCompileUnit();
604 unsigned getLineNumber() const {
605 return (getUnsignedField(4) << 8) >> 8;
607 unsigned getArgNumber() const {
608 unsigned L = getUnsignedField(4);
611 DIType getType() const { return getFieldAs<DIType>(5); }
613 /// isArtificial - Return true if this variable is marked as "artificial".
614 bool isArtificial() const {
615 if (getVersion() <= llvm::LLVMDebugVersion8)
617 return (getUnsignedField(6) & FlagArtificial) != 0;
620 /// getInlinedAt - If this variable is inlined then return inline location.
621 MDNode *getInlinedAt() const;
623 /// Verify - Verify that a variable descriptor is well formed.
626 /// HasComplexAddr - Return true if the variable has a complex address.
627 bool hasComplexAddress() const {
628 return getNumAddrElements() > 0;
631 unsigned getNumAddrElements() const;
633 uint64_t getAddrElement(unsigned Idx) const {
634 if (getVersion() <= llvm::LLVMDebugVersion8)
635 return getUInt64Field(Idx+6);
636 if (getVersion() == llvm::LLVMDebugVersion9)
637 return getUInt64Field(Idx+7);
638 return getUInt64Field(Idx+8);
641 /// isBlockByrefVariable - Return true if the variable was declared as
642 /// a "__block" variable (Apple Blocks).
643 bool isBlockByrefVariable() const {
644 return getType().isBlockByrefStruct();
647 /// isInlinedFnArgument - Return trule if this variable provides debugging
648 /// information for an inlined function arguments.
649 bool isInlinedFnArgument(const Function *CurFn);
651 /// print - print variable.
652 void print(raw_ostream &OS) const;
654 void printExtendedName(raw_ostream &OS) const;
656 /// dump - print variable to dbgs() with a newline.
660 /// DILexicalBlock - This is a wrapper for a lexical block.
661 class DILexicalBlock : public DIScope {
663 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
664 DIScope getContext() const { return getFieldAs<DIScope>(1); }
665 unsigned getLineNumber() const { return getUnsignedField(2); }
666 unsigned getColumnNumber() const { return getUnsignedField(3); }
667 StringRef getDirectory() const {
668 StringRef dir = getFieldAs<DIFile>(4).getDirectory();
669 return !dir.empty() ? dir : getContext().getDirectory();
671 StringRef getFilename() const {
672 StringRef filename = getFieldAs<DIFile>(4).getFilename();
673 return !filename.empty() ? filename : getContext().getFilename();
677 /// DINameSpace - A wrapper for a C++ style name space.
678 class DINameSpace : public DIScope {
680 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
681 DIScope getContext() const { return getFieldAs<DIScope>(1); }
682 StringRef getName() const { return getStringField(2); }
683 StringRef getDirectory() const {
684 return getFieldAs<DIFile>(3).getDirectory();
686 StringRef getFilename() const {
687 return getFieldAs<DIFile>(3).getFilename();
689 DICompileUnit getCompileUnit() const{
690 if (getVersion() == llvm::LLVMDebugVersion7)
691 return getFieldAs<DICompileUnit>(3);
693 return getFieldAs<DIFile>(3).getCompileUnit();
695 unsigned getLineNumber() const { return getUnsignedField(4); }
699 /// DILocation - This object holds location information. This object
700 /// is not associated with any DWARF tag.
701 class DILocation : public DIDescriptor {
703 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
705 unsigned getLineNumber() const { return getUnsignedField(0); }
706 unsigned getColumnNumber() const { return getUnsignedField(1); }
707 DIScope getScope() const { return getFieldAs<DIScope>(2); }
708 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
709 StringRef getFilename() const { return getScope().getFilename(); }
710 StringRef getDirectory() const { return getScope().getDirectory(); }
714 /// getDISubprogram - Find subprogram that is enclosing this scope.
715 DISubprogram getDISubprogram(const MDNode *Scope);
717 /// getDICompositeType - Find underlying composite type.
718 DICompositeType getDICompositeType(DIType T);
720 /// isSubprogramContext - Return true if Context is either a subprogram
721 /// or another context nested inside a subprogram.
722 bool isSubprogramContext(const MDNode *Context);
724 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
725 /// to hold function specific information.
726 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, StringRef Name);
728 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
729 /// suitable to hold function specific information.
730 NamedMDNode *getFnSpecificMDNode(const Module &M, StringRef Name);
732 /// createInlinedVariable - Create a new inlined variable based on current
734 /// @param DV Current Variable.
735 /// @param InlinedScope Location at current variable is inlined.
736 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
737 LLVMContext &VMContext);
739 /// cleanseInlinedVariable - Remove inlined scope from the variable.
740 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
742 class DebugInfoFinder {
744 /// processModule - Process entire module and collect debug info
746 void processModule(Module &M);
749 /// processType - Process DIType.
750 void processType(DIType DT);
752 /// processLexicalBlock - Process DILexicalBlock.
753 void processLexicalBlock(DILexicalBlock LB);
755 /// processSubprogram - Process DISubprogram.
756 void processSubprogram(DISubprogram SP);
758 /// processDeclare - Process DbgDeclareInst.
759 void processDeclare(DbgDeclareInst *DDI);
761 /// processLocation - Process DILocation.
762 void processLocation(DILocation Loc);
764 /// addCompileUnit - Add compile unit into CUs.
765 bool addCompileUnit(DICompileUnit CU);
767 /// addGlobalVariable - Add global variable into GVs.
768 bool addGlobalVariable(DIGlobalVariable DIG);
770 // addSubprogram - Add subprgoram into SPs.
771 bool addSubprogram(DISubprogram SP);
773 /// addType - Add type into Tys.
774 bool addType(DIType DT);
777 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
778 iterator compile_unit_begin() const { return CUs.begin(); }
779 iterator compile_unit_end() const { return CUs.end(); }
780 iterator subprogram_begin() const { return SPs.begin(); }
781 iterator subprogram_end() const { return SPs.end(); }
782 iterator global_variable_begin() const { return GVs.begin(); }
783 iterator global_variable_end() const { return GVs.end(); }
784 iterator type_begin() const { return TYs.begin(); }
785 iterator type_end() const { return TYs.end(); }
787 unsigned compile_unit_count() const { return CUs.size(); }
788 unsigned global_variable_count() const { return GVs.size(); }
789 unsigned subprogram_count() const { return SPs.size(); }
790 unsigned type_count() const { return TYs.size(); }
793 SmallVector<MDNode *, 8> CUs; // Compile Units
794 SmallVector<MDNode *, 8> SPs; // Subprograms
795 SmallVector<MDNode *, 8> GVs; // Global Variables;
796 SmallVector<MDNode *, 8> TYs; // Types
797 SmallPtrSet<MDNode *, 64> NodesSeen;
799 } // end namespace llvm