[cfe-commits] r124753 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template.cpp

Devang Patel dpatel at apple.com
Wed Feb 2 13:38:49 PST 2011


Author: dpatel
Date: Wed Feb  2 15:38:49 2011
New Revision: 124753

URL: http://llvm.org/viewvc/llvm-project?rev=124753&view=rev
Log:
Emit debug info for template type parameters.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-template.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=124753&r1=124752&r2=124753&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Feb  2 15:38:49 2011
@@ -953,9 +953,23 @@
     }
 
   CollectRecordFields(RD, Unit, EltTys);
+  llvm::SmallVector<llvm::Value *, 16> TemplateParams;
   if (CXXDecl) {
     CollectCXXMemberFunctions(CXXDecl, Unit, EltTys, FwdDecl);
     CollectCXXFriends(CXXDecl, Unit, EltTys, FwdDecl);
+    if (ClassTemplateSpecializationDecl *TSpecial
+        = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
+      const TemplateArgumentList &TAL = TSpecial->getTemplateArgs();
+      for (unsigned i = 0, e = TAL.size(); i != e; ++i) {
+        const TemplateArgument &TA = TAL[i];
+        if (TA.getKind() == TemplateArgument::Type) {
+          llvm::DIType TTy = getOrCreateType(TA.getAsType(), Unit);
+          llvm::DITemplateTypeParameter TTP =
+            DBuilder.CreateTemplateTypeParameter(TheCU, TTy.getName(), TTy);
+          TemplateParams.push_back(TTP);
+        }
+      }
+    }
   }
 
   RegionStack.pop_back();
@@ -1000,9 +1014,12 @@
     }
     else if (CXXDecl->isDynamicClass()) 
       ContainingType = FwdDecl;
+    llvm::DIArray TParamsArray = 
+      DBuilder.GetOrCreateArray(TemplateParams.data(), TemplateParams.size());
    RealDecl = DBuilder.CreateClassType(RDContext, RDName, DefUnit, Line,
                                        Size, Align, 0, 0, llvm::DIType(),
-                                       Elements, ContainingType);
+                                       Elements, ContainingType,
+                                       TParamsArray);
   }
 
   // Now that we have a real decl for the struct, replace anything using the

Modified: cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template.cpp?rev=124753&r1=124752&r2=124753&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template.cpp Wed Feb  2 15:38:49 2011
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm-only -g -S %s -o - | grep "TC<int>"
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+
+//CHECK: TC<int>
+//CHECK: DW_TAG_template_type_parameter
+
 template<typename T>
 class TC {
 public:





More information about the cfe-commits mailing list