[PATCH] D142139: [clang-format] Disallow templates to be followed by literal
Emilia Dreamer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 19 10:19:40 PST 2023
rymiel updated this revision to Diff 490584.
rymiel added a comment.
Drop unrelated change
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142139/new/
https://reviews.llvm.org/D142139
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
@@ -10345,6 +10345,7 @@
// Not template parameters.
verifyFormat("return a < b && c > d;");
+ verifyFormat("a < 0 ? b : a > 0 ? c : d;");
verifyFormat("void f() {\n"
" while (a < b && c > d) {\n"
" }\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -185,6 +185,8 @@
} else {
CurrentToken->setType(TT_TemplateCloser);
}
+ if (CurrentToken->Next && CurrentToken->Next->Tok.isLiteral())
+ return false;
next();
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142139.490584.patch
Type: text/x-patch
Size: 884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230119/ac95f948/attachment.bin>
More information about the cfe-commits
mailing list