forked from OSchip/llvm-project
[clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.
Update ASTImporter to import value of FieldDecl::getCapturedVLAType. Reviewed By: shafik, martong Differential Revision: https://reviews.llvm.org/D99062
This commit is contained in:
parent
960a767368
commit
3cde27bc56
|
@ -3632,6 +3632,10 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
|
|||
auto ToInitializer = importChecked(Err, D->getInClassInitializer());
|
||||
if (Err)
|
||||
return std::move(Err);
|
||||
const Type *ToCapturedVLAType = nullptr;
|
||||
if (Error Err = Importer.importInto(
|
||||
ToCapturedVLAType, cast_or_null<Type>(D->getCapturedVLAType())))
|
||||
return std::move(Err);
|
||||
|
||||
FieldDecl *ToField;
|
||||
if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
|
||||
|
@ -3645,6 +3649,8 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
|
|||
if (ToInitializer)
|
||||
ToField->setInClassInitializer(ToInitializer);
|
||||
ToField->setImplicit(D->isImplicit());
|
||||
if (ToCapturedVLAType)
|
||||
ToField->setCapturedVLAType(cast<VariableArrayType>(ToCapturedVLAType));
|
||||
LexicalDC->addDeclInternal(ToField);
|
||||
return ToField;
|
||||
}
|
||||
|
|
|
@ -6261,6 +6261,25 @@ TEST_P(ASTImporterOptionSpecificTestBase,
|
|||
EXPECT_TRUE(To2);
|
||||
}
|
||||
|
||||
TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
|
||||
Decl *FromTU = getTuDecl(
|
||||
R"(
|
||||
void declToImport(int N) {
|
||||
int VLA[N];
|
||||
[&VLA] {}; // FieldDecl inside the lambda.
|
||||
}
|
||||
)",
|
||||
Lang_CXX14);
|
||||
auto *FromFD = FirstDeclMatcher<FieldDecl>().match(FromTU, fieldDecl());
|
||||
ASSERT_TRUE(FromFD);
|
||||
ASSERT_TRUE(FromFD->hasCapturedVLAType());
|
||||
|
||||
auto *ToFD = Import(FromFD, Lang_CXX14);
|
||||
EXPECT_TRUE(ToFD);
|
||||
EXPECT_TRUE(ToFD->hasCapturedVLAType());
|
||||
EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
|
||||
DefaultTestValuesForRunOptions, );
|
||||
|
||||
|
|
Loading…
Reference in New Issue