aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r--lib/IR/DebugInfo.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index 2a06e25..d171fc6 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -406,6 +406,16 @@ bool DIObjCProperty::Verify() const {
return DbgNode->getNumOperands() == 8;
}
+/// We allow an empty string to represent null. But we don't allow
+/// a non-empty string in a MDNode field.
+static bool fieldIsMDNode(const MDNode *DbgNode, unsigned Elt) {
+ Value *Fld = getField(DbgNode, Elt);
+ if (Fld && isa<MDString>(Fld) &&
+ !cast<MDString>(Fld)->getString().empty())
+ return false;
+ return true;
+}
+
/// Verify - Verify that a type descriptor is well formed.
bool DIType::Verify() const {
if (!isType())
@@ -443,6 +453,14 @@ bool DIBasicType::Verify() const {
/// Verify - Verify that a derived type descriptor is well formed.
bool DIDerivedType::Verify() const {
+ // Make sure DerivedFrom @ field 9 is MDNode.
+ if (!fieldIsMDNode(DbgNode, 9))
+ return false;
+ if (getTag() == dwarf::DW_TAG_ptr_to_member_type)
+ // Make sure ClassType @ field 10 is MDNode.
+ if (!fieldIsMDNode(DbgNode, 10))
+ return false;
+
return isDerivedType() && DbgNode->getNumOperands() >= 10 &&
DbgNode->getNumOperands() <= 14;
}
@@ -452,6 +470,12 @@ bool DICompositeType::Verify() const {
if (!isCompositeType())
return false;
+ // Make sure DerivedFrom @ field 9 and ContainingType @ field 12 are MDNodes.
+ if (!fieldIsMDNode(DbgNode, 9))
+ return false;
+ if (!fieldIsMDNode(DbgNode, 12))
+ return false;
+
return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14;
}
@@ -460,6 +484,14 @@ bool DISubprogram::Verify() const {
if (!isSubprogram())
return false;
+ // Make sure context @ field 2 and type @ field 7 are MDNodes.
+ if (!fieldIsMDNode(DbgNode, 2))
+ return false;
+ if (!fieldIsMDNode(DbgNode, 7))
+ return false;
+ // Containing type @ field 12.
+ if (!fieldIsMDNode(DbgNode, 12))
+ return false;
return DbgNode->getNumOperands() == 20;
}
@@ -470,6 +502,14 @@ bool DIGlobalVariable::Verify() const {
if (getDisplayName().empty())
return false;
+ // Make sure context @ field 2 and type @ field 8 are MDNodes.
+ if (!fieldIsMDNode(DbgNode, 2))
+ return false;
+ if (!fieldIsMDNode(DbgNode, 8))
+ return false;
+ // Make sure StaticDataMemberDeclaration @ field 12 is MDNode.
+ if (!fieldIsMDNode(DbgNode, 12))
+ return false;
return DbgNode->getNumOperands() == 13;
}
@@ -479,6 +519,11 @@ bool DIVariable::Verify() const {
if (!isVariable())
return false;
+ // Make sure context @ field 1 and type @ field 5 are MDNodes.
+ if (!fieldIsMDNode(DbgNode, 1))
+ return false;
+ if (!fieldIsMDNode(DbgNode, 5))
+ return false;
return DbgNode->getNumOperands() >= 8;
}