[llvm] r188082 - DebugInfo: provide the ability to add members to a class after it has been constructed

David Blaikie dblaikie at gmail.com
Fri Aug 9 10:17:13 PDT 2013


Author: dblaikie
Date: Fri Aug  9 12:17:12 2013
New Revision: 188082

URL: http://llvm.org/viewvc/llvm-project?rev=188082&view=rev
Log:
DebugInfo: provide the ability to add members to a class after it has been constructed

This is necessary to allow Clang to only emit implicit members when
there is code generated for them, rather than whenever they are ODR
used.

Modified:
    llvm/trunk/include/llvm/DebugInfo.h
    llvm/trunk/lib/IR/DebugInfo.cpp

Modified: llvm/trunk/include/llvm/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=188082&r1=188081&r2=188082&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/DebugInfo.h Fri Aug  9 12:17:12 2013
@@ -323,6 +323,7 @@ namespace llvm {
 
     DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
     void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
+    void addMember(DISubprogram S);
     unsigned getRunTimeLang() const { return getUnsignedField(11); }
     DICompositeType getContainingType() const {
       return getFieldAs<DICompositeType>(12);

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=188082&r1=188081&r2=188082&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Fri Aug  9 12:17:12 2013
@@ -647,6 +647,19 @@ void DICompositeType::setTypeArray(DIArr
   DbgNode = N;
 }
 
+void DICompositeType::addMember(DISubprogram S) {
+  SmallVector<llvm::Value *, 16> 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<MDNode> N(*this);





More information about the llvm-commits mailing list