summaryrefslogtreecommitdiffstats
path: root/clang/unittests/AST/ASTImporterTest.cpp
diff options
context:
space:
mode:
authorGabor Marton <gabor.marton@ericsson.com>2019-07-08 12:49:13 +0000
committerGabor Marton <gabor.marton@ericsson.com>2019-07-08 12:49:13 +0000
commite73805f80eab155e38a83c61710b5186ea2ea04f (patch)
tree58f8c7407f7303807250d9605310907181568e09 /clang/unittests/AST/ASTImporterTest.cpp
parent0752d12c0910ece5041806e5d967ce48039df9f7 (diff)
downloadbcm5719-llvm-e73805f80eab155e38a83c61710b5186ea2ea04f.tar.gz
bcm5719-llvm-e73805f80eab155e38a83c61710b5186ea2ea04f.zip
[ASTImporter] Fix import of lambda in function param
Summary: The current import implementation fails to import the definition of a lambda class if the lambda class is defined in a function param. E.g., the lambda class below will be imported without any methods: ``` template <typename F> void f(F L = [](){}) {} ``` Reviewers: a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64073 llvm-svn: 365315
Diffstat (limited to 'clang/unittests/AST/ASTImporterTest.cpp')
-rw-r--r--clang/unittests/AST/ASTImporterTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index 165946a669f..6b8315f2b9e 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -5083,6 +5083,45 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTests, DeclContextTest,
INSTANTIATE_TEST_CASE_P(ParameterizedTests, CanonicalRedeclChain,
::testing::Values(ArgVector()), );
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionBody) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ void f() {
+ auto L = [](){};
+ }
+ )",
+ Lang_CXX11, "input0.cc");
+ auto Pattern = lambdaExpr();
+ CXXRecordDecl *FromL =
+ FirstDeclMatcher<LambdaExpr>().match(FromTU, Pattern)->getLambdaClass();
+
+ auto ToL = Import(FromL, Lang_CXX11);
+ unsigned ToLSize = std::distance(ToL->decls().begin(), ToL->decls().end());
+ unsigned FromLSize =
+ std::distance(FromL->decls().begin(), FromL->decls().end());
+ EXPECT_NE(ToLSize, 0u);
+ EXPECT_EQ(ToLSize, FromLSize);
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionParam) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ template <typename F>
+ void f(F L = [](){}) {}
+ )",
+ Lang_CXX11, "input0.cc");
+ auto Pattern = lambdaExpr();
+ CXXRecordDecl *FromL =
+ FirstDeclMatcher<LambdaExpr>().match(FromTU, Pattern)->getLambdaClass();
+
+ auto ToL = Import(FromL, Lang_CXX11);
+ unsigned ToLSize = std::distance(ToL->decls().begin(), ToL->decls().end());
+ unsigned FromLSize =
+ std::distance(FromL->decls().begin(), FromL->decls().end());
+ EXPECT_NE(ToLSize, 0u);
+ EXPECT_EQ(ToLSize, FromLSize);
+}
+
INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
DefaultTestValuesForRunOptions, );
OpenPOWER on IntegriCloud