__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.
Patch by Strager Neds, thank you.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241439
91177308-0d34-0410-b5e6-
96231b3b80d8
if (Line.MustBeDeclaration && Contexts.size() == 1 &&
!Contexts.back().IsExpression && !Line.startsWith(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:
verifyFormat("SomeType s __attribute__((unused)) (InitValue);");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((unused))\n"
"aaaaaaaaaaaaaaaaaaaaaaa(int i);");
+ FormatStyle AfterType = getLLVMStyle();
+ AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+ verifyFormat("__attribute__((nodebug)) void\n"
+ "foo() {}\n",
+ AfterType);
}
TEST_F(FormatTest, UnderstandsEllipsis) {