Provide more details for DINameSpace debug info in the IR comment annotations
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 20 Mar 2013 05:14:14 +0000 (05:14 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 20 Mar 2013 05:14:14 +0000 (05:14 +0000)
Sorry for the version skew - I should've committed this before the
corresponding Clang test case.

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

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

index 30ea378a6fadf8c5359d437c94ecd3873710bb5a..103a9b2842c621dcc7260378271332daec0143c4 100644 (file)
@@ -640,6 +640,8 @@ namespace llvm {
 
   /// DINameSpace - A wrapper for a C++ style name space.
   class DINameSpace : public DIScope {
+    friend class DIDescriptor;
+    void printInternal(raw_ostream &OS) const;
   public:
     explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
     DIScope getContext() const     { return getFieldAs<DIScope>(1);      }
index d1db3ab53af7f188229376db3627ed867d08e1ce..dd7ba23bf1a3321aa16ffb4e3c440d2dcd12d9cd 100644 (file)
@@ -1033,6 +1033,8 @@ void DIDescriptor::print(raw_ostream &OS) const {
     DIVariable(DbgNode).printInternal(OS);
   } else if (this->isObjCProperty()) {
     DIObjCProperty(DbgNode).printInternal(OS);
+  } else if (this->isNameSpace()) {
+    DINameSpace(DbgNode).printInternal(OS);
   } else if (this->isScope()) {
     DIScope(DbgNode).printInternal(OS);
   }
@@ -1106,6 +1108,14 @@ void DICompositeType::printInternal(raw_ostream &OS) const {
   OS << " [" << A.getNumElements() << " elements]";
 }
 
+void DINameSpace::printInternal(raw_ostream &OS) const {
+  StringRef Name = getName();
+  if (!Name.empty())
+    OS << " [" << Name << ']';
+
+  OS << " [line " << getLineNumber() << ']';
+}
+
 void DISubprogram::printInternal(raw_ostream &OS) const {
   // TODO : Print context
   OS << " [line " << getLineNumber() << ']';