[clang] 31751ce - [clang-format] Fix build on gcc < 7 introduced in rG8d93d7ff.

Marek Kurdej via cfe-commits cfe-commits at lists.llvm.org
Mon May 3 09:54:10 PDT 2021


Author: Marek Kurdej
Date: 2021-05-03T18:52:41+02:00
New Revision: 31751ce1b9239d7aacac84864bf06c36ce888408

URL: https://github.com/llvm/llvm-project/commit/31751ce1b9239d7aacac84864bf06c36ce888408
DIFF: https://github.com/llvm/llvm-project/commit/31751ce1b9239d7aacac84864bf06c36ce888408.diff

LOG: [clang-format] Fix build on gcc < 7 introduced in rG8d93d7ff.

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 {
                                          ^

Added: 
    

Modified: 
    clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 8d1694fe4b44..2b1b15de8bbf 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -421,7 +421,8 @@ class LineJoiner {
       }
       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;
 


        


More information about the cfe-commits mailing list