[clang] 6e5082b - [clang-format] Fix build on gcc < 7 introduced in rG9363aa9.

Marek Kurdej via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 29 00:58:08 PDT 2021


Author: Marek Kurdej
Date: 2021-04-29T09:57:34+02:00
New Revision: 6e5082bbc498ab7d68178ea883203b38f6cd47fb

URL: https://github.com/llvm/llvm-project/commit/6e5082bbc498ab7d68178ea883203b38f6cd47fb
DIFF: https://github.com/llvm/llvm-project/commit/6e5082bbc498ab7d68178ea883203b38f6cd47fb.diff

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

This fixes a bogus build error on gcc, e.g. https://lab.llvm.org/buildbot/#/builders/110/builds/2973.

/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/clang/lib/Format/TokenAnnotator.cpp:3097:53: error: binding ‘const clang::SourceRange’ to reference of type ‘clang::SourceRange&’ discards qualifiers
   auto HasExistingWhitespace = [&Whitespace = Right.WhitespaceRange]() {
                                                     ^

Added: 
    

Modified: 
    clang/lib/Format/TokenAnnotator.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index f20640a1343d..3fe62bc4adc0 100755
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3094,8 +3094,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
 bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
                                          const FormatToken &Right) {
   const FormatToken &Left = *Right.Previous;
-  auto HasExistingWhitespace = [&Whitespace = Right.WhitespaceRange]() {
-    return Whitespace.getBegin() != Whitespace.getEnd();
+  auto HasExistingWhitespace = [&Right]() {
+    return Right.WhitespaceRange.getBegin() != Right.WhitespaceRange.getEnd();
   };
   if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo())
     return true; // Never ever merge two identifiers.


        


More information about the cfe-commits mailing list