This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix TestClangASTContext.TestFunctionTemplateInRecordConstruction in Debug builds
ClosedPublic

Authored by teemperor on Jan 7 2020, 1:02 PM.

Details

Summary

In Debug builds we call VerifyDecl in ClangASTContext::CreateFunctionDeclaration which in turn
calls getAccess on the created FunctionDecl. As we passed in a RecordDecl as the DeclContext
for the FunctionDecl, we end up hitting the assert in getAccess that checks that we never have
a Decl inside a Record without a valid AccessSpecifier. FunctionDecls are never in RecordDecls
(that would be a CXXMethodDecl) so setting a access specifier would not be the correct way to
fix this.

Instead this patch does the same thing that DWARFASTParserClang::ParseSubroutine is doing:
We pass in the FunctionDecl with the TranslationUnit as the DeclContext. That's not ideal but
it is how we currently do it when creating our debug info AST, so the unit test should do
the same.

Diff Detail

Event Timeline

teemperor created this revision.Jan 7 2020, 1:02 PM
shafik accepted this revision.Jan 9 2020, 10:16 AM

LGTM

This revision is now accepted and ready to land.Jan 9 2020, 10:16 AM
This revision was automatically updated to reflect the committed changes.