[cfe-commits] r128915 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Devang Patel dpatel at apple.com
Tue Apr 5 13:15:06 PDT 2011


Author: dpatel
Date: Tue Apr  5 15:15:06 2011
New Revision: 128915

URL: http://llvm.org/viewvc/llvm-project?rev=128915&view=rev
Log:
Use TemplateParameterList to extract template parameter name.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=128915&r1=128914&r2=128915&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Apr  5 15:15:06 2011
@@ -840,21 +840,28 @@
 llvm::DIArray CGDebugInfo::
 CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TSpecial,
                          llvm::DIFile Unit) {
-  llvm::SmallVector<llvm::Value *, 16> TemplateParams;
-  const TemplateArgumentList &TAL = TSpecial->getTemplateArgs();
-  for (unsigned i = 0, e = TAL.size(); i != e; ++i) {
-    const TemplateArgument &TA = TAL[i];
+  llvm::PointerUnion<ClassTemplateDecl *,
+                     ClassTemplatePartialSpecializationDecl *>
+    PU = TSpecial->getSpecializedTemplateOrPartial();
+  
+  TemplateParameterList *TPList = PU.is<ClassTemplateDecl *>() ?
+    PU.get<ClassTemplateDecl *>()->getTemplateParameters() :
+    PU.get<ClassTemplatePartialSpecializationDecl *>()->getTemplateParameters();
+  const TemplateArgumentList &TAList = TSpecial->getTemplateInstantiationArgs();
+  llvm::SmallVector<llvm::Value *, 16> TemplateParams;  
+  for (unsigned i = 0, e = TAList.size(); i != e; ++i) {
+    const TemplateArgument &TA = TAList[i];
+    NamedDecl *ND = TPList->getParam(i);
     if (TA.getKind() == TemplateArgument::Type) {
       llvm::DIType TTy = getOrCreateType(TA.getAsType(), Unit);
       llvm::DITemplateTypeParameter TTP =
-        DBuilder.createTemplateTypeParameter(TheCU, TTy.getName(), TTy);
+        DBuilder.createTemplateTypeParameter(TheCU, ND->getName(), TTy);
       TemplateParams.push_back(TTP);
     } else if (TA.getKind() == TemplateArgument::Integral) {
       llvm::DIType TTy = getOrCreateType(TA.getIntegralType(), Unit);
-      // FIXME: Get parameter name, instead of parameter type name.
       llvm::DITemplateValueParameter TVP =
-        DBuilder.createTemplateValueParameter(TheCU, TTy.getName(), TTy,
-                                              TA.getAsIntegral()->getZExtValue());
+        DBuilder.createTemplateValueParameter(TheCU, ND->getName(), TTy,
+                                          TA.getAsIntegral()->getZExtValue());
       TemplateParams.push_back(TVP);          
     }
   }





More information about the cfe-commits mailing list