[clang-format] Fix build on gcc < 7 introduced in rG8d93d7ff.
authorMarek Kurdej <marek.kurdej+llvm.org@gmail.com>
Mon, 3 May 2021 16:52:19 +0000 (18:52 +0200)
committerMarek Kurdej <marek.kurdej+llvm.org@gmail.com>
Mon, 3 May 2021 16:52:41 +0000 (18:52 +0200)
This fixes another bogus build error on gcc, e.g. https://lab.llvm.org/buildbot/#/builders/118/builds/2504.

/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux-perf/llvm/clang/lib/Format/UnwrappedLineFormatter.cpp:424:42: error: binding ‘clang::format::FormatToken* const’ to reference of type ‘clang::format::FormatToken*&’ discards qualifiers
     auto IsElseLine = [&First = TheLine->First]() -> bool {
                                          ^

clang/lib/Format/UnwrappedLineFormatter.cpp

index 8d1694f..2b1b15d 100644 (file)
@@ -421,7 +421,8 @@ private:
       }
       return MergedLines;
     }
-    auto IsElseLine = [&First = TheLine->First]() -> bool {
+    auto IsElseLine = [&TheLine]() -> bool {
+      const FormatToken *First = TheLine->First;
       if (First->is(tok::kw_else))
         return true;