clang-format: Add space in corner case.
Before:
SomeType s __attribute__((unused))(InitValue);
After:
SomeType s __attribute__((unused)) (InitValue);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186535 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 021fd24..97be71c 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -1151,6 +1151,10 @@
if (Left.is(tok::l_paren))
return false;
if (Right.is(tok::l_paren)) {
+ if (Left.is(tok::r_paren) && Left.MatchingParen &&
+ Left.MatchingParen->Previous &&
+ Left.MatchingParen->Previous->is(tok::kw___attribute))
+ return true;
return Line.Type == LT_ObjCDecl ||
Left.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
tok::kw_return, tok::kw_catch, tok::kw_new,
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 353fcc7..05119f3 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -3546,6 +3546,10 @@
verifyFormat("delete *x;", PointerLeft);
}
+TEST_F(FormatTest, UnderstandsAttributes) {
+ verifyFormat("SomeType s __attribute__((unused)) (InitValue);");
+}
+
TEST_F(FormatTest, UnderstandsEllipsis) {
verifyFormat("int printf(const char *fmt, ...);");
verifyFormat("template <class... Ts> void Foo(Ts... ts) { Foo(ts...); }");