summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-08-26 22:39:55 +0000
committerManman Ren <manman.ren@gmail.com>2013-08-26 22:39:55 +0000
commit0ed70aeb85cb0bf00721015afdebb4b825dc6fa1 (patch)
tree58fe46e21c20d39039981811be3002b613eba9ea /llvm/lib/IR/DebugInfo.cpp
parentbdc9ff449800079c194d30e919ca74ce15f64284 (diff)
downloadbcm5719-llvm-0ed70aeb85cb0bf00721015afdebb4b825dc6fa1.tar.gz
bcm5719-llvm-0ed70aeb85cb0bf00721015afdebb4b825dc6fa1.zip
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. llvm-svn: 189282
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index fdd8d537ce4..8fad393e5ae 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud