}
};
-/// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
-/// This should not be stored in a container, because the underlying MDNode
-/// may change in certain situations.
+/// A thin wraper around MDNode to access encoded debug info. This should not
+/// be stored in a container, because the underlying MDNode may change in
+/// certain situations.
class DIDescriptor {
// Befriends DIRef so DIRef can befriend the protected member
// function: getFieldAs<DIRef>.
bool isImportedEntity() const;
bool isExpression() const;
- /// print - print descriptor.
void print(raw_ostream &OS) const;
-
- /// dump - print descriptor to dbgs() with a newline.
void dump() const;
- /// replaceAllUsesWith - Replace all uses of debug info referenced by
- /// this descriptor.
+ /// Replace all uses of debug info referenced by this descriptor.
void replaceAllUsesWith(LLVMContext &VMContext, DIDescriptor D);
void replaceAllUsesWith(MDNode *D);
};
-/// DISubrange - This is used to represent ranges, for array bounds.
+/// This is used to represent ranges, for array bounds.
class DISubrange : public DIDescriptor {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
bool Verify() const;
};
-/// DITypedArray - This descriptor holds an array of nodes with type T.
+/// This descriptor holds an array of nodes with type T.
template <typename T> class DITypedArray : public DIDescriptor {
public:
explicit DITypedArray(const MDNode *N = nullptr) : DIDescriptor(N) {}
typedef DITypedArray<DIDescriptor> DIArray;
-/// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
+/// A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
/// FIXME: it seems strange that this doesn't have either a reference to the
/// type/precision or a file/line pair for location info.
class DIEnumerator : public DIDescriptor {
typedef DIRef<DIType> DITypeRef;
typedef DITypedArray<DITypeRef> DITypeArray;
-/// DIScope - A base class for various scopes.
+/// A base class for various scopes.
///
/// Although, implementation-wise, DIScope is the parent class of most
/// other DIxxx classes, including DIType and its descendants, most of
public:
explicit DIScope(const MDNode *N = nullptr) : DIDescriptor(N) {}
- /// Gets the parent scope for this scope node or returns a
- /// default constructed scope.
+ /// Gets the parent scope for this scope node or returns a default
+ /// constructed scope.
DIScopeRef getContext() const;
/// If the scope node has a name, return that, else return an empty string.
StringRef getName() const;
/// Specialize DIRef constructor for DITypeRef.
template <> DIRef<DIType>::DIRef(const Value *V);
-/// DIType - This is a wrapper for a type.
+/// This is a wrapper for a type.
/// FIXME: Types should be factored much better so that CV qualifiers and
/// others do not require a huge and empty descriptor full of zeros.
class DIType : public DIScope {
return DITypeRef(&*getRef());
}
- /// Verify - Verify that a type descriptor is well formed.
bool Verify() const;
DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); }
return (getFlags() & FlagAccessibility) == FlagPublic;
}
bool isForwardDecl() const { return (getFlags() & FlagFwdDecl) != 0; }
- // isAppleBlock - Return true if this is the Apple Blocks extension.
bool isAppleBlockExtension() const {
return (getFlags() & FlagAppleBlock) != 0;
}
bool isValid() const { return DbgNode && isType(); }
};
-/// DIBasicType - A basic type, like 'int' or 'float'.
+/// A basic type, like 'int' or 'float'.
class DIBasicType : public DIType {
public:
explicit DIBasicType(const MDNode *N = nullptr) : DIType(N) {}
unsigned getEncoding() const { return getHeaderFieldAs<unsigned>(7); }
- /// Verify - Verify that a basic type descriptor is well formed.
bool Verify() const;
};
-/// DIDerivedType - A simple derived type, like a const qualified type,
-/// a typedef, a pointer or reference, et cetera. Or, a data member of
-/// a class/struct/union.
+/// A simple derived type, like a const qualified type, a typedef, a pointer or
+/// reference, et cetera. Or, a data member of a class/struct/union.
class DIDerivedType : public DIType {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
DITypeRef getTypeDerivedFrom() const { return getFieldAs<DITypeRef>(3); }
- /// getObjCProperty - Return property node, if this ivar is
- /// associated with one.
+ /// Return property node, if this ivar is associated with one.
MDNode *getObjCProperty() const;
DITypeRef getClassType() const {
return getConstantField(4);
}
- /// Verify - Verify that a derived type descriptor is well formed.
bool Verify() const;
};
-/// DICompositeType - This descriptor holds a type that can refer to multiple
-/// other types, like a function or struct.
+/// This descriptor holds a type that can refer to multiple other types, like a
+/// function or struct.
+///
/// DICompositeType is derived from DIDerivedType because some
/// composite types (such as enums) can be derived from basic types
// FIXME: Make this derive from DIType directly & just store the
class DICompositeType : public DIDerivedType {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
+
+ /// \brief Set the array of member DITypes.
void setArraysHelper(MDNode *Elements, MDNode *TParams);
public:
return getHeaderFieldAs<unsigned>(7);
}
DITypeRef getContainingType() const { return getFieldAs<DITypeRef>(5); }
+
+ /// \brief Set the containing type.
void setContainingType(DICompositeType ContainingType);
DIArray getTemplateParams() const { return getFieldAs<DIArray>(6); }
MDString *getIdentifier() const;
- /// Verify - Verify that a composite type descriptor is well formed.
bool Verify() const;
};
}
};
-/// DIFile - This is a wrapper for a file.
+/// This is a wrapper for a file.
class DIFile : public DIScope {
friend class DIDescriptor;
public:
explicit DIFile(const MDNode *N = nullptr) : DIScope(N) {}
+
+ /// \brief Retrieve the MDNode for the directory/file pair.
MDNode *getFileNode() const;
bool Verify() const;
};
-/// DICompileUnit - A wrapper for a compile unit.
+/// A wrapper for a compile unit.
class DICompileUnit : public DIScope {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
StringRef getSplitDebugFilename() const { return getHeaderField(6); }
unsigned getEmissionKind() const { return getHeaderFieldAs<unsigned>(7); }
- /// Verify - Verify that a compile unit is well formed.
bool Verify() const;
};
-/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
+/// This is a wrapper for a subprogram (e.g. a function).
class DISubprogram : public DIScope {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
StringRef getLinkageName() const { return getHeaderField(3); }
unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(4); }
- /// isLocalToUnit - Return true if this subprogram is local to the current
- /// compile unit, like 'static' in C.
+ /// Return true if this subprogram is local to the current compile unit, like
+ /// 'static' in C.
unsigned isLocalToUnit() const { return getHeaderFieldAs<unsigned>(5); }
unsigned isDefinition() const { return getHeaderFieldAs<unsigned>(6); }
unsigned isOptimized() const { return getHeaderFieldAs<bool>(10); }
- /// getScopeLineNumber - Get the beginning of the scope of the
- /// function, not necessarily where the name of the program
- /// starts.
+ /// Get the beginning of the scope of the function, not necessarily where the
+ /// name of the program starts.
unsigned getScopeLineNumber() const { return getHeaderFieldAs<unsigned>(11); }
DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); }
DITypeRef getContainingType() const { return getFieldAs<DITypeRef>(4); }
- /// Verify - Verify that a subprogram descriptor is well formed.
bool Verify() const;
- /// describes - Return true if this subprogram provides debugging
- /// information for the function F.
+ /// Return true if this subprogram provides debugging information for the
+ /// function F.
bool describes(const Function *F);
Function *getFunction() const { return getFunctionField(5); }
DIArray getVariables() const;
unsigned isArtificial() const { return (getFlags() & FlagArtificial) != 0; }
- /// isPrivate - Return true if this subprogram has "private"
- /// access specifier.
+ /// Return true if this subprogram has "private" access specifier.
bool isPrivate() const {
return (getFlags() & FlagAccessibility) == FlagPrivate;
}
- /// isProtected - Return true if this subprogram has "protected"
- /// access specifier.
+ /// Return true if this subprogram has "protected" access specifier.
bool isProtected() const {
return (getFlags() & FlagAccessibility) == FlagProtected;
}
- /// isPublic - Return true if this subprogram has "public"
- /// access specifier.
+ /// Return true if this subprogram has "public" access specifier.
bool isPublic() const {
return (getFlags() & FlagAccessibility) == FlagPublic;
}
- /// isExplicit - Return true if this subprogram is marked as explicit.
+ /// Return true if this subprogram is marked as explicit.
bool isExplicit() const { return (getFlags() & FlagExplicit) != 0; }
- /// isPrototyped - Return true if this subprogram is prototyped.
+ /// Return true if this subprogram is prototyped.
bool isPrototyped() const { return (getFlags() & FlagPrototyped) != 0; }
- /// Return true if this subprogram is a C++11 reference-qualified
- /// non-static member function (void foo() &).
+ /// Return true if this subprogram is a C++11 reference-qualified non-static
+ /// member function (void foo() &).
unsigned isLValueReference() const {
return (getFlags() & FlagLValueReference) != 0;
}
- /// Return true if this subprogram is a C++11
- /// rvalue-reference-qualified non-static member function
- /// (void foo() &&).
+ /// Return true if this subprogram is a C++11 rvalue-reference-qualified
+ /// non-static member function (void foo() &&).
unsigned isRValueReference() const {
return (getFlags() & FlagRValueReference) != 0;
}
};
-/// DILexicalBlock - This is a wrapper for a lexical block.
+/// This is a wrapper for a lexical block.
class DILexicalBlock : public DIScope {
public:
explicit DILexicalBlock(const MDNode *N = nullptr) : DIScope(N) {}
bool Verify() const;
};
-/// DILexicalBlockFile - This is a wrapper for a lexical block with
-/// a filename change.
+/// This is a wrapper for a lexical block with a filename change.
class DILexicalBlockFile : public DIScope {
public:
explicit DILexicalBlockFile(const MDNode *N = nullptr) : DIScope(N) {}
bool Verify() const;
};
-/// DINameSpace - A wrapper for a C++ style name space.
+/// A wrapper for a C++ style name space.
class DINameSpace : public DIScope {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
bool Verify() const;
};
-/// DITemplateTypeParameter - This is a wrapper for template type parameter.
+/// This is a wrapper for template type parameter.
class DITemplateTypeParameter : public DIDescriptor {
public:
explicit DITemplateTypeParameter(const MDNode *N = nullptr)
bool Verify() const;
};
-/// DITemplateValueParameter - This is a wrapper for template value parameter.
+/// This is a wrapper for template value parameter.
class DITemplateValueParameter : public DIDescriptor {
public:
explicit DITemplateValueParameter(const MDNode *N = nullptr)
bool Verify() const;
};
-/// DIGlobalVariable - This is a wrapper for a global variable.
+/// This is a wrapper for a global variable.
class DIGlobalVariable : public DIDescriptor {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
return getFieldAs<DIDerivedType>(5);
}
- /// Verify - Verify that a global variable descriptor is well formed.
bool Verify() const;
};
-/// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
-/// global etc).
+/// This is a wrapper for a variable (e.g. parameter, local, global etc).
class DIVariable : public DIDescriptor {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
DIFile getFile() const { return getFieldAs<DIFile>(2); }
DITypeRef getType() const { return getFieldAs<DITypeRef>(3); }
- /// isArtificial - Return true if this variable is marked as "artificial".
+ /// Return true if this variable is marked as "artificial".
bool isArtificial() const {
return (getHeaderFieldAs<unsigned>(3) & FlagArtificial) != 0;
}
return (getHeaderFieldAs<unsigned>(3) & FlagIndirectVariable) != 0;
}
- /// getInlinedAt - If this variable is inlined then return inline location.
+ /// If this variable is inlined then return inline location.
MDNode *getInlinedAt() const;
- /// Verify - Verify that a variable descriptor is well formed.
bool Verify() const;
- /// isBlockByrefVariable - Return true if the variable was declared as
- /// a "__block" variable (Apple Blocks).
+ /// Return true if the variable was declared as a "__block" variable (Apple
+ /// Blocks).
bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
return (getType().resolve(Map)).isBlockByrefStruct();
}
- /// isInlinedFnArgument - Return true if this variable provides debugging
- /// information for an inlined function arguments.
+ /// Return true if this variable provides debugging information for an
+ /// inlined function arguments.
bool isInlinedFnArgument(const Function *CurFn);
/// Return the size reported by the variable's type.
void printExtendedName(raw_ostream &OS) const;
};
-/// DIExpression - A complex location expression.
+/// A complex location expression.
class DIExpression : public DIDescriptor {
friend class DIDescriptor;
void printInternal(raw_ostream &OS) const;
public:
explicit DIExpression(const MDNode *N = nullptr) : DIDescriptor(N) {}
- /// Verify - Verify that a variable descriptor is well formed.
bool Verify() const;
/// \brief Return the number of elements in the complex expression.
/// \brief return the Idx'th complex address element.
uint64_t getElement(unsigned Idx) const;
- /// isVariablePiece - Return whether this is a piece of an aggregate
- /// variable.
+ /// Return whether this is a piece of an aggregate variable.
bool isVariablePiece() const;
- /// getPieceOffset - Return the offset of this piece in bytes.
+ /// Return the offset of this piece in bytes.
uint64_t getPieceOffset() const;
- /// getPieceSize - Return the size of this piece in bytes.
+ /// Return the size of this piece in bytes.
uint64_t getPieceSize() const;
};
-/// DILocation - This object holds location information. This object
-/// is not associated with any DWARF tag.
+/// This object holds location information. This object is not associated with
+/// any DWARF tag.
class DILocation : public DIDescriptor {
public:
explicit DILocation(const MDNode *N) : DIDescriptor(N) {}
return (getLineNumber() == Other.getLineNumber() &&
getFilename() == Other.getFilename());
}
- /// getDiscriminator - DWARF discriminators are used to distinguish
- /// identical file locations for instructions that are on different
- /// basic blocks. If two instructions are inside the same lexical block
- /// and are in different basic blocks, we create a new lexical block
- /// with identical location as the original but with a different
- /// discriminator value (lib/Transforms/Util/AddDiscriminators.cpp
- /// for details).
+ /// DWARF discriminators are used to distinguish identical file locations for
+ /// instructions that are on different basic blocks. If two instructions are
+ /// inside the same lexical block and are in different basic blocks, we
+ /// create a new lexical block with identical location as the original but
+ /// with a different discriminator value
+ /// (lib/Transforms/Util/AddDiscriminators.cpp for details).
unsigned getDiscriminator() const {
// Since discriminators are associated with lexical blocks, make
// sure this location is a lexical block before retrieving its
? getFieldAs<DILexicalBlockFile>(2).getDiscriminator()
: 0;
}
+
+ /// Generate a new discriminator value for this file and line location.
unsigned computeNewDiscriminator(LLVMContext &Ctx);
+
+ /// Return a copy of this location, replacing the current scope with the
+ /// given one.
DILocation copyWithNewScope(LLVMContext &Ctx, DILexicalBlockFile NewScope);
};
/// the type as a DITypeRef here.
DIType getType() const { return getFieldAs<DIType>(2); }
- /// Verify - Verify that a derived type descriptor is well formed.
bool Verify() const;
};
bool Verify() const;
};
-/// getDISubprogram - Find subprogram that is enclosing this scope.
+/// Find subprogram that is enclosing this scope.
DISubprogram getDISubprogram(const MDNode *Scope);
-/// getDICompositeType - Find underlying composite type.
+/// Find underlying composite type.
DICompositeType getDICompositeType(DIType T);
-/// createInlinedVariable - Create a new inlined variable based on current
-/// variable.
+/// Create a new inlined variable based on current variable.
/// @param DV Current Variable.
/// @param InlinedScope Location at current variable is inlined.
DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
LLVMContext &VMContext);
-/// cleanseInlinedVariable - Remove inlined scope from the variable.
+/// Remove inlined scope from the variable.
DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
/// Construct DITypeIdentifierMap by going through retained types of each CU.
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
/// Strip debug info in the module if it exists.
+///
/// To do this, we remove all calls to the debugger intrinsics and any named
/// metadata for debugging. We also remove debug locations for instructions.
/// Return true if module is modified.
public:
DebugInfoFinder() : TypeMapInitialized(false) {}
- /// processModule - Process entire module and collect debug info
- /// anchors.
+ /// Process entire module and collect debug info anchors.
void processModule(const Module &M);
- /// processDeclare - Process DbgDeclareInst.
+ /// Process DbgDeclareInst.
void processDeclare(const Module &M, const DbgDeclareInst *DDI);
/// Process DbgValueInst.
void processValue(const Module &M, const DbgValueInst *DVI);
- /// processLocation - Process DILocation.
+ /// Process DILocation.
void processLocation(const Module &M, DILocation Loc);
/// Clear all lists.
void reset();
private:
- /// Initialize TypeIdentifierMap.
void InitializeTypeMap(const Module &M);
- /// processType - Process DIType.
void processType(DIType DT);
-
- /// processSubprogram - Process DISubprogram.
void processSubprogram(DISubprogram SP);
-
void processScope(DIScope Scope);
-
- /// addCompileUnit - Add compile unit into CUs.
bool addCompileUnit(DICompileUnit CU);
-
- /// addGlobalVariable - Add global variable into GVs.
bool addGlobalVariable(DIGlobalVariable DIG);
-
- // addSubprogram - Add subprogram into SPs.
bool addSubprogram(DISubprogram SP);
-
- /// addType - Add type into Tys.
bool addType(DIType DT);
-
bool addScope(DIScope Scope);
public:
unsigned scope_count() const { return Scopes.size(); }
private:
- SmallVector<DICompileUnit, 8> CUs; // Compile Units
- SmallVector<DISubprogram, 8> SPs; // Subprograms
- SmallVector<DIGlobalVariable, 8> GVs; // Global Variables;
- SmallVector<DIType, 8> TYs; // Types
- SmallVector<DIScope, 8> Scopes; // Scopes
+ SmallVector<DICompileUnit, 8> CUs;
+ SmallVector<DISubprogram, 8> SPs;
+ SmallVector<DIGlobalVariable, 8> GVs;
+ SmallVector<DIType, 8> TYs;
+ SmallVector<DIScope, 8> Scopes;
SmallPtrSet<MDNode *, 64> NodesSeen;
DITypeIdentifierMap TypeIdentifierMap;
/// Specify if TypeIdentifierMap is initialized.
return isCompositeType() && getTag() == dwarf::DW_TAG_subroutine_type;
}
-/// isBasicType - Return true if the specified tag is legal for
-/// DIBasicType.
bool DIDescriptor::isBasicType() const {
if (!DbgNode)
return false;
}
}
-/// isDerivedType - Return true if the specified tag is legal for DIDerivedType.
bool DIDescriptor::isDerivedType() const {
if (!DbgNode)
return false;
}
}
-/// isCompositeType - Return true if the specified tag is legal for
-/// DICompositeType.
bool DIDescriptor::isCompositeType() const {
if (!DbgNode)
return false;
}
}
-/// isVariable - Return true if the specified tag is legal for DIVariable.
bool DIDescriptor::isVariable() const {
if (!DbgNode)
return false;
}
}
-/// isType - Return true if the specified tag is legal for DIType.
bool DIDescriptor::isType() const {
return isBasicType() || isCompositeType() || isDerivedType();
}
-/// isSubprogram - Return true if the specified tag is legal for
-/// DISubprogram.
bool DIDescriptor::isSubprogram() const {
return DbgNode && getTag() == dwarf::DW_TAG_subprogram;
}
-/// isGlobalVariable - Return true if the specified tag is legal for
-/// DIGlobalVariable.
bool DIDescriptor::isGlobalVariable() const {
return DbgNode && (getTag() == dwarf::DW_TAG_variable ||
getTag() == dwarf::DW_TAG_constant);
}
-/// isScope - Return true if the specified tag is one of the scope
-/// related tag.
bool DIDescriptor::isScope() const {
if (!DbgNode)
return false;
return isType();
}
-/// isTemplateTypeParameter - Return true if the specified tag is
-/// DW_TAG_template_type_parameter.
bool DIDescriptor::isTemplateTypeParameter() const {
return DbgNode && getTag() == dwarf::DW_TAG_template_type_parameter;
}
-/// isTemplateValueParameter - Return true if the specified tag is
-/// DW_TAG_template_value_parameter.
bool DIDescriptor::isTemplateValueParameter() const {
return DbgNode && (getTag() == dwarf::DW_TAG_template_value_parameter ||
getTag() == dwarf::DW_TAG_GNU_template_template_param ||
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack);
}
-/// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
bool DIDescriptor::isCompileUnit() const {
return DbgNode && getTag() == dwarf::DW_TAG_compile_unit;
}
-/// isFile - Return true if the specified tag is DW_TAG_file_type.
bool DIDescriptor::isFile() const {
return DbgNode && getTag() == dwarf::DW_TAG_file_type;
}
-/// isNameSpace - Return true if the specified tag is DW_TAG_namespace.
bool DIDescriptor::isNameSpace() const {
return DbgNode && getTag() == dwarf::DW_TAG_namespace;
}
-/// isLexicalBlockFile - Return true if the specified descriptor is a
-/// lexical block with an extra file.
bool DIDescriptor::isLexicalBlockFile() const {
return DbgNode && getTag() == dwarf::DW_TAG_lexical_block &&
DbgNode->getNumOperands() == 3 && getNumHeaderFields() == 2;
}
-/// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block.
bool DIDescriptor::isLexicalBlock() const {
// FIXME: There are always exactly 4 header fields in DILexicalBlock, but
// something relies on this returning true for DILexicalBlockFile.
(getNumHeaderFields() == 2 || getNumHeaderFields() == 4);
}
-/// isSubrange - Return true if the specified tag is DW_TAG_subrange_type.
bool DIDescriptor::isSubrange() const {
return DbgNode && getTag() == dwarf::DW_TAG_subrange_type;
}
-/// isEnumerator - Return true if the specified tag is DW_TAG_enumerator.
bool DIDescriptor::isEnumerator() const {
return DbgNode && getTag() == dwarf::DW_TAG_enumerator;
}
-/// isObjCProperty - Return true if the specified tag is DW_TAG_APPLE_property.
bool DIDescriptor::isObjCProperty() const {
return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property;
}
-/// \brief Return true if the specified tag is DW_TAG_imported_module or
-/// DW_TAG_imported_declaration.
bool DIDescriptor::isImportedEntity() const {
return DbgNode && (getTag() == dwarf::DW_TAG_imported_module ||
getTag() == dwarf::DW_TAG_imported_declaration);
}
-/// \brief Return true if the specified tag is DW_TAG_imported_module or
-/// DW_TAG_imported_declaration.
bool DIDescriptor::isExpression() const {
return DbgNode && (getTag() == dwarf::DW_TAG_expression);
}
// Simple Descriptor Constructors and other Methods
//===----------------------------------------------------------------------===//
-/// replaceAllUsesWith - Replace all uses of the MDNode used by this
-/// type with the one in the passed descriptor.
void DIDescriptor::replaceAllUsesWith(LLVMContext &VMContext, DIDescriptor D) {
assert(DbgNode && "Trying to replace an unverified type!");
DbgNode = DN;
}
-/// replaceAllUsesWith - Replace all uses of the MDNode used by this
-/// type with the one in D.
void DIDescriptor::replaceAllUsesWith(MDNode *D) {
assert(DbgNode && "Trying to replace an unverified type!");
MDNode::deleteTemporary(Node);
}
-/// Verify - Verify that a compile unit is well formed.
bool DICompileUnit::Verify() const {
if (!isCompileUnit())
return false;
return DbgNode->getNumOperands() == 7 && getNumHeaderFields() == 8;
}
-/// Verify - Verify that an ObjC property is well formed.
bool DIObjCProperty::Verify() const {
if (!isObjCProperty())
return false;
return isScopeRef(Fld);
}
-/// Verify - Verify that a type descriptor is well formed.
bool DIType::Verify() const {
if (!isType())
return false;
getNumHeaderFields() == 8;
}
-/// Verify - Verify that a derived type descriptor is well formed.
bool DIDerivedType::Verify() const {
// Make sure DerivedFrom @ field 3 is TypeRef.
if (!fieldIsTypeRef(DbgNode, 3))
getNumHeaderFields() <= 8;
}
-/// Verify - Verify that a composite type descriptor is well formed.
bool DICompositeType::Verify() const {
if (!isCompositeType())
return false;
return DbgNode->getNumOperands() == 8 && getNumHeaderFields() == 8;
}
-/// Verify - Verify that a subprogram descriptor is well formed.
bool DISubprogram::Verify() const {
if (!isSubprogram())
return false;
return DbgNode->getNumOperands() == 9 && getNumHeaderFields() == 12;
}
-/// Verify - Verify that a global variable descriptor is well formed.
bool DIGlobalVariable::Verify() const {
if (!isGlobalVariable())
return false;
return DbgNode->getNumOperands() == 6 && getNumHeaderFields() == 7;
}
-/// Verify - Verify that a variable descriptor is well formed.
bool DIVariable::Verify() const {
if (!isVariable())
return false;
return getInlinedAt() != nullptr && DbgNode->getNumOperands() == 5;
}
-/// Verify - Verify that a variable descriptor is well formed.
bool DIExpression::Verify() const {
// Empty DIExpressions may be represented as a nullptr.
if (!DbgNode)
return isExpression() && DbgNode->getNumOperands() == 1;
}
-/// Verify - Verify that a location descriptor is well formed.
bool DILocation::Verify() const {
if (!DbgNode)
return false;
return DbgNode->getNumOperands() == 4;
}
-/// Verify - Verify that a namespace descriptor is well formed.
bool DINameSpace::Verify() const {
if (!isNameSpace())
return false;
return DbgNode->getNumOperands() == 3 && getNumHeaderFields() == 3;
}
-/// \brief Retrieve the MDNode for the directory/file pair.
MDNode *DIFile::getFileNode() const { return getNodeField(DbgNode, 1); }
-/// \brief Verify that the file descriptor is well formed.
bool DIFile::Verify() const {
return isFile() && DbgNode->getNumOperands() == 2;
}
-/// \brief Verify that the enumerator descriptor is well formed.
bool DIEnumerator::Verify() const {
return isEnumerator() && DbgNode->getNumOperands() == 1 &&
getNumHeaderFields() == 3;
}
-/// \brief Verify that the subrange descriptor is well formed.
bool DISubrange::Verify() const {
return isSubrange() && DbgNode->getNumOperands() == 1 &&
getNumHeaderFields() == 3;
}
-/// \brief Verify that the lexical block descriptor is well formed.
bool DILexicalBlock::Verify() const {
return isLexicalBlock() && DbgNode->getNumOperands() == 3 &&
getNumHeaderFields() == 4;
}
-/// \brief Verify that the file-scoped lexical block descriptor is well formed.
bool DILexicalBlockFile::Verify() const {
return isLexicalBlockFile() && DbgNode->getNumOperands() == 3 &&
getNumHeaderFields() == 2;
}
-/// \brief Verify that the template type parameter descriptor is well formed.
bool DITemplateTypeParameter::Verify() const {
return isTemplateTypeParameter() && DbgNode->getNumOperands() == 4 &&
getNumHeaderFields() == 4;
}
-/// \brief Verify that the template value parameter descriptor is well formed.
bool DITemplateValueParameter::Verify() const {
return isTemplateValueParameter() && DbgNode->getNumOperands() == 5 &&
getNumHeaderFields() == 4;
}
-/// \brief Verify that the imported module descriptor is well formed.
bool DIImportedEntity::Verify() const {
return isImportedEntity() && DbgNode->getNumOperands() == 3 &&
getNumHeaderFields() == 3;
}
-/// getObjCProperty - Return property node, if this ivar is associated with one.
MDNode *DIDerivedType::getObjCProperty() const {
return getNodeField(DbgNode, 4);
}
}
#endif
-/// \brief Set the array of member DITypes.
void DICompositeType::setArraysHelper(MDNode *Elements, MDNode *TParams) {
TrackingVH<MDNode> N(*this);
if (Elements) {
DbgNode = N;
}
-/// Generate a reference to this DIType. Uses the type identifier instead
-/// of the actual MDNode if possible, to help type uniquing.
DIScopeRef DIScope::getRef() const {
if (!isCompositeType())
return DIScopeRef(*this);
return DIScopeRef(DTy.getIdentifier());
}
-/// \brief Set the containing type.
void DICompositeType::setContainingType(DICompositeType ContainingType) {
TrackingVH<MDNode> N(*this);
N->replaceOperandWith(5, ContainingType.getRef());
DbgNode = N;
}
-/// isInlinedFnArgument - Return true if this variable provides debugging
-/// information for an inlined function arguments.
bool DIVariable::isInlinedFnArgument(const Function *CurFn) {
assert(CurFn && "Invalid function");
if (!getContext().isSubprogram())
return !DISubprogram(getContext()).describes(CurFn);
}
-/// describes - Return true if this subprogram provides debugging
-/// information for the function F.
bool DISubprogram::describes(const Function *F) {
assert(F && "Invalid function");
if (F == getFunction())
return getField(DbgNode, 3);
}
-// If the current node has a parent scope then return that,
-// else return an empty scope.
DIScopeRef DIScope::getContext() const {
if (isType())
return DIScopeRef(nullptr);
}
-// If the scope node has a name, return that, else return an empty string.
StringRef DIScope::getName() const {
if (isType())
return DIType(DbgNode).getName();
const_cast<MDNode *>(DbgNode)->replaceOperandWith(5, GlobalVariables);
}
-/// copyWithNewScope - Return a copy of this location, replacing the
-/// current scope with the given one.
DILocation DILocation::copyWithNewScope(LLVMContext &Ctx,
DILexicalBlockFile NewScope) {
SmallVector<Value *, 10> Elts;
return DILocation(NewDIL);
}
-/// computeNewDiscriminator - Generate a new discriminator value for this
-/// file and line location.
unsigned DILocation::computeNewDiscriminator(LLVMContext &Ctx) {
std::pair<const char *, unsigned> Key(getFilename().data(), getLineNumber());
return ++Ctx.pImpl->DiscriminatorTable[Key];
}
-/// createInlinedVariable - Create a new inlined variable based on current
-/// variable.
-/// @param DV Current Variable.
-/// @param InlinedScope Location at current variable is inlined.
DIVariable llvm::createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
LLVMContext &VMContext) {
assert(DIVariable(DV).Verify() && "Expected a DIVariable");
return Inlined;
}
-/// cleanseInlinedVariable - Remove inlined scope from the variable.
DIVariable llvm::cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext) {
assert(DIVariable(DV).Verify() && "Expected a DIVariable");
if (!DIVariable(DV).getInlinedAt())
return Cleansed;
}
-/// getDISubprogram - Find subprogram that is enclosing this scope.
DISubprogram llvm::getDISubprogram(const MDNode *Scope) {
DIDescriptor D(Scope);
if (D.isSubprogram())
return DISubprogram();
}
-/// getDICompositeType - Find underlying composite type.
DICompositeType llvm::getDICompositeType(DIType T) {
if (T.isCompositeType())
return DICompositeType(T);
return DICompositeType();
}
-/// Update DITypeIdentifierMap by going through retained types of each CU.
DITypeIdentifierMap
llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
DITypeIdentifierMap Map;
}
}
-/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(const Module &M) {
InitializeTypeMap(M);
if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
}
}
-/// processLocation - Process DILocation.
void DebugInfoFinder::processLocation(const Module &M, DILocation Loc) {
if (!Loc)
return;
processLocation(M, Loc.getOrigLocation());
}
-/// processType - Process DIType.
void DebugInfoFinder::processType(DIType DT) {
if (!addType(DT))
return;
}
}
-/// processSubprogram - Process DISubprogram.
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
if (!addSubprogram(SP))
return;
}
}
-/// processDeclare - Process DbgDeclareInst.
void DebugInfoFinder::processDeclare(const Module &M,
const DbgDeclareInst *DDI) {
MDNode *N = dyn_cast<MDNode>(DDI->getVariable());
processType(DIVariable(N).getType().resolve(TypeIdentifierMap));
}
-/// addType - Add type into Tys.
bool DebugInfoFinder::addType(DIType DT) {
if (!DT)
return false;
return true;
}
-/// addCompileUnit - Add compile unit into CUs.
bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) {
if (!CU)
return false;
return true;
}
-/// addGlobalVariable - Add global variable into GVs.
bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) {
if (!DIG)
return false;
return true;
}
-// addSubprogram - Add subprgoram into SPs.
bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
if (!SP)
return false;
// DIDescriptor: dump routines for all descriptors.
//===----------------------------------------------------------------------===//
-/// dump - Print descriptor to dbgs() with a newline.
void DIDescriptor::dump() const {
print(dbgs());
dbgs() << '\n';
}
-/// print - Print descriptor.
void DIDescriptor::print(raw_ostream &OS) const {
if (!DbgNode)
return;
}
}
-/// Specialize constructor to make sure it has the correct type.
template <> DIRef<DIScope>::DIRef(const Value *V) : Val(V) {
assert(isScopeRef(V) && "DIScopeRef should be a MDString or MDNode");
}
assert(isTypeRef(V) && "DITypeRef should be a MDString or MDNode");
}
-/// Specialize getFieldAs to handle fields that are references to DIScopes.
template <>
DIScopeRef DIDescriptor::getFieldAs<DIScopeRef>(unsigned Elt) const {
return DIScopeRef(getField(DbgNode, Elt));
}
-/// Specialize getFieldAs to handle fields that are references to DITypes.
template <> DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const {
return DITypeRef(getField(DbgNode, Elt));
}
-/// Strip debug info in the module if it exists.
-/// To do this, we remove all calls to the debugger intrinsics and any named
-/// metadata for debugging. We also remove debug locations for instructions.
-/// Return true if module is modified.
bool llvm::StripDebugInfo(Module &M) {
-
bool Changed = false;
// Remove all of the calls to the debugger intrinsics, and remove them from
return Changed;
}
-/// Return Debug Info Metadata Version by checking module flags.
unsigned llvm::getDebugMetadataVersionFromModule(const Module &M) {
Value *Val = M.getModuleFlag("Debug Info Version");
if (!Val)