penagos created this revision.
penagos added reviewers: Saldivarcher, MyDeveloperDay, JakeMerdichAMD, krasimir.
penagos requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This serves to augment the improvements made in
https://reviews.llvm.org/D86581. It prevents clang-format from interpreting
bitshift operators as template arguments in certain circumstances.
Repository:
rG LLVM Github Monorepo
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,7 @@
verifyFormat("a<int> = 1;", Style);
verifyFormat("a<int> >>= 1;", Style);
+ verifyFormat("test < a - 1 >> 1;");
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;
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7649,6 +7649,7 @@
verifyFormat("a<int> = 1;", Style);
verifyFormat("a<int> >>= 1;", Style);
+ verifyFormat("test < a - 1 >> 1;");
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;
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits