[PATCH] Clang-format: Fix for #pragma option formatting
Sergey Razmetov
razmser at yandex.ru
Tue Apr 21 22:36:10 PDT 2015
Fixed nitpicks.
If I understand right, in order to use Keywords object I must create new annotations for `#pragma mark` and `#pragma option`. I can do it, but I think that should be done in separate commit.
http://reviews.llvm.org/D8121
Files:
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -589,6 +589,14 @@
CurrentToken->Type = TT_ImplicitStringLiteral;
next();
}
+ } else if (CurrentToken && CurrentToken->TokenText == "option") {
+ next(); // Consume "option".
+ while (CurrentToken) {
+ // Don't add space after binary operator.
+ if (CurrentToken->Previous->Type == TT_BinaryOperator)
+ CurrentToken->Type = TT_ImplicitStringLiteral;
+ next();
+ }
}
}
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8795,6 +8795,12 @@
"(including parentheses)."));
}
+TEST_F(FormatTest, UnderstandPragmaOption) {
+ verifyFormat("#pragma option -C -A");
+
+ EXPECT_EQ("#pragma option -C -A", format("#pragma option -C -A"));
+}
+
#define EXPECT_ALL_STYLES_EQUAL(Styles) \
for (size_t i = 1; i < Styles.size(); ++i) \
EXPECT_EQ(Styles[0], Styles[i]) << "Style #" << i << " of " \
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8121.24197.patch
Type: text/x-patch
Size: 1300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150422/0883eb7b/attachment.bin>
More information about the cfe-commits
mailing list