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"
45 class DILexicalBlockFile;
50 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
51 /// This should not be stored in a container, because the underlying MDNode
52 /// may change in certain situations.
57 FlagProtected = 1 << 1,
59 FlagAppleBlock = 1 << 3,
60 FlagBlockByrefStruct = 1 << 4,
62 FlagArtificial = 1 << 6,
63 FlagExplicit = 1 << 7,
64 FlagPrototyped = 1 << 8,
65 FlagObjcClassComplete = 1 << 9,
66 FlagObjectPointer = 1 << 10,
68 FlagStaticMember = 1 << 12,
69 FlagIndirectVariable = 1 << 13
72 const MDNode *DbgNode;
74 StringRef getStringField(unsigned Elt) const;
75 unsigned getUnsignedField(unsigned Elt) const {
76 return (unsigned)getUInt64Field(Elt);
78 uint64_t getUInt64Field(unsigned Elt) const;
79 int64_t getInt64Field(unsigned Elt) const;
80 DIDescriptor getDescriptorField(unsigned Elt) const;
82 template <typename DescTy>
83 DescTy getFieldAs(unsigned Elt) const {
84 return DescTy(getDescriptorField(Elt));
87 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
88 Constant *getConstantField(unsigned Elt) const;
89 Function *getFunctionField(unsigned Elt) const;
90 void replaceFunctionField(unsigned Elt, Function *F);
93 explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {}
97 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
98 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
100 // An explicit operator bool so that we can do testing of DI values
102 // FIXME: This operator bool isn't actually protecting anything at the
103 // moment due to the conversion operator above making DIDescriptor nodes
104 // implicitly convertable to bool.
105 LLVM_EXPLICIT operator bool() const { return DbgNode != 0; }
107 bool operator==(DIDescriptor Other) const {
108 return DbgNode == Other.DbgNode;
110 bool operator!=(DIDescriptor Other) const {
111 return !operator==(Other);
114 uint16_t getTag() const {
115 return getUnsignedField(0) & ~LLVMDebugVersionMask;
118 bool isDerivedType() const;
119 bool isCompositeType() const;
120 bool isBasicType() const;
121 bool isVariable() const;
122 bool isSubprogram() const;
123 bool isGlobalVariable() const;
124 bool isScope() const;
126 bool isCompileUnit() const;
127 bool isNameSpace() const;
128 bool isLexicalBlockFile() const;
129 bool isLexicalBlock() const;
130 bool isSubrange() const;
131 bool isEnumerator() const;
133 bool isUnspecifiedParameter() const;
134 bool isTemplateTypeParameter() const;
135 bool isTemplateValueParameter() const;
136 bool isObjCProperty() const;
137 bool isImportedEntity() const;
139 /// print - print descriptor.
140 void print(raw_ostream &OS) const;
142 /// dump - print descriptor to dbgs() with a newline.
146 /// DISubrange - This is used to represent ranges, for array bounds.
147 class DISubrange : public DIDescriptor {
148 friend class DIDescriptor;
149 void printInternal(raw_ostream &OS) const;
151 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
153 int64_t getLo() const { return getInt64Field(1); }
154 int64_t getCount() const { return getInt64Field(2); }
158 /// DIArray - This descriptor holds an array of descriptors.
159 class DIArray : public DIDescriptor {
161 explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {}
163 unsigned getNumElements() const;
164 DIDescriptor getElement(unsigned Idx) const {
165 return getDescriptorField(Idx);
169 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
170 /// FIXME: it seems strange that this doesn't have either a reference to the
171 /// type/precision or a file/line pair for location info.
172 class DIEnumerator : public DIDescriptor {
173 friend class DIDescriptor;
174 void printInternal(raw_ostream &OS) const;
176 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
178 StringRef getName() const { return getStringField(1); }
179 int64_t getEnumValue() const { return getInt64Field(2); }
183 /// DIScope - A base class for various scopes.
184 class DIScope : public DIDescriptor {
186 friend class DIDescriptor;
187 void printInternal(raw_ostream &OS) const;
189 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
191 /// Gets the parent scope for this scope node or returns a
192 /// default constructed scope.
193 DIScope getContext() const;
194 StringRef getFilename() const;
195 StringRef getDirectory() const;
198 /// DIType - This is a wrapper for a type.
199 /// FIXME: Types should be factored much better so that CV qualifiers and
200 /// others do not require a huge and empty descriptor full of zeros.
201 class DIType : public DIScope {
203 friend class DIDescriptor;
204 void printInternal(raw_ostream &OS) const;
207 DIType(const MDNode *N = 0) : DIScope(N) {}
209 /// Verify - Verify that a type descriptor is well formed.
212 DIScope getContext() const { return getFieldAs<DIScope>(2); }
213 StringRef getName() const { return getStringField(3); }
214 unsigned getLineNumber() const { return getUnsignedField(4); }
215 uint64_t getSizeInBits() const { return getUInt64Field(5); }
216 uint64_t getAlignInBits() const { return getUInt64Field(6); }
217 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
218 // carry this is just plain insane.
219 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
220 unsigned getFlags() const { return getUnsignedField(8); }
221 bool isPrivate() const {
222 return (getFlags() & FlagPrivate) != 0;
224 bool isProtected() const {
225 return (getFlags() & FlagProtected) != 0;
227 bool isForwardDecl() const {
228 return (getFlags() & FlagFwdDecl) != 0;
230 // isAppleBlock - Return true if this is the Apple Blocks extension.
231 bool isAppleBlockExtension() const {
232 return (getFlags() & FlagAppleBlock) != 0;
234 bool isBlockByrefStruct() const {
235 return (getFlags() & FlagBlockByrefStruct) != 0;
237 bool isVirtual() const {
238 return (getFlags() & FlagVirtual) != 0;
240 bool isArtificial() const {
241 return (getFlags() & FlagArtificial) != 0;
243 bool isObjectPointer() const {
244 return (getFlags() & FlagObjectPointer) != 0;
246 bool isObjcClassComplete() const {
247 return (getFlags() & FlagObjcClassComplete) != 0;
249 bool isVector() const {
250 return (getFlags() & FlagVector) != 0;
252 bool isStaticMember() const {
253 return (getFlags() & FlagStaticMember) != 0;
255 bool isValid() const {
256 return DbgNode && isType();
259 /// isUnsignedDIType - Return true if type encoding is unsigned.
260 bool isUnsignedDIType();
262 /// replaceAllUsesWith - Replace all uses of debug info referenced by
264 void replaceAllUsesWith(DIDescriptor &D);
265 void replaceAllUsesWith(MDNode *D);
268 /// DIBasicType - A basic type, like 'int' or 'float'.
269 class DIBasicType : public DIType {
271 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
273 unsigned getEncoding() const { return getUnsignedField(9); }
275 /// Verify - Verify that a basic type descriptor is well formed.
279 /// DIDerivedType - A simple derived type, like a const qualified type,
280 /// a typedef, a pointer or reference, et cetera. Or, a data member of
281 /// a class/struct/union.
282 class DIDerivedType : public DIType {
283 friend class DIDescriptor;
284 void printInternal(raw_ostream &OS) const;
287 explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {}
289 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
291 /// getOriginalTypeSize - If this type is derived from a base type then
292 /// return base type size.
293 uint64_t getOriginalTypeSize() const;
295 /// getObjCProperty - Return property node, if this ivar is
296 /// associated with one.
297 MDNode *getObjCProperty() const;
299 DIType getClassType() const {
300 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
301 return getFieldAs<DIType>(10);
304 Constant *getConstant() const {
305 assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
306 return getConstantField(10);
309 /// Verify - Verify that a derived type descriptor is well formed.
313 /// DICompositeType - This descriptor holds a type that can refer to multiple
314 /// other types, like a function or struct.
315 /// DICompositeType is derived from DIDerivedType because some
316 /// composite types (such as enums) can be derived from basic types
317 // FIXME: Make this derive from DIType directly & just store the
318 // base type in a single DIType field.
319 class DICompositeType : public DIDerivedType {
320 friend class DIDescriptor;
321 void printInternal(raw_ostream &OS) const;
323 explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {}
325 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
326 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
327 void addMember(DIDescriptor D);
328 unsigned getRunTimeLang() const { return getUnsignedField(11); }
329 DICompositeType getContainingType() const {
330 return getFieldAs<DICompositeType>(12);
332 void setContainingType(DICompositeType ContainingType);
333 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
334 MDString *getIdentifier() const;
336 /// Verify - Verify that a composite type descriptor is well formed.
340 /// DIFile - This is a wrapper for a file.
341 class DIFile : public DIScope {
342 friend class DIDescriptor;
344 explicit DIFile(const MDNode *N = 0) : DIScope(N) {}
345 MDNode *getFileNode() const;
349 /// DICompileUnit - A wrapper for a compile unit.
350 class DICompileUnit : public DIScope {
351 friend class DIDescriptor;
352 void printInternal(raw_ostream &OS) const;
354 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
356 unsigned getLanguage() const { return getUnsignedField(2); }
357 StringRef getProducer() const { return getStringField(3); }
359 bool isOptimized() const { return getUnsignedField(4) != 0; }
360 StringRef getFlags() const { return getStringField(5); }
361 unsigned getRunTimeVersion() const { return getUnsignedField(6); }
363 DIArray getEnumTypes() const;
364 DIArray getRetainedTypes() const;
365 DIArray getSubprograms() const;
366 DIArray getGlobalVariables() const;
367 DIArray getImportedEntities() const;
369 StringRef getSplitDebugFilename() const { return getStringField(12); }
371 /// Verify - Verify that a compile unit is well formed.
375 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
376 class DISubprogram : public DIScope {
377 friend class DIDescriptor;
378 void printInternal(raw_ostream &OS) const;
380 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
382 DIScope getContext() const { return getFieldAs<DIScope>(2); }
383 StringRef getName() const { return getStringField(3); }
384 StringRef getDisplayName() const { return getStringField(4); }
385 StringRef getLinkageName() const { return getStringField(5); }
386 unsigned getLineNumber() const { return getUnsignedField(6); }
387 DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
389 /// isLocalToUnit - Return true if this subprogram is local to the current
390 /// compile unit, like 'static' in C.
391 unsigned isLocalToUnit() const { return getUnsignedField(8); }
392 unsigned isDefinition() const { return getUnsignedField(9); }
394 unsigned getVirtuality() const { return getUnsignedField(10); }
395 unsigned getVirtualIndex() const { return getUnsignedField(11); }
397 DICompositeType getContainingType() const {
398 return getFieldAs<DICompositeType>(12);
401 unsigned getFlags() const {
402 return getUnsignedField(13);
405 unsigned isArtificial() const {
406 return (getUnsignedField(13) & FlagArtificial) != 0;
408 /// isPrivate - Return true if this subprogram has "private"
409 /// access specifier.
410 bool isPrivate() const {
411 return (getUnsignedField(13) & FlagPrivate) != 0;
413 /// isProtected - Return true if this subprogram has "protected"
414 /// access specifier.
415 bool isProtected() const {
416 return (getUnsignedField(13) & FlagProtected) != 0;
418 /// isExplicit - Return true if this subprogram is marked as explicit.
419 bool isExplicit() const {
420 return (getUnsignedField(13) & FlagExplicit) != 0;
422 /// isPrototyped - Return true if this subprogram is prototyped.
423 bool isPrototyped() const {
424 return (getUnsignedField(13) & FlagPrototyped) != 0;
427 unsigned isOptimized() const;
429 /// Verify - Verify that a subprogram descriptor is well formed.
432 /// describes - Return true if this subprogram provides debugging
433 /// information for the function F.
434 bool describes(const Function *F);
436 Function *getFunction() const { return getFunctionField(15); }
437 void replaceFunction(Function *F) { replaceFunctionField(15, F); }
438 DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); }
439 DISubprogram getFunctionDeclaration() const {
440 return getFieldAs<DISubprogram>(17);
442 MDNode *getVariablesNodes() const;
443 DIArray getVariables() const;
445 /// getScopeLineNumber - Get the beginning of the scope of the
446 /// function, not necessarily where the name of the program
448 unsigned getScopeLineNumber() const { return getUnsignedField(19); }
451 /// DILexicalBlock - This is a wrapper for a lexical block.
452 class DILexicalBlock : public DIScope {
454 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
455 DIScope getContext() const { return getFieldAs<DIScope>(2); }
456 unsigned getLineNumber() const { return getUnsignedField(3); }
457 unsigned getColumnNumber() const { return getUnsignedField(4); }
461 /// DILexicalBlockFile - This is a wrapper for a lexical block with
462 /// a filename change.
463 class DILexicalBlockFile : public DIScope {
465 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
466 DIScope getContext() const {
467 if (getScope().isSubprogram())
469 return getScope().getContext();
471 unsigned getLineNumber() const { return getScope().getLineNumber(); }
472 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
473 DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
477 /// DINameSpace - A wrapper for a C++ style name space.
478 class DINameSpace : public DIScope {
479 friend class DIDescriptor;
480 void printInternal(raw_ostream &OS) const;
482 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
483 DIScope getContext() const { return getFieldAs<DIScope>(2); }
484 StringRef getName() const { return getStringField(3); }
485 unsigned getLineNumber() const { return getUnsignedField(4); }
489 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
490 class DITemplateTypeParameter : public DIDescriptor {
492 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
494 DIScope getContext() const { return getFieldAs<DIScope>(1); }
495 StringRef getName() const { return getStringField(2); }
496 DIType getType() const { return getFieldAs<DIType>(3); }
497 StringRef getFilename() const {
498 return getFieldAs<DIFile>(4).getFilename();
500 StringRef getDirectory() const {
501 return getFieldAs<DIFile>(4).getDirectory();
503 unsigned getLineNumber() const { return getUnsignedField(5); }
504 unsigned getColumnNumber() const { return getUnsignedField(6); }
508 /// DITemplateValueParameter - This is a wrapper for template value parameter.
509 class DITemplateValueParameter : public DIDescriptor {
511 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
513 DIScope getContext() const { return getFieldAs<DIScope>(1); }
514 StringRef getName() const { return getStringField(2); }
515 DIType getType() const { return getFieldAs<DIType>(3); }
516 Value *getValue() const;
517 StringRef getFilename() const {
518 return getFieldAs<DIFile>(5).getFilename();
520 StringRef getDirectory() const {
521 return getFieldAs<DIFile>(5).getDirectory();
523 unsigned getLineNumber() const { return getUnsignedField(6); }
524 unsigned getColumnNumber() const { return getUnsignedField(7); }
528 /// DIGlobalVariable - This is a wrapper for a global variable.
529 class DIGlobalVariable : public DIDescriptor {
530 friend class DIDescriptor;
531 void printInternal(raw_ostream &OS) const;
533 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
535 DIScope getContext() const { return getFieldAs<DIScope>(2); }
536 StringRef getName() const { return getStringField(3); }
537 StringRef getDisplayName() const { return getStringField(4); }
538 StringRef getLinkageName() const { return getStringField(5); }
539 StringRef getFilename() const {
540 return getFieldAs<DIFile>(6).getFilename();
542 StringRef getDirectory() const {
543 return getFieldAs<DIFile>(6).getDirectory();
547 unsigned getLineNumber() const { return getUnsignedField(7); }
548 DIType getType() const { return getFieldAs<DIType>(8); }
549 unsigned isLocalToUnit() const { return getUnsignedField(9); }
550 unsigned isDefinition() const { return getUnsignedField(10); }
552 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
553 Constant *getConstant() const { return getConstantField(11); }
554 DIDerivedType getStaticDataMemberDeclaration() const {
555 return getFieldAs<DIDerivedType>(12);
558 /// Verify - Verify that a global variable descriptor is well formed.
562 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
564 class DIVariable : public DIDescriptor {
565 friend class DIDescriptor;
566 void printInternal(raw_ostream &OS) const;
568 explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {}
570 DIScope getContext() const { return getFieldAs<DIScope>(1); }
571 StringRef getName() const { return getStringField(2); }
572 DIFile getFile() const { return getFieldAs<DIFile>(3); }
573 unsigned getLineNumber() const {
574 return (getUnsignedField(4) << 8) >> 8;
576 unsigned getArgNumber() const {
577 unsigned L = getUnsignedField(4);
580 DIType getType() const { return getFieldAs<DIType>(5); }
582 /// isArtificial - Return true if this variable is marked as "artificial".
583 bool isArtificial() const {
584 return (getUnsignedField(6) & FlagArtificial) != 0;
587 bool isObjectPointer() const {
588 return (getUnsignedField(6) & FlagObjectPointer) != 0;
591 /// \brief Return true if this variable is represented as a pointer.
592 bool isIndirect() const {
593 return (getUnsignedField(6) & FlagIndirectVariable) != 0;
596 /// getInlinedAt - If this variable is inlined then return inline location.
597 MDNode *getInlinedAt() const;
599 /// Verify - Verify that a variable descriptor is well formed.
602 /// HasComplexAddr - Return true if the variable has a complex address.
603 bool hasComplexAddress() const {
604 return getNumAddrElements() > 0;
607 unsigned getNumAddrElements() const;
609 uint64_t getAddrElement(unsigned Idx) const {
610 return getUInt64Field(Idx+8);
613 /// isBlockByrefVariable - Return true if the variable was declared as
614 /// a "__block" variable (Apple Blocks).
615 bool isBlockByrefVariable() const {
616 return getType().isBlockByrefStruct();
619 /// isInlinedFnArgument - Return true if this variable provides debugging
620 /// information for an inlined function arguments.
621 bool isInlinedFnArgument(const Function *CurFn);
623 void printExtendedName(raw_ostream &OS) const;
626 /// DILocation - This object holds location information. This object
627 /// is not associated with any DWARF tag.
628 class DILocation : public DIDescriptor {
630 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
632 unsigned getLineNumber() const { return getUnsignedField(0); }
633 unsigned getColumnNumber() const { return getUnsignedField(1); }
634 DIScope getScope() const { return getFieldAs<DIScope>(2); }
635 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
636 StringRef getFilename() const { return getScope().getFilename(); }
637 StringRef getDirectory() const { return getScope().getDirectory(); }
641 class DIObjCProperty : public DIDescriptor {
642 friend class DIDescriptor;
643 void printInternal(raw_ostream &OS) const;
645 explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
647 StringRef getObjCPropertyName() const { return getStringField(1); }
648 DIFile getFile() const { return getFieldAs<DIFile>(2); }
649 unsigned getLineNumber() const { return getUnsignedField(3); }
651 StringRef getObjCPropertyGetterName() const {
652 return getStringField(4);
654 StringRef getObjCPropertySetterName() const {
655 return getStringField(5);
657 bool isReadOnlyObjCProperty() const {
658 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
660 bool isReadWriteObjCProperty() const {
661 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
663 bool isAssignObjCProperty() const {
664 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
666 bool isRetainObjCProperty() const {
667 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
669 bool isCopyObjCProperty() const {
670 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
672 bool isNonAtomicObjCProperty() const {
673 return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
676 DIType getType() const { return getFieldAs<DIType>(7); }
678 /// Verify - Verify that a derived type descriptor is well formed.
682 /// \brief An imported module (C++ using directive or similar).
683 class DIImportedEntity : public DIDescriptor {
684 friend class DIDescriptor;
685 void printInternal(raw_ostream &OS) const;
687 explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { }
688 DIScope getContext() const { return getFieldAs<DIScope>(1); }
689 DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
690 unsigned getLineNumber() const { return getUnsignedField(3); }
691 StringRef getName() const { return getStringField(4); }
695 /// getDISubprogram - Find subprogram that is enclosing this scope.
696 DISubprogram getDISubprogram(const MDNode *Scope);
698 /// getDICompositeType - Find underlying composite type.
699 DICompositeType getDICompositeType(DIType T);
701 /// isSubprogramContext - Return true if Context is either a subprogram
702 /// or another context nested inside a subprogram.
703 bool isSubprogramContext(const MDNode *Context);
705 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
706 /// to hold function specific information.
707 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
709 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
710 /// suitable to hold function specific information.
711 NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
713 /// createInlinedVariable - Create a new inlined variable based on current
715 /// @param DV Current Variable.
716 /// @param InlinedScope Location at current variable is inlined.
717 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
718 LLVMContext &VMContext);
720 /// cleanseInlinedVariable - Remove inlined scope from the variable.
721 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
723 /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To
724 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
725 /// processDeclare, processValue and processLocation to handle DbgDeclareInst,
726 /// DbgValueInst and DbgLoc attached to instructions. processModule will go
727 /// through all DICompileUnits in llvm.dbg.cu and list debug info MDNodes
729 class DebugInfoFinder {
731 /// processModule - Process entire module and collect debug info
733 void processModule(const Module &M);
735 /// processDeclare - Process DbgDeclareInst.
736 void processDeclare(const DbgDeclareInst *DDI);
737 /// Process DbgValueInst.
738 void processValue(const DbgValueInst *DVI);
739 /// processLocation - Process DILocation.
740 void processLocation(DILocation Loc);
745 /// processType - Process DIType.
746 void processType(DIType DT);
748 /// processLexicalBlock - Process DILexicalBlock.
749 void processLexicalBlock(DILexicalBlock LB);
751 /// processSubprogram - Process DISubprogram.
752 void processSubprogram(DISubprogram SP);
754 void processScope(DIScope Scope);
756 /// addCompileUnit - Add compile unit into CUs.
757 bool addCompileUnit(DICompileUnit CU);
759 /// addGlobalVariable - Add global variable into GVs.
760 bool addGlobalVariable(DIGlobalVariable DIG);
762 // addSubprogram - Add subprogram into SPs.
763 bool addSubprogram(DISubprogram SP);
765 /// addType - Add type into Tys.
766 bool addType(DIType DT);
768 bool addScope(DIScope Scope);
771 typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
772 iterator compile_unit_begin() const { return CUs.begin(); }
773 iterator compile_unit_end() const { return CUs.end(); }
774 iterator subprogram_begin() const { return SPs.begin(); }
775 iterator subprogram_end() const { return SPs.end(); }
776 iterator global_variable_begin() const { return GVs.begin(); }
777 iterator global_variable_end() const { return GVs.end(); }
778 iterator type_begin() const { return TYs.begin(); }
779 iterator type_end() const { return TYs.end(); }
780 iterator scope_begin() const { return Scopes.begin(); }
781 iterator scope_end() const { return Scopes.end(); }
783 unsigned compile_unit_count() const { return CUs.size(); }
784 unsigned global_variable_count() const { return GVs.size(); }
785 unsigned subprogram_count() const { return SPs.size(); }
786 unsigned type_count() const { return TYs.size(); }
787 unsigned scope_count() const { return Scopes.size(); }
790 SmallVector<MDNode *, 8> CUs; // Compile Units
791 SmallVector<MDNode *, 8> SPs; // Subprograms
792 SmallVector<MDNode *, 8> GVs; // Global Variables;
793 SmallVector<MDNode *, 8> TYs; // Types
794 SmallVector<MDNode *, 8> Scopes; // Scopes
795 SmallPtrSet<MDNode *, 64> NodesSeen;
797 } // end namespace llvm