Author: rtrieu Date: Fri Nov 10 16:54:25 2017 New Revision: 317957 URL: http://llvm.org/viewvc/llvm-project?rev=317957&view=rev Log: 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. Modified: cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp Modified: cfe/trunk/lib/AST/StmtPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=317957&r1=317956&r2=317957&view=diff ============================================================================== --- cfe/trunk/lib/AST/StmtPrinter.cpp (original) +++ cfe/trunk/lib/AST/StmtPrinter.cpp Fri Nov 10 16:54:25 2017 @@ -2232,6 +2232,9 @@ void StmtPrinter::VisitLambdaExpr(Lambda CEnd = Node->explicit_capture_end(); C != CEnd; ++C) { + if (C->capturesVLAType()) + continue; + if (NeedComma) OS << ", "; NeedComma = true; Modified: cfe/trunk/lib/AST/StmtProfile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=317957&r1=317956&r2=317957&view=diff ============================================================================== --- cfe/trunk/lib/AST/StmtProfile.cpp (original) +++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Nov 10 16:54:25 2017 @@ -1590,6 +1590,9 @@ StmtProfiler::VisitLambdaExpr(const Lamb 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: Modified: cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp?rev=317957&r1=317956&r2=317957&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp Fri Nov 10 16:54:25 2017 @@ -55,4 +55,8 @@ struct B : A { ; // CHECK-NOT: ; +void g(int n) { + int buffer[n]; // CHECK: int buffer[n]; + [&buffer]() {}(); // CHECK: [&buffer] +} _______________________________________________ cfe-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
