diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 74416db2175..b02446abbbf 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -323,6 +323,7 @@ namespace llvm { DIArray getTypeArray() const { return getFieldAs(10); } void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); + void addMember(DISubprogram S); unsigned getRunTimeLang() const { return getUnsignedField(11); } DICompositeType getContainingType() const { return getFieldAs(12); diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index fc9324949d0..0f7ddb5961c 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -647,6 +647,19 @@ void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { DbgNode = N; } +void DICompositeType::addMember(DISubprogram S) { + SmallVector M; + DIArray OrigM = getTypeArray(); + unsigned Elements = OrigM.getNumElements(); + if (Elements == 1 && !OrigM.getElement(0)) + Elements = 0; + M.reserve(Elements + 1); + for (unsigned i = 0; i != Elements; ++i) + M.push_back(OrigM.getElement(i)); + M.push_back(S); + setTypeArray(DIArray(MDNode::get(DbgNode->getContext(), M))); +} + /// \brief Set the containing type. void DICompositeType::setContainingType(DICompositeType ContainingType) { TrackingVH N(*this);