[PATCH] D99062: [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 23 00:58:21 PDT 2021
balazske updated this revision to Diff 332551.
balazske added a comment.
Rebase and changed test code format.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99062/new/
https://reviews.llvm.org/D99062
Files:
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===================================================================
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6261,6 +6261,25 @@
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, );
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,10 @@
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 @@
if (ToInitializer)
ToField->setInClassInitializer(ToInitializer);
ToField->setImplicit(D->isImplicit());
+ if (ToCapturedVLAType)
+ ToField->setCapturedVLAType(cast<VariableArrayType>(ToCapturedVLAType));
LexicalDC->addDeclInternal(ToField);
return ToField;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99062.332551.patch
Type: text/x-patch
Size: 1876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210323/f9514ef2/attachment.bin>
More information about the cfe-commits
mailing list