Skip to content

Commit d16d371

Browse files
committed
[lldb] Fix crash in AccessDeclContextSanity when copying FunctionTemplateDecl inside a record.
Summary: We currently don't set access specifiers for function template declarations. This seems to be fine as long as the function template is not declared inside any record in which case Clang asserts with the following once we try to query it's access: ``` Assertion failed: (Access != AS_none && "Access specifier is AS_none inside a record decl"), function AccessDeclContextSanity, ``` This patch just marks these function template declarations as public to make Clang happy. Reviewers: shafik, teemperor Reviewed By: teemperor Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71909
1 parent c3e5ae3 commit d16d371

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/TestCompletionCrash2.py

Lines changed: 0 additions & 4 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from lldbsuite.test import lldbinline
2+
from lldbsuite.test import decorators
3+
4+
lldbinline.MakeInlineTest(__file__, globals(), [])

lldb/source/Symbol/ClangASTContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,11 @@ clang::FunctionTemplateDecl *ClangASTContext::CreateFunctionTemplateDecl(
15471547
// TODO: verify which decl context we should put template_param_decls into..
15481548
template_param_decls[i]->setDeclContext(func_decl);
15491549
}
1550+
// Function templates inside a record need to have an access specifier.
1551+
// It doesn't matter what access specifier we give the template as LLDB
1552+
// anyway allows accessing everything inside a record.
1553+
if (decl_ctx->isRecord())
1554+
func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
15501555

15511556
return func_tmpl_decl;
15521557
}

0 commit comments

Comments
 (0)