From: Richard Trieu Date: Sat, 11 Nov 2017 00:54:25 +0000 (+0000) Subject: Handle lambda captures of variable length arrays in profiling and printing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b947cc35e20b4818236c04ea5a9268e713e5c0ad;p=clang Handle lambda captures of variable length arrays in profiling and printing. From http://reviews.llvm.org/D4368 these cases were thought to not be reachable and the checks removed before the rest of the code was committed in r216649. However, these cases are reachable and the checks are added back. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317957 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 371d3e181d..09092743f0 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -2232,6 +2232,9 @@ void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) { CEnd = Node->explicit_capture_end(); C != CEnd; ++C) { + if (C->capturesVLAType()) + continue; + if (NeedComma) OS << ", "; NeedComma = true; diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index 9acd79bc2c..6cc77f682e 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -1590,6 +1590,9 @@ StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), CEnd = S->explicit_capture_end(); C != CEnd; ++C) { + if (C->capturesVLAType()) + continue; + ID.AddInteger(C->getCaptureKind()); switch (C->getCaptureKind()) { case LCK_StarThis: diff --git a/test/SemaCXX/cxx11-ast-print.cpp b/test/SemaCXX/cxx11-ast-print.cpp index 9c617af4e9..17dcbcb3f7 100644 --- a/test/SemaCXX/cxx11-ast-print.cpp +++ b/test/SemaCXX/cxx11-ast-print.cpp @@ -55,4 +55,8 @@ struct B : A { ; // CHECK-NOT: ; +void g(int n) { + int buffer[n]; // CHECK: int buffer[n]; + [&buffer]() {}(); // CHECK: [&buffer] +}