arichardson created this revision. arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, curdeius. Herald added a project: clang. Herald added a subscriber: cfe-commits. arichardson requested review of this revision.
Before: void f() { MACRO(A * __attribute((foo)) a); } After: void f() { MACRO(A *__attribute((foo)) a); } Also check that the __attribute__ alias is handled. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D86711 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8059,6 +8059,8 @@ verifyIndependentOfContext("MACRO(A *volatile a);"); verifyIndependentOfContext("MACRO(A *__volatile a);"); verifyIndependentOfContext("MACRO(A *__volatile__ a);"); + verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);"); + verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);"); verifyIndependentOfContext("MACRO('0' <= c && c <= '9');"); verifyFormat("void f() { f(float{1}, a * a); }"); // FIXME: Is there a way to make this work? Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1892,7 +1892,7 @@ if (!NextToken || NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const, tok::kw_restrict, tok::kw_volatile, - tok::kw_noexcept) || + tok::kw___attribute, tok::kw_noexcept) || (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment())) return TT_PointerOrReference;
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8059,6 +8059,8 @@ verifyIndependentOfContext("MACRO(A *volatile a);"); verifyIndependentOfContext("MACRO(A *__volatile a);"); verifyIndependentOfContext("MACRO(A *__volatile__ a);"); + verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);"); + verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);"); verifyIndependentOfContext("MACRO('0' <= c && c <= '9');"); verifyFormat("void f() { f(float{1}, a * a); }"); // FIXME: Is there a way to make this work? Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1892,7 +1892,7 @@ if (!NextToken || NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const, tok::kw_restrict, tok::kw_volatile, - tok::kw_noexcept) || + tok::kw___attribute, tok::kw_noexcept) || (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment())) return TT_PointerOrReference;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits