[Lldb-commits] [lldb] r180155 - <rdar://problem/13298695>

Greg Clayton gclayton at apple.com
Tue Apr 23 15:38:02 PDT 2013


Author: gclayton
Date: Tue Apr 23 17:38:02 2013
New Revision: 180155

URL: http://llvm.org/viewvc/llvm-project?rev=180155&view=rev
Log:
<rdar://problem/13298695>

Fixed LLDB to be able to correctly parse template parameters that have no name and no type. This can be triggered by the following LLVM/Clang code:

template <typename T, typename = void>
class SmallVectorTemplateCommon : public SmallVectorBase {

The “typename = void” was emitting DWARF with an empty DW_AT_name and no DW_AT_type. We now correctly infer that no DW_AT_type means “void” and that an empty name is ok.

This means you can now call functions on things that inherit from SmallVectorTemplateCommon.

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=180155&r1=180154&r2=180155&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Apr 23 17:38:02 2013
@@ -1273,15 +1273,26 @@ SymbolFileDWARF::ParseTemplateDIE (DWARF
                     }
                 }
                 
-                if (name && lldb_type && clang_type)
+                clang::ASTContext *ast = GetClangASTContext().getASTContext();
+                if (!clang_type)
+                    clang_type = ast->VoidTy.getAsOpaquePtr();
+
+                if (clang_type)
                 {
                     bool is_signed = false;
-                    template_param_infos.names.push_back(name);
+                    if (name && name[0])
+                        template_param_infos.names.push_back(name);
+                    else
+                        template_param_infos.names.push_back(NULL);
+    
                     clang::QualType clang_qual_type (clang::QualType::getFromOpaquePtr (clang_type));
-                    if (tag == DW_TAG_template_value_parameter && ClangASTContext::IsIntegerType (clang_type, is_signed) && uval64_valid)
+                    if (tag == DW_TAG_template_value_parameter &&
+                        lldb_type != NULL &&
+                        ClangASTContext::IsIntegerType (clang_type, is_signed) &&
+                        uval64_valid)
                     {
                         llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed);
-                        template_param_infos.args.push_back (clang::TemplateArgument (*GetClangASTContext().getASTContext(),
+                        template_param_infos.args.push_back (clang::TemplateArgument (*ast,
                                                                                       llvm::APSInt(apint),
                                                                                       clang_qual_type));
                     }

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=180155&r1=180154&r2=180155&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Apr 23 17:38:02 2013
@@ -1193,6 +1193,10 @@ CreateTemplateParameterList (ASTContext
     for (size_t i=0; i<num_template_params; ++i)
     {
         const char *name = template_param_infos.names[i];
+        
+        IdentifierInfo *identifier_info = NULL;
+        if (name && name[0])
+            identifier_info = &ast->Idents.get(name);
         if (template_param_infos.args[i].getKind() == TemplateArgument::Integral)
         {
             template_param_decls.push_back (NonTypeTemplateParmDecl::Create (*ast,
@@ -1201,7 +1205,7 @@ CreateTemplateParameterList (ASTContext
                                                                              SourceLocation(), 
                                                                              depth, 
                                                                              i,
-                                                                             &ast->Idents.get(name), 
+                                                                             identifier_info,
                                                                              template_param_infos.args[i].getIntegralType(), 
                                                                              parameter_pack, 
                                                                              NULL));
@@ -1215,7 +1219,7 @@ CreateTemplateParameterList (ASTContext
                                                                           SourceLocation(),
                                                                           depth, 
                                                                           i,
-                                                                          &ast->Idents.get(name), 
+                                                                          identifier_info,
                                                                           is_typename,
                                                                           parameter_pack));
         }





More information about the lldb-commits mailing list