[PATCH] D95479: [clang-format] Avoid considering include directive as a template closer.
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 27 00:15:41 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe3713f156b8c: [clang-format] Avoid considering include directive as a template closer. (authored by curdeius).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95479/new/
https://reviews.llvm.org/D95479
Files:
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10248,6 +10248,21 @@
"{\n"
"};",
Style);
+
+ verifyFormat("#include \"stdint.h\"\n"
+ "namespace rep {}",
+ Style);
+ verifyFormat("#include <stdint.h>\n"
+ "namespace rep {}",
+ Style);
+ verifyFormat("#include <stdint.h>\n"
+ "namespace rep {}",
+ "#include <stdint.h>\n"
+ "namespace rep {\n"
+ "\n"
+ "\n"
+ "}",
+ Style);
}
TEST_F(FormatTest, SplitEmptyStruct) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -371,7 +371,7 @@
if (Previous->is(tok::comment))
Previous = Previous->getPreviousNonComment();
if (Previous) {
- if (Previous->is(tok::greater))
+ if (Previous->is(tok::greater) && !I[-1]->InPPDirective)
return 0;
if (Previous->is(tok::identifier)) {
const FormatToken *PreviousPrevious =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95479.319482.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210127/4a8320f8/attachment.bin>
More information about the cfe-commits
mailing list