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"
44 class DILexicalBlockFile;
49 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
50 /// This should not be stored in a container, because the underlying MDNode
51 /// may change in certain situations.
56 FlagProtected = 1 << 1,
58 FlagAppleBlock = 1 << 3,
59 FlagBlockByrefStruct = 1 << 4,
61 FlagArtificial = 1 << 6,
62 FlagExplicit = 1 << 7,
63 FlagPrototyped = 1 << 8,
64 FlagObjcClassComplete = 1 << 9,
65 FlagObjectPointer = 1 << 10,
67 FlagStaticMember = 1 << 12,
68 FlagIndirectVariable = 1 << 13
71 const MDNode *DbgNode;
73 StringRef getStringField(unsigned Elt) const;
74 unsigned getUnsignedField(unsigned Elt) const {
75 return (unsigned)getUInt64Field(Elt);
77 uint64_t getUInt64Field(unsigned Elt) const;
78 int64_t getInt64Field(unsigned Elt) const;
79 DIDescriptor getDescriptorField(unsigned Elt) const;
81 template <typename DescTy>
82 DescTy getFieldAs(unsigned Elt) const {
83 return DescTy(getDescriptorField(Elt));
86 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
87 Constant *getConstantField(unsigned Elt) const;
88 Function *getFunctionField(unsigned Elt) const;
89 void replaceFunctionField(unsigned Elt, Function *F);
92 explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {}
96 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
97 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
99 // An explicit operator bool so that we can do testing of DI values
101 // FIXME: This operator bool isn't actually protecting anything at the
102 // moment due to the conversion operator above making DIDescriptor nodes
103 // implicitly convertable to bool.
104 LLVM_EXPLICIT operator bool() const { return DbgNode != 0; }
106 bool operator==(DIDescriptor Other) const {
107 return DbgNode == Other.DbgNode;
109 bool operator!=(DIDescriptor Other) const {
110 return !operator==(Other);
113 uint16_t getTag() const {
114 return getUnsignedField(0) & ~LLVMDebugVersionMask;
117 bool isDerivedType() const;
118 bool isCompositeType() const;
119 bool isBasicType() const;
120 bool isVariable() const;
121 bool isSubprogram() const;
122 bool isGlobalVariable() const;
123 bool isScope() const;
125 bool isCompileUnit() const;
126 bool isNameSpace() const;
127 bool isLexicalBlockFile() const;
128 bool isLexicalBlock() const;
129 bool isSubrange() const;
130 bool isEnumerator() const;
132 bool isUnspecifiedParameter() const;
133 bool isTemplateTypeParameter() const;
134 bool isTemplateValueParameter() const;
135 bool isObjCProperty() const;
136 bool isImportedEntity() const;
138 /// print - print descriptor.
139 void print(raw_ostream &OS) const;
141 /// dump - print descriptor to dbgs() with a newline.
145 /// DISubrange - This is used to represent ranges, for array bounds.
146 class DISubrange : public DIDescriptor {
147 friend class DIDescriptor;
148 void printInternal(raw_ostream &OS) const;
150 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
152 int64_t getLo() const { return getInt64Field(1); }
153 int64_t getCount() const { return getInt64Field(2); }
157 /// DIArray - This descriptor holds an array of descriptors.
158 class DIArray : public DIDescriptor {
160 explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {}
162 unsigned getNumElements() const;
163 DIDescriptor getElement(unsigned Idx) const {
164 return getDescriptorField(Idx);
168 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
169 /// FIXME: it seems strange that this doesn't have either a reference to the
170 /// type/precision or a file/line pair for location info.
171 class DIEnumerator : public DIDescriptor {
172 friend class DIDescriptor;
173 void printInternal(raw_ostream &OS) const;
175 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
177 StringRef getName() const { return getStringField(1); }
178 int64_t getEnumValue() const { return getInt64Field(2); }
182 /// DIScope - A base class for various scopes.
183 class DIScope : public DIDescriptor {
185 friend class DIDescriptor;
186 void printInternal(raw_ostream &OS) const;
188 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
190 /// Gets the parent scope for this scope node or returns a
191 /// default constructed scope.
192 DIScope getContext() const;
193 StringRef getFilename() const;
194 StringRef getDirectory() const;
197 /// DIType - This is a wrapper for a type.
198 /// FIXME: Types should be factored much better so that CV qualifiers and
199 /// others do not require a huge and empty descriptor full of zeros.
200 class DIType : public DIScope {
202 friend class DIDescriptor;
203 void printInternal(raw_ostream &OS) const;
206 DIType(const MDNode *N = 0) : DIScope(N) {}
208 /// Verify - Verify that a type descriptor is well formed.
211 DIScope getContext() const { return getFieldAs<DIScope>(2); }
212 StringRef getName() const { return getStringField(3); }
213 unsigned getLineNumber() const { return getUnsignedField(4); }
214 uint64_t getSizeInBits() const { return getUInt64Field(5); }
215 uint64_t getAlignInBits() const { return getUInt64Field(6); }
216 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
217 // carry this is just plain insane.
218 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
219 unsigned getFlags() const { return getUnsignedField(8); }
220 bool isPrivate() const {
221 return (getFlags() & FlagPrivate) != 0;
223 bool isProtected() const {
224 return (getFlags() & FlagProtected) != 0;
226 bool isForwardDecl() const {
227 return (getFlags() & FlagFwdDecl) != 0;
229 // isAppleBlock - Return true if this is the Apple Blocks extension.
230 bool isAppleBlockExtension() const {
231 return (getFlags() & FlagAppleBlock) != 0;
233 bool isBlockByrefStruct() const {
234 return (getFlags() & FlagBlockByrefStruct) != 0;
236 bool isVirtual() const {
237 return (getFlags() & FlagVirtual) != 0;
239 bool isArtificial() const {
240 return (getFlags() & FlagArtificial) != 0;
242 bool isObjectPointer() const {
243 return (getFlags() & FlagObjectPointer) != 0;
245 bool isObjcClassComplete() const {
246 return (getFlags() & FlagObjcClassComplete) != 0;
248 bool isVector() const {
249 return (getFlags() & FlagVector) != 0;
251 bool isStaticMember() const {
252 return (getFlags() & FlagStaticMember) != 0;
254 bool isValid() const {
255 return DbgNode && isType();
258 /// isUnsignedDIType - Return true if type encoding is unsigned.
259 bool isUnsignedDIType();
261 /// replaceAllUsesWith - Replace all uses of debug info referenced by
263 void replaceAllUsesWith(DIDescriptor &D);
264 void replaceAllUsesWith(MDNode *D);
267 /// DIBasicType - A basic type, like 'int' or 'float'.
268 class DIBasicType : public DIType {
270 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
272 unsigned getEncoding() const { return getUnsignedField(9); }
274 /// Verify - Verify that a basic type descriptor is well formed.
278 /// DIDerivedType - A simple derived type, like a const qualified type,
279 /// a typedef, a pointer or reference, et cetera. Or, a data member of
280 /// a class/struct/union.
281 class DIDerivedType : public DIType {
282 friend class DIDescriptor;
283 void printInternal(raw_ostream &OS) const;
286 explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {}
288 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
290 /// getOriginalTypeSize - If this type is derived from a base type then
291 /// return base type size.
292 uint64_t getOriginalTypeSize() const;
294 /// getObjCProperty - Return property node, if this ivar is
295 /// associated with one.
296 MDNode *getObjCProperty() const;
298 DIType getClassType() const {
299 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
300 return getFieldAs<DIType>(10);
303 Constant *getConstant() const {
304 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
305 return getConstantField(10);
308 /// Verify - Verify that a derived type descriptor is well formed.
312 /// DICompositeType - This descriptor holds a type that can refer to multiple
313 /// other types, like a function or struct.
314 /// DICompositeType is derived from DIDerivedType because some
315 /// composite types (such as enums) can be derived from basic types
316 // FIXME: Make this derive from DIType directly & just store the
317 // base type in a single DIType field.
318 class DICompositeType : public DIDerivedType {
319 friend class DIDescriptor;
320 void printInternal(raw_ostream &OS) const;
322 explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {}
324 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
325 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
326 void addMember(DIDescriptor D);
327 unsigned getRunTimeLang() const { return getUnsignedField(11); }
328 DICompositeType getContainingType() const {
329 return getFieldAs<DICompositeType>(12);
331 void setContainingType(DICompositeType ContainingType);
332 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
334 /// Verify - Verify that a composite type descriptor is well formed.
338 /// DIFile - This is a wrapper for a file.
339 class DIFile : public DIScope {
340 friend class DIDescriptor;
342 explicit DIFile(const MDNode *N = 0) : DIScope(N) {}
343 MDNode *getFileNode() const;
347 /// DICompileUnit - A wrapper for a compile unit.
348 class DICompileUnit : public DIScope {
349 friend class DIDescriptor;
350 void printInternal(raw_ostream &OS) const;
352 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
354 unsigned getLanguage() const { return getUnsignedField(2); }
355 StringRef getProducer() const { return getStringField(3); }
357 bool isOptimized() const { return getUnsignedField(4) != 0; }
358 StringRef getFlags() const { return getStringField(5); }
359 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
361 DIArray getEnumTypes() const;
362 DIArray getRetainedTypes() const;
363 DIArray getSubprograms() const;
364 DIArray getGlobalVariables() const;
365 DIArray getImportedEntities() const;
367 StringRef getSplitDebugFilename() const { return getStringField(12); }
369 /// Verify - Verify that a compile unit is well formed.
373 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
374 class DISubprogram : public DIScope {
375 friend class DIDescriptor;
376 void printInternal(raw_ostream &OS) const;
378 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
380 DIScope getContext() const { return getFieldAs<DIScope>(2); }
381 StringRef getName() const { return getStringField(3); }
382 StringRef getDisplayName() const { return getStringField(4); }
383 StringRef getLinkageName() const { return getStringField(5); }
384 unsigned getLineNumber() const { return getUnsignedField(6); }
385 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
387 /// isLocalToUnit - Return true if this subprogram is local to the current
388 /// compile unit, like 'static' in C.
389 unsigned isLocalToUnit() const { return getUnsignedField(8); }
390 unsigned isDefinition() const { return getUnsignedField(9); }
392 unsigned getVirtuality() const { return getUnsignedField(10); }
393 unsigned getVirtualIndex() const { return getUnsignedField(11); }
395 DICompositeType getContainingType() const {
396 return getFieldAs<DICompositeType>(12);
399 unsigned getFlags() const {
400 return getUnsignedField(13);
403 unsigned isArtificial() const {
404 return (getUnsignedField(13) & FlagArtificial) != 0;
406 /// isPrivate - Return true if this subprogram has "private"
407 /// access specifier.
408 bool isPrivate() const {
409 return (getUnsignedField(13) & FlagPrivate) != 0;
411 /// isProtected - Return true if this subprogram has "protected"
412 /// access specifier.
413 bool isProtected() const {
414 return (getUnsignedField(13) & FlagProtected) != 0;
416 /// isExplicit - Return true if this subprogram is marked as explicit.
417 bool isExplicit() const {
418 return (getUnsignedField(13) & FlagExplicit) != 0;
420 /// isPrototyped - Return true if this subprogram is prototyped.
421 bool isPrototyped() const {
422 return (getUnsignedField(13) & FlagPrototyped) != 0;
425 unsigned isOptimized() const;
427 /// Verify - Verify that a subprogram descriptor is well formed.
430 /// describes - Return true if this subprogram provides debugging
431 /// information for the function F.
432 bool describes(const Function *F);
434 Function *getFunction() const { return getFunctionField(15); }
435 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
436 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
437 DISubprogram getFunctionDeclaration() const {
438 return getFieldAs<DISubprogram>(17);
440 MDNode *getVariablesNodes() const;
441 DIArray getVariables() const;
443 /// getScopeLineNumber - Get the beginning of the scope of the
444 /// function, not necessarily where the name of the program
446 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
449 /// DILexicalBlock - This is a wrapper for a lexical block.
450 class DILexicalBlock : public DIScope {
452 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
453 DIScope getContext() const { return getFieldAs<DIScope>(2); }
454 unsigned getLineNumber() const { return getUnsignedField(3); }
455 unsigned getColumnNumber() const { return getUnsignedField(4); }
459 /// DILexicalBlockFile - This is a wrapper for a lexical block with
460 /// a filename change.
461 class DILexicalBlockFile : public DIScope {
463 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
464 DIScope getContext() const {
465 if (getScope().isSubprogram())
467 return getScope().getContext();
469 unsigned getLineNumber() const { return getScope().getLineNumber(); }
470 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
471 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
475 /// DINameSpace - A wrapper for a C++ style name space.
476 class DINameSpace : public DIScope {
477 friend class DIDescriptor;
478 void printInternal(raw_ostream &OS) const;
480 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
481 DIScope getContext() const { return getFieldAs<DIScope>(2); }
482 StringRef getName() const { return getStringField(3); }
483 unsigned getLineNumber() const { return getUnsignedField(4); }
487 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
488 class DITemplateTypeParameter : public DIDescriptor {
490 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
492 DIScope getContext() const { return getFieldAs<DIScope>(1); }
493 StringRef getName() const { return getStringField(2); }
494 DIType getType() const { return getFieldAs<DIType>(3); }
495 StringRef getFilename() const {
496 return getFieldAs<DIFile>(4).getFilename();
498 StringRef getDirectory() const {
499 return getFieldAs<DIFile>(4).getDirectory();
501 unsigned getLineNumber() const { return getUnsignedField(5); }
502 unsigned getColumnNumber() const { return getUnsignedField(6); }
506 /// DITemplateValueParameter - This is a wrapper for template value parameter.
507 class DITemplateValueParameter : public DIDescriptor {
509 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
511 DIScope getContext() const { return getFieldAs<DIScope>(1); }
512 StringRef getName() const { return getStringField(2); }
513 DIType getType() const { return getFieldAs<DIType>(3); }
514 Value *getValue() const;
515 StringRef getFilename() const {
516 return getFieldAs<DIFile>(5).getFilename();
518 StringRef getDirectory() const {
519 return getFieldAs<DIFile>(5).getDirectory();
521 unsigned getLineNumber() const { return getUnsignedField(6); }
522 unsigned getColumnNumber() const { return getUnsignedField(7); }
526 /// DIGlobalVariable - This is a wrapper for a global variable.
527 class DIGlobalVariable : public DIDescriptor {
528 friend class DIDescriptor;
529 void printInternal(raw_ostream &OS) const;
531 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
533 DIScope getContext() const { return getFieldAs<DIScope>(2); }
534 StringRef getName() const { return getStringField(3); }
535 StringRef getDisplayName() const { return getStringField(4); }
536 StringRef getLinkageName() const { return getStringField(5); }
537 StringRef getFilename() const {
538 return getFieldAs<DIFile>(6).getFilename();
540 StringRef getDirectory() const {
541 return getFieldAs<DIFile>(6).getDirectory();
545 unsigned getLineNumber() const { return getUnsignedField(7); }
546 DIType getType() const { return getFieldAs<DIType>(8); }
547 unsigned isLocalToUnit() const { return getUnsignedField(9); }
548 unsigned isDefinition() const { return getUnsignedField(10); }
550 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
551 Constant *getConstant() const { return getConstantField(11); }
552 DIDerivedType getStaticDataMemberDeclaration() const {
553 return getFieldAs<DIDerivedType>(12);
556 /// Verify - Verify that a global variable descriptor is well formed.
560 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
562 class DIVariable : public DIDescriptor {
563 friend class DIDescriptor;
564 void printInternal(raw_ostream &OS) const;
566 explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {}
568 DIScope getContext() const { return getFieldAs<DIScope>(1); }
569 StringRef getName() const { return getStringField(2); }
570 DIFile getFile() const { return getFieldAs<DIFile>(3); }
571 unsigned getLineNumber() const {
572 return (getUnsignedField(4) << 8) >> 8;
574 unsigned getArgNumber() const {
575 unsigned L = getUnsignedField(4);
578 DIType getType() const { return getFieldAs<DIType>(5); }
580 /// isArtificial - Return true if this variable is marked as "artificial".
581 bool isArtificial() const {
582 return (getUnsignedField(6) & FlagArtificial) != 0;
585 bool isObjectPointer() const {
586 return (getUnsignedField(6) & FlagObjectPointer) != 0;
589 /// \brief Return true if this variable is represented as a pointer.
590 bool isIndirect() const {
591 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
594 /// getInlinedAt - If this variable is inlined then return inline location.
595 MDNode *getInlinedAt() const;
597 /// Verify - Verify that a variable descriptor is well formed.
600 /// HasComplexAddr - Return true if the variable has a complex address.
601 bool hasComplexAddress() const {
602 return getNumAddrElements() > 0;
605 unsigned getNumAddrElements() const;
607 uint64_t getAddrElement(unsigned Idx) const {
608 return getUInt64Field(Idx+8);
611 /// isBlockByrefVariable - Return true if the variable was declared as
612 /// a "__block" variable (Apple Blocks).
613 bool isBlockByrefVariable() const {
614 return getType().isBlockByrefStruct();
617 /// isInlinedFnArgument - Return true if this variable provides debugging
618 /// information for an inlined function arguments.
619 bool isInlinedFnArgument(const Function *CurFn);
621 void printExtendedName(raw_ostream &OS) const;
624 /// DILocation - This object holds location information. This object
625 /// is not associated with any DWARF tag.
626 class DILocation : public DIDescriptor {
628 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
630 unsigned getLineNumber() const { return getUnsignedField(0); }
631 unsigned getColumnNumber() const { return getUnsignedField(1); }
632 DIScope getScope() const { return getFieldAs<DIScope>(2); }
633 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
634 StringRef getFilename() const { return getScope().getFilename(); }
635 StringRef getDirectory() const { return getScope().getDirectory(); }
639 class DIObjCProperty : public DIDescriptor {
640 friend class DIDescriptor;
641 void printInternal(raw_ostream &OS) const;
643 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
645 StringRef getObjCPropertyName() const { return getStringField(1); }
646 DIFile getFile() const { return getFieldAs<DIFile>(2); }
647 unsigned getLineNumber() const { return getUnsignedField(3); }
649 StringRef getObjCPropertyGetterName() const {
650 return getStringField(4);
652 StringRef getObjCPropertySetterName() const {
653 return getStringField(5);
655 bool isReadOnlyObjCProperty() const {
656 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
658 bool isReadWriteObjCProperty() const {
659 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
661 bool isAssignObjCProperty() const {
662 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
664 bool isRetainObjCProperty() const {
665 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
667 bool isCopyObjCProperty() const {
668 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
670 bool isNonAtomicObjCProperty() const {
671 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
674 DIType getType() const { return getFieldAs<DIType>(7); }
676 /// Verify - Verify that a derived type descriptor is well formed.
680 /// \brief An imported module (C++ using directive or similar).
681 class DIImportedEntity : public DIDescriptor {
682 friend class DIDescriptor;
683 void printInternal(raw_ostream &OS) const;
685 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
686 DIScope getContext() const { return getFieldAs<DIScope>(1); }
687 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
688 unsigned getLineNumber() const { return getUnsignedField(3); }
689 StringRef getName() const { return getStringField(4); }
693 /// getDISubprogram - Find subprogram that is enclosing this scope.
694 DISubprogram getDISubprogram(const MDNode *Scope);
696 /// getDICompositeType - Find underlying composite type.
697 DICompositeType getDICompositeType(DIType T);
699 /// isSubprogramContext - Return true if Context is either a subprogram
700 /// or another context nested inside a subprogram.
701 bool isSubprogramContext(const MDNode *Context);
703 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
704 /// to hold function specific information.
705 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
707 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
708 /// suitable to hold function specific information.
709 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
711 /// createInlinedVariable - Create a new inlined variable based on current
713 /// @param DV Current Variable.
714 /// @param InlinedScope Location at current variable is inlined.
715 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
716 LLVMContext &VMContext);
718 /// cleanseInlinedVariable - Remove inlined scope from the variable.
719 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
721 /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To
722 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
723 /// processDeclare, processValue and processLocation to handle DbgDeclareInst,
724 /// DbgValueInst and DbgLoc attached to instructions. processModule will go
725 /// through all DICompileUnits in llvm.dbg.cu and list debug info MDNodes
727 class DebugInfoFinder {
729 /// processModule - Process entire module and collect debug info
731 void processModule(const Module &M);
733 /// processDeclare - Process DbgDeclareInst.
734 void processDeclare(const DbgDeclareInst *DDI);
735 /// Process DbgValueInst.
736 void processValue(const DbgValueInst *DVI);
737 /// processLocation - Process DILocation.
738 void processLocation(DILocation Loc);
743 /// processType - Process DIType.
744 void processType(DIType DT);
746 /// processLexicalBlock - Process DILexicalBlock.
747 void processLexicalBlock(DILexicalBlock LB);
749 /// processSubprogram - Process DISubprogram.
750 void processSubprogram(DISubprogram SP);
752 void processScope(DIScope Scope);
754 /// addCompileUnit - Add compile unit into CUs.
755 bool addCompileUnit(DICompileUnit CU);
757 /// addGlobalVariable - Add global variable into GVs.
758 bool addGlobalVariable(DIGlobalVariable DIG);
760 // addSubprogram - Add subprogram into SPs.
761 bool addSubprogram(DISubprogram SP);
763 /// addType - Add type into Tys.
764 bool addType(DIType DT);
766 bool addScope(DIScope Scope);
769 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
770 iterator compile_unit_begin() const { return CUs.begin(); }
771 iterator compile_unit_end() const { return CUs.end(); }
772 iterator subprogram_begin() const { return SPs.begin(); }
773 iterator subprogram_end() const { return SPs.end(); }
774 iterator global_variable_begin() const { return GVs.begin(); }
775 iterator global_variable_end() const { return GVs.end(); }
776 iterator type_begin() const { return TYs.begin(); }
777 iterator type_end() const { return TYs.end(); }
778 iterator scope_begin() const { return Scopes.begin(); }
779 iterator scope_end() const { return Scopes.end(); }
781 unsigned compile_unit_count() const { return CUs.size(); }
782 unsigned global_variable_count() const { return GVs.size(); }
783 unsigned subprogram_count() const { return SPs.size(); }
784 unsigned type_count() const { return TYs.size(); }
785 unsigned scope_count() const { return Scopes.size(); }
788 SmallVector<MDNode *, 8> CUs; // Compile Units
789 SmallVector<MDNode *, 8> SPs; // Subprograms
790 SmallVector<MDNode *, 8> GVs; // Global Variables;
791 SmallVector<MDNode *, 8> TYs; // Types
792 SmallVector<MDNode *, 8> Scopes; // Scopes
793 SmallPtrSet<MDNode *, 64> NodesSeen;
795 } // end namespace llvm