]> granicus.if.org Git - clang/commitdiff
Handle lambda captures of variable length arrays in profiling and printing.
authorRichard Trieu <rtrieu@google.com>
Sat, 11 Nov 2017 00:54:25 +0000 (00:54 +0000)
committerRichard Trieu <rtrieu@google.com>
Sat, 11 Nov 2017 00:54:25 +0000 (00:54 +0000)
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

lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
test/SemaCXX/cxx11-ast-print.cpp

index 371d3e181d225293c1a4eeb2c669e37260c7d25b..09092743f0d2e0bd9f7b32c0b8e19cf13dfff962 100644 (file)
@@ -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;
index 9acd79bc2ca3bd2bea6dfcad69530d10c144f4c5..6cc77f682ee7b7c04e965d0916f68fbb0153a23e 100644 (file)
@@ -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:
index 9c617af4e95fd42409b18188cfc665dd0b09480f..17dcbcb3f7b00a11ca8f29788a184ef5fe796ac1 100644 (file)
@@ -55,4 +55,8 @@ struct B : A {
 ;
 // CHECK-NOT: ;
 
+void g(int n) {
+  int buffer[n];     // CHECK: int buffer[n];
+  [&buffer]() {}();  // CHECK: [&buffer]
+}