Skip to content

Commit 22687c1

Browse files
authored
Merge pull request #746 from Teemperor/FixDebugBuildTestFunctionTemplate
[lldb] Fix TestClangASTContext.TestFunctionTemplateInRecordConstructi…
2 parents d0e243f + eccbcf9 commit 22687c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lldb/unittests/Symbol/TestTypeSystemClang.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateInRecordConstruction) {
498498
// Tests creating a function template inside a record.
499499

500500
CompilerType int_type = m_ast->GetBasicType(lldb::eBasicTypeInt);
501+
clang::TranslationUnitDecl *TU = m_ast->GetTranslationUnitDecl();
501502

502503
// Create a record we can put the function template int.
503504
CompilerType record_type =
@@ -507,8 +508,11 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateInRecordConstruction) {
507508
// Prepare the declarations/types we need for the template.
508509
CompilerType clang_type =
509510
m_ast->CreateFunctionType(int_type, nullptr, 0U, false, 0U);
511+
// We create the FunctionDecl for the template in the TU DeclContext because:
512+
// 1. FunctionDecls can't be in a Record (only CXXMethodDecls can).
513+
// 2. It is mirroring the behavior of DWARFASTParserClang::ParseSubroutine.
510514
FunctionDecl *func =
511-
m_ast->CreateFunctionDeclaration(record, "foo", clang_type, 0, false);
515+
m_ast->CreateFunctionDeclaration(TU, "foo", clang_type, 0, false);
512516
TypeSystemClang::TemplateParameterInfos empty_params;
513517

514518
// Create the actual function template.

0 commit comments

Comments
 (0)