diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2208,7 +2208,8 @@ } if (PreviousNotConst->is(tok::r_paren) && - PreviousNotConst->is(TT_TypeDeclarationParen)) { + (PreviousNotConst->is(TT_TypeDeclarationParen) || + PreviousNotConst->is(TT_AttributeParen))) { return true; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -16455,8 +16455,10 @@ verifyFormat("int f ();", SpaceFuncDecl); verifyFormat("void f(int a, T b) {}", SpaceFuncDecl); + verifyFormat("void __attribute__((asdf)) f(int a, T b) {}", SpaceFuncDecl); verifyFormat("A::A() : a(1) {}", SpaceFuncDecl); verifyFormat("void f () __attribute__((asdf));", SpaceFuncDecl); + verifyFormat("void __attribute__((asdf)) f ();", SpaceFuncDecl); verifyFormat("#define A(x) x", SpaceFuncDecl); verifyFormat("#define A (x) x", SpaceFuncDecl); verifyFormat("#if defined(x)\n" @@ -16490,8 +16492,10 @@ verifyFormat("int f();", SpaceFuncDef); verifyFormat("void f (int a, T b) {}", SpaceFuncDef); + verifyFormat("void __attribute__((asdf)) f (int a, T b) {}", SpaceFuncDef); verifyFormat("A::A() : a(1) {}", SpaceFuncDef); verifyFormat("void f() __attribute__((asdf));", SpaceFuncDef); + verifyFormat("void __attribute__((asdf)) f();", SpaceFuncDef); verifyFormat("#define A(x) x", SpaceFuncDef); verifyFormat("#define A (x) x", SpaceFuncDef); verifyFormat("#if defined(x)\n"