Debug Info: Provide a means to update the members of a composite type
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 26 Mar 2013 21:59:17 +0000 (21:59 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 26 Mar 2013 21:59:17 +0000 (21:59 +0000)
This will be used to factor out some uses of magic number operand offsets
inside Clang where these fields were updated in an effort to resolve forward
declarations/circular references.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178078 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 3a2aff3f15ce959450947b510fabdd023419f24b..e30713e2520846e140a37c2e02fcba44bc5414ff 100644 (file)
@@ -354,6 +354,7 @@ namespace llvm {
     }
 
     DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
+    void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
     unsigned getRunTimeLang() const { return getUnsignedField(11); }
     DICompositeType getContainingType() const {
       return getFieldAs<DICompositeType>(12);
index 5ab64265e49fc2fb2b32015f37f7fcd401b574ca..1916f5ea9667e2bc1f9150cef9964d85d9736f9a 100644 (file)
@@ -25,6 +25,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Dwarf.h"
+#include "llvm/Support/ValueHandle.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 using namespace llvm::dwarf;
@@ -615,6 +616,16 @@ MDNode *DIDerivedType::getObjCProperty() const {
   return dyn_cast_or_null<MDNode>(DbgNode->getOperand(10));
 }
 
+/// \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);
+  N->replaceOperandWith(10, Elements);
+  if (TParams)
+    N->replaceOperandWith(13, TParams);
+  DbgNode = N;
+}
+
 /// isInlinedFnArgument - Return true if this variable provides debugging
 /// information for an inlined function arguments.
 bool DIVariable::isInlinedFnArgument(const Function *CurFn) {