[PATCH] clang-format: Fix __attribute__ being treated as decl name.

strager strager.nds at gmail.com
Wed Jun 10 16:08:50 PDT 2015


Hi djasper,

__attribute__ was treated as the name of a function
definition, with the tokens in parentheses being the
parameter list. This formats incorrectly with
AlwaysBreakAfterDefinitionReturnType. Fix it by treating
__attribute__ like decltype.

http://reviews.llvm.org/D10373

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

Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -506,7 +506,8 @@
       if (Line.MustBeDeclaration && Contexts.size() == 1 &&
           !Contexts.back().IsExpression && Line.First->isNot(TT_ObjCProperty) &&
           (!Tok->Previous ||
-           !Tok->Previous->isOneOf(tok::kw_decltype, TT_LeadingJavaAnnotation)))
+           !Tok->Previous->isOneOf(tok::kw_decltype, tok::kw___attribute,
+                                   TT_LeadingJavaAnnotation)))
         Line.MightBeFunctionDecl = true;
       break;
     case tok::l_square:

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10373.27474.patch
Type: text/x-patch
Size: 668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150610/5f38b4ae/attachment.bin>


More information about the cfe-commits mailing list