diff options
author | Aleksei Sidorin <a.sidorin@samsung.com> | 2018-01-26 11:36:54 +0000 |
---|---|---|
committer | Aleksei Sidorin <a.sidorin@samsung.com> | 2018-01-26 11:36:54 +0000 |
commit | 8fc8510cb8dab5857e62870e976dfa7feca3fca7 (patch) | |
tree | 987fca5b298b2c15fa7be4579f9ea381df60058b /clang/test/ASTMerge/exprs-cpp | |
parent | 24f0fa34c2e8d01ce97008f0f664016378079a92 (diff) | |
download | bcm5719-llvm-8fc8510cb8dab5857e62870e976dfa7feca3fca7.tar.gz bcm5719-llvm-8fc8510cb8dab5857e62870e976dfa7feca3fca7.zip |
[ASTImporter] Support LambdaExprs and improve template support
Also, a number of style and bug fixes was done:
* ASTImporterTest: added sanity check for source node
* ExternalASTMerger: better lookup for template specializations
* ASTImporter: don't add templated declarations into DeclContext
* ASTImporter: introduce a helper, ImportTemplateArgumentListInfo getting SourceLocations
* ASTImporter: proper set ParmVarDecls for imported FunctionProtoTypeLoc
Differential Revision: https://reviews.llvm.org/D42301
llvm-svn: 323519
Diffstat (limited to 'clang/test/ASTMerge/exprs-cpp')
-rw-r--r-- | clang/test/ASTMerge/exprs-cpp/Inputs/exprs3.cpp | 17 | ||||
-rw-r--r-- | clang/test/ASTMerge/exprs-cpp/test.cpp | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/ASTMerge/exprs-cpp/Inputs/exprs3.cpp b/clang/test/ASTMerge/exprs-cpp/Inputs/exprs3.cpp index 2a33c35d9ea..6fdc33fb391 100644 --- a/clang/test/ASTMerge/exprs-cpp/Inputs/exprs3.cpp +++ b/clang/test/ASTMerge/exprs-cpp/Inputs/exprs3.cpp @@ -122,3 +122,20 @@ void useTemplateType() { const bool ExpressionTrait = __is_lvalue_expr(1); const unsigned ArrayRank = __array_rank(int[10][20]); const unsigned ArrayExtent = __array_extent(int[10][20], 1); + +constexpr int testLambdaAdd(int toAdd) { + const int Captured1 = 1, Captured2 = 2; + constexpr auto LambdaAdd = [Captured1, Captured2](int k) -> int { + return Captured1 + Captured2 + k; + }; + return LambdaAdd(toAdd); +} + +template<typename T> +struct TestLambdaTemplate { + T i, j; + TestLambdaTemplate(T i, const T &j) : i(i), j(j) {} + T testLambda(T k) { + return [this](T k) -> decltype(auto) { return i + j + k; }(k); + } +}; diff --git a/clang/test/ASTMerge/exprs-cpp/test.cpp b/clang/test/ASTMerge/exprs-cpp/test.cpp index 0535aa85330..c0b282ec028 100644 --- a/clang/test/ASTMerge/exprs-cpp/test.cpp +++ b/clang/test/ASTMerge/exprs-cpp/test.cpp @@ -30,6 +30,8 @@ static_assert(ExpressionTrait == false); static_assert(ArrayRank == 2); static_assert(ArrayExtent == 20); +static_assert(testLambdaAdd(3) == 6); + void testImport(int *x, const S1 &cs1, S1 &s1) { testNewThrowDelete(); testArrayElement(nullptr, 12); @@ -44,4 +46,5 @@ void testImport(int *x, const S1 &cs1, S1 &s1) { testDefaultArg(); testDefaultArgExpr(); useTemplateType(); + TestLambdaTemplate<int>(1, 2).testLambda(3); } |