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_DEBUGINFO_H
18 #define LLVM_DEBUGINFO_H
20 #include "llvm/ADT/SmallPtrSet.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/Dwarf.h"
43 class DILexicalBlockFile;
48 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
49 /// This should not be stored in a container, because the underlying MDNode
50 /// may change in certain situations.
55 FlagProtected = 1 << 1,
57 FlagAppleBlock = 1 << 3,
58 FlagBlockByrefStruct = 1 << 4,
60 FlagArtificial = 1 << 6,
61 FlagExplicit = 1 << 7,
62 FlagPrototyped = 1 << 8,
63 FlagObjcClassComplete = 1 << 9,
64 FlagObjectPointer = 1 << 10,
66 FlagStaticMember = 1 << 12
69 const MDNode *DbgNode;
71 StringRef getStringField(unsigned Elt) const;
72 unsigned getUnsignedField(unsigned Elt) const {
73 return (unsigned)getUInt64Field(Elt);
75 uint64_t getUInt64Field(unsigned Elt) const;
76 int64_t getInt64Field(unsigned Elt) const;
77 DIDescriptor getDescriptorField(unsigned Elt) const;
79 template <typename DescTy>
80 DescTy getFieldAs(unsigned Elt) const {
81 return DescTy(getDescriptorField(Elt));
84 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
85 Constant *getConstantField(unsigned Elt) const;
86 Function *getFunctionField(unsigned Elt) const;
87 void replaceFunctionField(unsigned Elt, Function *F);
90 explicit DIDescriptor() : DbgNode(0) {}
91 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
92 explicit DIDescriptor(const DIFile F);
93 explicit DIDescriptor(const DISubprogram F);
94 explicit DIDescriptor(const DILexicalBlockFile F);
95 explicit DIDescriptor(const DILexicalBlock F);
96 explicit DIDescriptor(const DIVariable F);
97 explicit DIDescriptor(const DIType F);
101 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
102 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
104 unsigned getTag() const {
105 return getUnsignedField(0) & ~LLVMDebugVersionMask;
108 bool isDerivedType() const;
109 bool isCompositeType() const;
110 bool isBasicType() const;
111 bool isVariable() const;
112 bool isSubprogram() const;
113 bool isGlobalVariable() const;
114 bool isScope() const;
116 bool isCompileUnit() const;
117 bool isNameSpace() const;
118 bool isLexicalBlockFile() 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;
127 bool isObjCProperty() const;
129 /// print - print descriptor.
130 void print(raw_ostream &OS) const;
132 /// dump - print descriptor to dbgs() with a newline.
136 /// DISubrange - This is used to represent ranges, for array bounds.
137 class DISubrange : public DIDescriptor {
138 friend class DIDescriptor;
139 void printInternal(raw_ostream &OS) const;
141 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
143 int64_t getLo() const { return getInt64Field(1); }
144 int64_t getCount() const { return getInt64Field(2); }
148 /// DIArray - This descriptor holds an array of descriptors.
149 class DIArray : public DIDescriptor {
151 explicit DIArray(const MDNode *N = 0)
154 unsigned getNumElements() const;
155 DIDescriptor getElement(unsigned Idx) const {
156 return getDescriptorField(Idx);
160 /// DIScope - A base class for various scopes.
161 class DIScope : public DIDescriptor {
163 friend class DIDescriptor;
164 void printInternal(raw_ostream &OS) const;
166 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
168 StringRef getFilename() const;
169 StringRef getDirectory() const;
172 /// DIFile - This is a wrapper for a file.
173 class DIFile : public DIScope {
174 friend class DIDescriptor;
176 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
177 if (DbgNode && !isFile())
180 StringRef getFilename() const { return getStringField(1); }
181 StringRef getDirectory() const { return getStringField(2); }
185 /// DICompileUnit - A wrapper for a compile unit.
186 class DICompileUnit : public DIScope {
187 friend class DIDescriptor;
188 void printInternal(raw_ostream &OS) const;
190 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
192 unsigned getLanguage() const { return getUnsignedField(2); }
193 StringRef getFilename() const {
194 return getFieldAs<DIFile>(3).getFilename();
196 StringRef getDirectory() const {
197 return getFieldAs<DIFile>(3).getDirectory();
199 StringRef getProducer() const { return getStringField(4); }
201 bool isOptimized() const { return getUnsignedField(5) != 0; }
202 StringRef getFlags() const { return getStringField(6); }
203 unsigned getRunTimeVersion() const { return getUnsignedField(7); }
205 DIArray getEnumTypes() const;
206 DIArray getRetainedTypes() const;
207 DIArray getSubprograms() const;
208 DIArray getGlobalVariables() const;
210 StringRef getSplitDebugFilename() const { return getStringField(12); }
212 /// Verify - Verify that a compile unit is well formed.
216 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
217 /// FIXME: it seems strange that this doesn't have either a reference to the
218 /// type/precision or a file/line pair for location info.
219 class DIEnumerator : public DIDescriptor {
220 friend class DIDescriptor;
221 void printInternal(raw_ostream &OS) const;
223 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
225 StringRef getName() const { return getStringField(1); }
226 uint64_t getEnumValue() const { return getUInt64Field(2); }
230 /// DIType - This is a wrapper for a type.
231 /// FIXME: Types should be factored much better so that CV qualifiers and
232 /// others do not require a huge and empty descriptor full of zeros.
233 class DIType : public DIScope {
235 friend class DIDescriptor;
236 void printInternal(raw_ostream &OS) const;
237 // This ctor is used when the Tag has already been validated by a derived
239 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
241 /// Verify - Verify that a type descriptor is well formed.
243 explicit DIType(const MDNode *N);
246 DIScope getContext() const { return getFieldAs<DIScope>(1); }
247 StringRef getName() const { return getStringField(2); }
248 DIFile getFile() const { return getFieldAs<DIFile>(3); }
249 unsigned getLineNumber() const { return getUnsignedField(4); }
250 uint64_t getSizeInBits() const { return getUInt64Field(5); }
251 uint64_t getAlignInBits() const { return getUInt64Field(6); }
252 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
253 // carry this is just plain insane.
254 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
255 unsigned getFlags() const { return getUnsignedField(8); }
256 bool isPrivate() const {
257 return (getFlags() & FlagPrivate) != 0;
259 bool isProtected() const {
260 return (getFlags() & FlagProtected) != 0;
262 bool isForwardDecl() const {
263 return (getFlags() & FlagFwdDecl) != 0;
265 // isAppleBlock - Return true if this is the Apple Blocks extension.
266 bool isAppleBlockExtension() const {
267 return (getFlags() & FlagAppleBlock) != 0;
269 bool isBlockByrefStruct() const {
270 return (getFlags() & FlagBlockByrefStruct) != 0;
272 bool isVirtual() const {
273 return (getFlags() & FlagVirtual) != 0;
275 bool isArtificial() const {
276 return (getFlags() & FlagArtificial) != 0;
278 bool isObjectPointer() const {
279 return (getFlags() & FlagObjectPointer) != 0;
281 bool isObjcClassComplete() const {
282 return (getFlags() & FlagObjcClassComplete) != 0;
284 bool isVector() const {
285 return (getFlags() & FlagVector) != 0;
287 bool isStaticMember() const {
288 return (getFlags() & FlagStaticMember) != 0;
290 bool isValid() const {
291 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
293 StringRef getDirectory() const {
294 return getFieldAs<DIFile>(3).getDirectory();
296 StringRef getFilename() const {
297 return getFieldAs<DIFile>(3).getFilename();
300 /// isUnsignedDIType - Return true if type encoding is unsigned.
301 bool isUnsignedDIType();
303 /// replaceAllUsesWith - Replace all uses of debug info referenced by
305 void replaceAllUsesWith(DIDescriptor &D);
306 void replaceAllUsesWith(MDNode *D);
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.
320 /// DIDerivedType - A simple derived type, like a const qualified type,
321 /// a typedef, a pointer or reference, et cetera. Or, a data member of
322 /// a class/struct/union.
323 class DIDerivedType : public DIType {
324 friend class DIDescriptor;
325 void printInternal(raw_ostream &OS) const;
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 /// getObjCProperty - Return property node, if this ivar is
340 /// associated with one.
341 MDNode *getObjCProperty() const;
343 DIType getClassType() const {
344 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
345 return getFieldAs<DIType>(10);
348 Constant *getConstant() const {
349 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
350 return getConstantField(10);
353 /// Verify - Verify that a derived type descriptor is well formed.
357 /// DICompositeType - This descriptor holds a type that can refer to multiple
358 /// other types, like a function or struct.
359 /// FIXME: Why is this a DIDerivedType??
360 class DICompositeType : public DIDerivedType {
361 friend class DIDescriptor;
362 void printInternal(raw_ostream &OS) const;
364 explicit DICompositeType(const MDNode *N = 0)
365 : DIDerivedType(N, true, true) {
366 if (N && !isCompositeType())
370 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
371 unsigned getRunTimeLang() const { return getUnsignedField(11); }
372 DICompositeType getContainingType() const {
373 return getFieldAs<DICompositeType>(12);
375 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
377 /// Verify - Verify that a composite type descriptor is well formed.
381 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
382 class DITemplateTypeParameter : public DIDescriptor {
384 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
386 DIScope getContext() const { return getFieldAs<DIScope>(1); }
387 StringRef getName() const { return getStringField(2); }
388 DIType getType() const { return getFieldAs<DIType>(3); }
389 StringRef getFilename() const {
390 return getFieldAs<DIFile>(4).getFilename();
392 StringRef getDirectory() const {
393 return getFieldAs<DIFile>(4).getDirectory();
395 unsigned getLineNumber() const { return getUnsignedField(5); }
396 unsigned getColumnNumber() const { return getUnsignedField(6); }
400 /// DITemplateValueParameter - This is a wrapper for template value parameter.
401 class DITemplateValueParameter : public DIDescriptor {
403 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
405 DIScope getContext() const { return getFieldAs<DIScope>(1); }
406 StringRef getName() const { return getStringField(2); }
407 DIType getType() const { return getFieldAs<DIType>(3); }
408 uint64_t getValue() const { return getUInt64Field(4); }
409 StringRef getFilename() const {
410 return getFieldAs<DIFile>(5).getFilename();
412 StringRef getDirectory() const {
413 return getFieldAs<DIFile>(5).getDirectory();
415 unsigned getLineNumber() const { return getUnsignedField(6); }
416 unsigned getColumnNumber() const { return getUnsignedField(7); }
420 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
421 class DISubprogram : public DIScope {
422 friend class DIDescriptor;
423 void printInternal(raw_ostream &OS) const;
425 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
427 DIScope getContext() const { return getFieldAs<DIScope>(2); }
428 StringRef getName() const { return getStringField(3); }
429 StringRef getDisplayName() const { return getStringField(4); }
430 StringRef getLinkageName() const { return getStringField(5); }
431 unsigned getLineNumber() const { return getUnsignedField(7); }
432 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
434 /// getReturnTypeName - Subprogram return types are encoded either as
435 /// DIType or as DICompositeType.
436 StringRef getReturnTypeName() const {
437 DICompositeType DCT(getFieldAs<DICompositeType>(8));
439 DIArray A = DCT.getTypeArray();
440 DIType T(A.getElement(0));
443 DIType T(getFieldAs<DIType>(8));
447 /// isLocalToUnit - Return true if this subprogram is local to the current
448 /// compile unit, like 'static' in C.
449 unsigned isLocalToUnit() const { return getUnsignedField(9); }
450 unsigned isDefinition() const { return getUnsignedField(10); }
452 unsigned getVirtuality() const { return getUnsignedField(11); }
453 unsigned getVirtualIndex() const { return getUnsignedField(12); }
455 DICompositeType getContainingType() const {
456 return getFieldAs<DICompositeType>(13);
459 unsigned getFlags() const {
460 return getUnsignedField(14);
463 unsigned isArtificial() const {
464 return (getUnsignedField(14) & FlagArtificial) != 0;
466 /// isPrivate - Return true if this subprogram has "private"
467 /// access specifier.
468 bool isPrivate() const {
469 return (getUnsignedField(14) & FlagPrivate) != 0;
471 /// isProtected - Return true if this subprogram has "protected"
472 /// access specifier.
473 bool isProtected() const {
474 return (getUnsignedField(14) & FlagProtected) != 0;
476 /// isExplicit - Return true if this subprogram is marked as explicit.
477 bool isExplicit() const {
478 return (getUnsignedField(14) & FlagExplicit) != 0;
480 /// isPrototyped - Return true if this subprogram is prototyped.
481 bool isPrototyped() const {
482 return (getUnsignedField(14) & FlagPrototyped) != 0;
485 unsigned isOptimized() const;
487 StringRef getFilename() const {
488 return getFieldAs<DIFile>(6).getFilename();
491 StringRef getDirectory() const {
492 return getFieldAs<DIFile>(6).getDirectory();
495 DIFile getFile() const {
496 return getFieldAs<DIFile>(6);
499 /// getScopeLineNumber - Get the beginning of the scope of the
500 /// function, not necessarily where the name of the program
502 unsigned getScopeLineNumber() const { return getUnsignedField(20); }
504 /// Verify - Verify that a subprogram descriptor is well formed.
507 /// describes - Return true if this subprogram provides debugging
508 /// information for the function F.
509 bool describes(const Function *F);
511 Function *getFunction() const { return getFunctionField(16); }
512 void replaceFunction(Function *F) { replaceFunctionField(16, F); }
513 DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
514 DISubprogram getFunctionDeclaration() const {
515 return getFieldAs<DISubprogram>(18);
517 MDNode *getVariablesNodes() const;
518 DIArray getVariables() const;
521 /// DIGlobalVariable - This is a wrapper for a global variable.
522 class DIGlobalVariable : public DIDescriptor {
523 friend class DIDescriptor;
524 void printInternal(raw_ostream &OS) const;
526 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
528 DIScope getContext() const { return getFieldAs<DIScope>(2); }
529 StringRef getName() const { return getStringField(3); }
530 StringRef getDisplayName() const { return getStringField(4); }
531 StringRef getLinkageName() const { return getStringField(5); }
532 StringRef getFilename() const {
533 return getFieldAs<DIFile>(6).getFilename();
535 StringRef getDirectory() const {
536 return getFieldAs<DIFile>(6).getDirectory();
540 unsigned getLineNumber() const { return getUnsignedField(7); }
541 DIType getType() const { return getFieldAs<DIType>(8); }
542 unsigned isLocalToUnit() const { return getUnsignedField(9); }
543 unsigned isDefinition() const { return getUnsignedField(10); }
545 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
546 Constant *getConstant() const { return getConstantField(11); }
547 DIDerivedType getStaticDataMemberDeclaration() const {
548 return getFieldAs<DIDerivedType>(12);
551 /// Verify - Verify that a global variable descriptor is well formed.
555 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
557 class DIVariable : public DIDescriptor {
558 friend class DIDescriptor;
559 void printInternal(raw_ostream &OS) const;
561 explicit DIVariable(const MDNode *N = 0)
564 DIScope getContext() const { return getFieldAs<DIScope>(1); }
565 StringRef getName() const { return getStringField(2); }
566 DIFile getFile() const { return getFieldAs<DIFile>(3); }
567 unsigned getLineNumber() const {
568 return (getUnsignedField(4) << 8) >> 8;
570 unsigned getArgNumber() const {
571 unsigned L = getUnsignedField(4);
574 DIType getType() const { return getFieldAs<DIType>(5); }
576 /// isArtificial - Return true if this variable is marked as "artificial".
577 bool isArtificial() const {
578 return (getUnsignedField(6) & FlagArtificial) != 0;
581 bool isObjectPointer() const {
582 return (getUnsignedField(6) & FlagObjectPointer) != 0;
585 /// getInlinedAt - If this variable is inlined then return inline location.
586 MDNode *getInlinedAt() const;
588 /// Verify - Verify that a variable descriptor is well formed.
591 /// HasComplexAddr - Return true if the variable has a complex address.
592 bool hasComplexAddress() const {
593 return getNumAddrElements() > 0;
596 unsigned getNumAddrElements() const;
598 uint64_t getAddrElement(unsigned Idx) const {
599 return getUInt64Field(Idx+8);
602 /// isBlockByrefVariable - Return true if the variable was declared as
603 /// a "__block" variable (Apple Blocks).
604 bool isBlockByrefVariable() const {
605 return getType().isBlockByrefStruct();
608 /// isInlinedFnArgument - Return true if this variable provides debugging
609 /// information for an inlined function arguments.
610 bool isInlinedFnArgument(const Function *CurFn);
612 void printExtendedName(raw_ostream &OS) const;
615 /// DILexicalBlock - This is a wrapper for a lexical block.
616 class DILexicalBlock : public DIScope {
618 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
619 DIScope getContext() const { return getFieldAs<DIScope>(1); }
620 unsigned getLineNumber() const { return getUnsignedField(2); }
621 unsigned getColumnNumber() const { return getUnsignedField(3); }
622 StringRef getDirectory() const {
623 return getFieldAs<DIFile>(4).getDirectory();
625 StringRef getFilename() const {
626 return getFieldAs<DIFile>(4).getFilename();
631 /// DILexicalBlockFile - This is a wrapper for a lexical block with
632 /// a filename change.
633 class DILexicalBlockFile : public DIScope {
635 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
636 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
637 unsigned getLineNumber() const { return getScope().getLineNumber(); }
638 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
639 StringRef getDirectory() const {
640 return getFieldAs<DIFile>(2).getDirectory();
642 StringRef getFilename() const {
643 return getFieldAs<DIFile>(2).getFilename();
645 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(1); }
649 /// DINameSpace - A wrapper for a C++ style name space.
650 class DINameSpace : public DIScope {
652 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
653 DIScope getContext() const { return getFieldAs<DIScope>(1); }
654 StringRef getName() const { return getStringField(2); }
655 StringRef getDirectory() const {
656 return getFieldAs<DIFile>(3).getDirectory();
658 StringRef getFilename() const {
659 return getFieldAs<DIFile>(3).getFilename();
661 unsigned getLineNumber() const { return getUnsignedField(4); }
665 /// DILocation - This object holds location information. This object
666 /// is not associated with any DWARF tag.
667 class DILocation : public DIDescriptor {
669 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
671 unsigned getLineNumber() const { return getUnsignedField(0); }
672 unsigned getColumnNumber() const { return getUnsignedField(1); }
673 DIScope getScope() const { return getFieldAs<DIScope>(2); }
674 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
675 StringRef getFilename() const { return getScope().getFilename(); }
676 StringRef getDirectory() const { return getScope().getDirectory(); }
680 class DIObjCProperty : public DIDescriptor {
681 friend class DIDescriptor;
682 void printInternal(raw_ostream &OS) const;
684 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
686 StringRef getObjCPropertyName() const { return getStringField(1); }
687 DIFile getFile() const { return getFieldAs<DIFile>(2); }
688 unsigned getLineNumber() const { return getUnsignedField(3); }
690 StringRef getObjCPropertyGetterName() const {
691 return getStringField(4);
693 StringRef getObjCPropertySetterName() const {
694 return getStringField(5);
696 bool isReadOnlyObjCProperty() {
697 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
699 bool isReadWriteObjCProperty() {
700 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
702 bool isAssignObjCProperty() {
703 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
705 bool isRetainObjCProperty() {
706 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
708 bool isCopyObjCProperty() {
709 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
711 bool isNonAtomicObjCProperty() {
712 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
715 DIType getType() const { return getFieldAs<DIType>(7); }
717 /// Verify - Verify that a derived type descriptor is well formed.
721 /// getDISubprogram - Find subprogram that is enclosing this scope.
722 DISubprogram getDISubprogram(const MDNode *Scope);
724 /// getDICompositeType - Find underlying composite type.
725 DICompositeType getDICompositeType(DIType T);
727 /// isSubprogramContext - Return true if Context is either a subprogram
728 /// or another context nested inside a subprogram.
729 bool isSubprogramContext(const MDNode *Context);
731 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
732 /// to hold function specific information.
733 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
735 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
736 /// suitable to hold function specific information.
737 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
739 /// createInlinedVariable - Create a new inlined variable based on current
741 /// @param DV Current Variable.
742 /// @param InlinedScope Location at current variable is inlined.
743 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
744 LLVMContext &VMContext);
746 /// cleanseInlinedVariable - Remove inlined scope from the variable.
747 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
749 class DebugInfoFinder {
751 /// processModule - Process entire module and collect debug info
753 void processModule(const Module &M);
756 /// processType - Process DIType.
757 void processType(DIType DT);
759 /// processLexicalBlock - Process DILexicalBlock.
760 void processLexicalBlock(DILexicalBlock LB);
762 /// processSubprogram - Process DISubprogram.
763 void processSubprogram(DISubprogram SP);
765 /// processDeclare - Process DbgDeclareInst.
766 void processDeclare(const DbgDeclareInst *DDI);
768 /// processLocation - Process DILocation.
769 void processLocation(DILocation Loc);
771 /// addCompileUnit - Add compile unit into CUs.
772 bool addCompileUnit(DICompileUnit CU);
774 /// addGlobalVariable - Add global variable into GVs.
775 bool addGlobalVariable(DIGlobalVariable DIG);
777 // addSubprogram - Add subprogram into SPs.
778 bool addSubprogram(DISubprogram SP);
780 /// addType - Add type into Tys.
781 bool addType(DIType DT);
784 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
785 iterator compile_unit_begin() const { return CUs.begin(); }
786 iterator compile_unit_end() const { return CUs.end(); }
787 iterator subprogram_begin() const { return SPs.begin(); }
788 iterator subprogram_end() const { return SPs.end(); }
789 iterator global_variable_begin() const { return GVs.begin(); }
790 iterator global_variable_end() const { return GVs.end(); }
791 iterator type_begin() const { return TYs.begin(); }
792 iterator type_end() const { return TYs.end(); }
794 unsigned compile_unit_count() const { return CUs.size(); }
795 unsigned global_variable_count() const { return GVs.size(); }
796 unsigned subprogram_count() const { return SPs.size(); }
797 unsigned type_count() const { return TYs.size(); }
800 SmallVector<MDNode *, 8> CUs; // Compile Units
801 SmallVector<MDNode *, 8> SPs; // Subprograms
802 SmallVector<MDNode *, 8> GVs; // Global Variables;
803 SmallVector<MDNode *, 8> TYs; // Types
804 SmallPtrSet<MDNode *, 64> NodesSeen;
806 } // end namespace llvm