diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
commit | b76161e41bc2c07cd47f9c61f875d1be95e26d10 (patch) | |
tree | d03c19ce10dec6419f97df1d4dac9d47eb88982f /source/Symbol/ClangASTContext.cpp | |
parent | 8b4000f13b303cc154136abc74c55670673e2a96 (diff) |
Notes
Diffstat (limited to 'source/Symbol/ClangASTContext.cpp')
-rw-r--r-- | source/Symbol/ClangASTContext.cpp | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp index 8e2576aaec95..94c91fe335a7 100644 --- a/source/Symbol/ClangASTContext.cpp +++ b/source/Symbol/ClangASTContext.cpp @@ -1394,6 +1394,12 @@ CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx, return CompilerType(); } +namespace { + bool IsValueParam(const clang::TemplateArgument &argument) { + return argument.getKind() == TemplateArgument::Integral; + } +} + static TemplateParameterList *CreateTemplateParameterList( ASTContext *ast, const ClangASTContext::TemplateParameterInfos &template_param_infos, @@ -1401,31 +1407,51 @@ static TemplateParameterList *CreateTemplateParameterList( const bool parameter_pack = false; const bool is_typename = false; const unsigned depth = 0; - const size_t num_template_params = template_param_infos.GetSize(); + const size_t num_template_params = template_param_infos.args.size(); + DeclContext *const decl_context = + ast->getTranslationUnitDecl(); // Is this the right decl context?, for (size_t i = 0; i < num_template_params; ++i) { const char *name = template_param_infos.names[i]; IdentifierInfo *identifier_info = nullptr; if (name && name[0]) identifier_info = &ast->Idents.get(name); - if (template_param_infos.args[i].getKind() == TemplateArgument::Integral) { + if (IsValueParam(template_param_infos.args[i])) { template_param_decls.push_back(NonTypeTemplateParmDecl::Create( - *ast, - ast->getTranslationUnitDecl(), // Is this the right decl context?, - // SourceLocation StartLoc, + *ast, decl_context, SourceLocation(), SourceLocation(), depth, i, identifier_info, template_param_infos.args[i].getIntegralType(), parameter_pack, nullptr)); } else { template_param_decls.push_back(TemplateTypeParmDecl::Create( - *ast, - ast->getTranslationUnitDecl(), // Is this the right decl context? + *ast, decl_context, SourceLocation(), SourceLocation(), depth, i, identifier_info, is_typename, parameter_pack)); } } - + + if (template_param_infos.packed_args && + template_param_infos.packed_args->args.size()) { + IdentifierInfo *identifier_info = nullptr; + if (template_param_infos.pack_name && template_param_infos.pack_name[0]) + identifier_info = &ast->Idents.get(template_param_infos.pack_name); + const bool parameter_pack_true = true; + if (IsValueParam(template_param_infos.packed_args->args[0])) { + template_param_decls.push_back(NonTypeTemplateParmDecl::Create( + *ast, decl_context, + SourceLocation(), SourceLocation(), depth, num_template_params, + identifier_info, + template_param_infos.packed_args->args[0].getIntegralType(), + parameter_pack_true, nullptr)); + } else { + template_param_decls.push_back(TemplateTypeParmDecl::Create( + *ast, decl_context, + SourceLocation(), SourceLocation(), depth, num_template_params, + identifier_info, + is_typename, parameter_pack_true)); + } + } clang::Expr *const requires_clause = nullptr; // TODO: Concepts TemplateParameterList *template_param_list = TemplateParameterList::Create( *ast, SourceLocation(), SourceLocation(), template_param_decls, @@ -1535,10 +1561,19 @@ ClangASTContext::CreateClassTemplateSpecializationDecl( DeclContext *decl_ctx, ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &template_param_infos) { ASTContext *ast = getASTContext(); + llvm::SmallVector<clang::TemplateArgument, 2> args( + template_param_infos.args.size() + + (template_param_infos.packed_args ? 1 : 0)); + std::copy(template_param_infos.args.begin(), template_param_infos.args.end(), + args.begin()); + if (template_param_infos.packed_args) { + args[args.size() - 1] = TemplateArgument::CreatePackCopy( + *ast, template_param_infos.packed_args->args); + } ClassTemplateSpecializationDecl *class_template_specialization_decl = ClassTemplateSpecializationDecl::Create( *ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(), - SourceLocation(), class_template_decl, template_param_infos.args, + SourceLocation(), class_template_decl, args, nullptr); class_template_specialization_decl->setSpecializationKind( @@ -4458,7 +4493,7 @@ ClangASTContext::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) { case clang::Type::ObjCObjectPointer: { const clang::ObjCObjectPointerType *objc_class_type = - qual_type->getAsObjCInterfacePointerType(); + qual_type->getAs<clang::ObjCObjectPointerType>(); const clang::ObjCInterfaceType *objc_interface_type = objc_class_type->getInterfaceType(); if (objc_interface_type && @@ -4567,7 +4602,7 @@ ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, case clang::Type::ObjCObjectPointer: { const clang::ObjCObjectPointerType *objc_class_type = - qual_type->getAsObjCInterfacePointerType(); + qual_type->getAs<clang::ObjCObjectPointerType>(); const clang::ObjCInterfaceType *objc_interface_type = objc_class_type->getInterfaceType(); if (objc_interface_type && @@ -5636,7 +5671,7 @@ uint32_t ClangASTContext::GetNumFields(lldb::opaque_compiler_type_t type) { case clang::Type::ObjCObjectPointer: { const clang::ObjCObjectPointerType *objc_class_type = - qual_type->getAsObjCInterfacePointerType(); + qual_type->getAs<clang::ObjCObjectPointerType>(); const clang::ObjCInterfaceType *objc_interface_type = objc_class_type->getInterfaceType(); if (objc_interface_type && @@ -5784,7 +5819,7 @@ CompilerType ClangASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type, case clang::Type::ObjCObjectPointer: { const clang::ObjCObjectPointerType *objc_class_type = - qual_type->getAsObjCInterfacePointerType(); + qual_type->getAs<clang::ObjCObjectPointerType>(); const clang::ObjCInterfaceType *objc_interface_type = objc_class_type->getInterfaceType(); if (objc_interface_type && @@ -6398,7 +6433,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( if (base_class->isVirtual()) { bool handled = false; if (valobj) { - Error err; + Status err; AddressType addr_type = eAddressTypeInvalid; lldb::addr_t vtable_ptr_addr = valobj->GetCPPVTableAddress(addr_type); @@ -8792,7 +8827,7 @@ ClangASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, if (dst_size >= byte_size) { Scalar scalar = ap_float.bitcastToAPInt().zextOrTrunc( llvm::NextPowerOf2(byte_size) * 8); - lldb_private::Error get_data_error; + lldb_private::Status get_data_error; if (scalar.GetAsMemoryData(dst, byte_size, lldb_private::endian::InlHostByteOrder(), get_data_error)) @@ -9361,7 +9396,7 @@ void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type, buf.back() = '\0'; size_t bytes_read; size_t total_cstr_len = 0; - Error error; + Status error; while ((bytes_read = process->ReadMemory(pointer_address, &buf.front(), buf.size(), error)) > 0) { const size_t len = strlen((const char *)&buf.front()); |