DebugInfo: more support for mutating DICompositeType to reduce magic number usage...
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 26 Mar 2013 23:46:36 +0000 (23:46 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 26 Mar 2013 23:46:36 +0000 (23:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178090 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo.h
lib/IR/DebugInfo.cpp

index e30713e2520846e140a37c2e02fcba44bc5414ff..15f91870a57471214bec8d2d353e68b15e92a626 100644 (file)
@@ -359,6 +359,7 @@ namespace llvm {
     DICompositeType getContainingType() const {
       return getFieldAs<DICompositeType>(12);
     }
+    void setContainingType(DICompositeType ContainingType);
     DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
 
     /// Verify - Verify that a composite type descriptor is well formed.
index 1916f5ea9667e2bc1f9150cef9964d85d9736f9a..b74522f8b7ac164819aff24725966e8873e147e0 100644 (file)
@@ -616,7 +616,7 @@ MDNode *DIDerivedType::getObjCProperty() const {
   return dyn_cast_or_null<MDNode>(DbgNode->getOperand(10));
 }
 
-/// \brief Set the array of member DITypes
+/// \brief Set the array of member DITypes.
 void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) {
   assert(!TParams || DbgNode->getNumOperands() == 14 && "If you're setting the template parameters this should include a slot for that");
   TrackingVH<MDNode> N(*this);
@@ -626,6 +626,13 @@ void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) {
   DbgNode = N;
 }
 
+/// \brief Set the containing type.
+void DICompositeType::setContainingType(DICompositeType ContainingType) {
+  TrackingVH<MDNode> N(*this);
+  N->replaceOperandWith(12, ContainingType);
+  DbgNode = N;
+}
+
 /// isInlinedFnArgument - Return true if this variable provides debugging
 /// information for an inlined function arguments.
 bool DIVariable::isInlinedFnArgument(const Function *CurFn) {