diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 29 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 18 |
2 files changed, 37 insertions, 10 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 665e16ea8a7..7027813b814 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -617,7 +617,8 @@ DICompositeType DIBuilder::createClassType(DIDescriptor Context, StringRef Name, Elements, ConstantInt::get(Type::getInt32Ty(VMContext), 0), VTableHolder, - TemplateParams + TemplateParams, + NULL // Type Identifer }; DICompositeType R(MDNode::get(VMContext, Elts)); assert(R.isCompositeType() && @@ -651,6 +652,7 @@ DICompositeType DIBuilder::createStructType(DIDescriptor Context, ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang), VTableHolder, NULL, + NULL // Type Identifer }; DICompositeType R(MDNode::get(VMContext, Elts)); assert(R.isCompositeType() && @@ -679,8 +681,9 @@ DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name, NULL, Elements, ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang), - Constant::getNullValue(Type::getInt32Ty(VMContext)), - NULL + NULL, + NULL, + NULL // Type Identifer }; return DICompositeType(MDNode::get(VMContext, Elts)); } @@ -702,7 +705,9 @@ DIBuilder::createSubroutineType(DIFile File, DIArray ParameterTypes) { NULL, ParameterTypes, ConstantInt::get(Type::getInt32Ty(VMContext), 0), - Constant::getNullValue(Type::getInt32Ty(VMContext)) + NULL, + NULL, + NULL // Type Identifer }; return DICompositeType(MDNode::get(VMContext, Elts)); } @@ -727,7 +732,9 @@ DICompositeType DIBuilder::createEnumerationType( UnderlyingType, Elements, ConstantInt::get(Type::getInt32Ty(VMContext), 0), - Constant::getNullValue(Type::getInt32Ty(VMContext)) + NULL, + NULL, + NULL // Type Identifer }; MDNode *Node = MDNode::get(VMContext, Elts); AllEnumTypes.push_back(Node); @@ -751,7 +758,9 @@ DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits, Ty, Subscripts, ConstantInt::get(Type::getInt32Ty(VMContext), 0), - Constant::getNullValue(Type::getInt32Ty(VMContext)) + NULL, + NULL, + NULL // Type Identifer }; return DICompositeType(MDNode::get(VMContext, Elts)); } @@ -773,7 +782,9 @@ DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits, Ty, Subscripts, ConstantInt::get(Type::getInt32Ty(VMContext), 0), - Constant::getNullValue(Type::getInt32Ty(VMContext)) + NULL, + NULL, + NULL // Type Identifer }; return DICompositeType(MDNode::get(VMContext, Elts)); } @@ -864,7 +875,9 @@ DICompositeType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, NULL, DIArray(), ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), - NULL + NULL, + NULL, //TemplateParams + NULL // Type Identifer }; MDNode *Node = MDNode::getTemporary(VMContext, Elts); DICompositeType RetTy(Node); 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); |