diff options
author | Manman Ren <manman.ren@gmail.com> | 2013-08-26 22:39:55 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2013-08-26 22:39:55 +0000 |
commit | 6e3cd0ebe22a7cc959ed301de7f2f09d7a9307c8 (patch) | |
tree | 8aaac55e738c68b9d74e97ab921cb0a46b41ba87 /lib/IR/DebugInfo.cpp | |
parent | 4bf6326d0871961a7402c797a0399a2bdaf53574 (diff) | |
download | llvm-6e3cd0ebe22a7cc959ed301de7f2f09d7a9307c8.tar.gz llvm-6e3cd0ebe22a7cc959ed301de7f2f09d7a9307c8.tar.bz2 llvm-6e3cd0ebe22a7cc959ed301de7f2f09d7a9307c8.tar.xz |
Debug Info: add an identifier field to DICompositeType.
DICompositeType will have an identifier field at position 14. For now, the
field is set to null in DIBuilder.
For DICompositeTypes where the template argument field (the 13th field)
was optional, modify DIBuilder to make sure the template argument field is set.
Now DICompositeType has 15 fields.
Update DIBuilder to use NULL instead of "i32 0" for null value of a MDNode.
Update verifier to check that DICompositeType has 15 fields and the last
field is null or a MDString.
Update testing cases to include an extra field for DICompositeType.
The identifier field will be used by type uniquing so a front end can
genearte a DICompositeType with a unique identifer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189282 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r-- | lib/IR/DebugInfo.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index fdd8d537ce..8fad393e5a 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -419,6 +419,12 @@ static bool fieldIsMDNode(const MDNode *DbgNode, unsigned Elt) { return true; } +/// Check if a field at position Elt of a MDNode is a MDString. +static bool fieldIsMDString(const MDNode *DbgNode, unsigned Elt) { + Value *Fld = getField(DbgNode, Elt); + return !Fld || isa<MDString>(Fld); +} + /// Verify - Verify that a type descriptor is well formed. bool DIType::Verify() const { if (!isType()) @@ -483,13 +489,17 @@ bool DICompositeType::Verify() const { if (!fieldIsMDNode(DbgNode, 12)) return false; + // Make sure the type identifier at field 14 is MDString, it can be null. + if (!fieldIsMDString(DbgNode, 14)) + return false; + // If this is an array type verify that we have a DIType in the derived type // field as that's the type of our element. if (getTag() == dwarf::DW_TAG_array_type) if (!DIType(getTypeDerivedFrom())) return false; - return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14; + return DbgNode->getNumOperands() == 15; } /// Verify - Verify that a subprogram descriptor is well formed. @@ -635,9 +645,13 @@ MDNode *DIDerivedType::getObjCProperty() const { return getNodeField(DbgNode, 10); } +MDString *DICompositeType::getIdentifier() const { + return cast_or_null<MDString>(getField(DbgNode, 14)); +} + /// \brief Set the array of member DITypes. void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { - assert((!TParams || DbgNode->getNumOperands() == 14) && + assert((!TParams || DbgNode->getNumOperands() == 15) && "If you're setting the template parameters this should include a slot " "for that!"); TrackingVH<MDNode> N(*this); |