[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators
Luis Penagos via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 19 14:45:58 PDT 2021
penagos updated this revision to Diff 338648.
penagos added a comment.
Update Format test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100778/new/
https://reviews.llvm.org/D100778
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,6 +7649,8 @@
verifyFormat("a<int> = 1;", Style);
verifyFormat("a<int> >>= 1;", Style);
+ verifyFormat("test < a | b >> c;");
+ verifyFormat("test<test<a | b>> c;");
verifyFormat("test >> a >> b;");
verifyFormat("test << a >> b;");
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -119,7 +119,10 @@
// a statement.
if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
Left->ParentBracket != tok::less &&
- isKeywordWithCondition(*Line.First))
+ (isKeywordWithCondition(*Line.First) ||
+ CurrentToken->getStartOfNonWhitespace() ==
+ CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
return false;
Left->MatchingParen = CurrentToken;
CurrentToken->MatchingParen = Left;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100778.338648.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210419/edcdc313/attachment.bin>
More information about the cfe-commits
mailing list