]> granicus.if.org Git - clang/commitdiff
clang-format: Add space in corner case.
authorDaniel Jasper <djasper@google.com>
Wed, 17 Jul 2013 20:25:02 +0000 (20:25 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 17 Jul 2013 20:25:02 +0000 (20:25 +0000)
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

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 021fd2488bbebe4ae0e56de4b9d8a182debc1506..97be71c277ee1ce46db235a57bb6394f2e63756d 100644 (file)
@@ -1151,6 +1151,10 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   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,
index 353fcc7d0bda3fa6efe0d522e8550b9094f4a9a7..05119f37cb1a876d1cf035933659128fb637ad0a 100644 (file)
@@ -3546,6 +3546,10 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   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...); }");