[Lldb-commits] [PATCH] D66357: Fix GetDIEForDeclContext so it only returns entries matching the provided context

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 19 07:17:56 PDT 2019


clayborg added a comment.

In D66357#1634175 <https://reviews.llvm.org/D66357#1634175>, @guiandrade wrote:

> In D66357#1633461 <https://reviews.llvm.org/D66357#1633461>, @clayborg wrote:
>
> > Needs a test, but looks good.
>
>
> Sure, I agree. Though, it's not total clear to me how we could do that.
>
> I imagined something like the following.
>
>   TEST_F(DWARFASTParserClangTests,
>          TestGetDIEForDeclContextReturnsOnlyMatchingEntries) {
>     auto ast = ClangASTContext(...);
>     auto ast_parser = DWARFASTParserClang(ast);
>     CompilerDeclContext decl1(nullptr, (void *)1LL);
>     CompilerDeclContext decl2(nullptr, (void *)2LL);
>     CompilerDeclContext decl3(nullptr, (void *)2LL);
>     CompilerDeclContext decl4(nullptr, (void *)3LL);
>     ast_parser->LinkDeclContextToDIE(decl1, DWARFDIE());
>     ast_parser->LinkDeclContextToDIE(decl2, DWARFDIE());
>     ast_parser->LinkDeclContextToDIE(decl3, DWARFDIE());
>     ast_parser->LinkDeclContextToDIE(decl4, DWARFDIE());
>  
>     auto decl_ctx_die_list = ast_parser->GetDIEForDeclContext(decl2);
>     EXPECT_EQ(2u, decl_ctx_die_list.size());
>     EXPECT_EQ(decl2.GetOpaqueDeclContext(),
>               decl_ctx_die_list[0].GetDeclContext().GetOpaqueDeclContext());
>     EXPECT_EQ(decl3.GetOpaqueDeclContext(),
>               decl_ctx_die_list[1].GetDeclContext().GetOpaqueDeclContext());
>   }
>
>
> But DWARFASTParserClang::LinkDeclContextToDIE is protected. Do you have any ideas to overcome that?


Feel free to relax that function to be public or to add a testing helper function that is public if needed. If you make it public, please put a comment on the function to indicate it was done for testing purposes.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66357/new/

https://reviews.llvm.org/D66357





More information about the lldb-commits mailing list