[PATCH] D107961: [clang-format] Distinguish K&R C function definition and attribute

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 13 13:02:42 PDT 2021


owenpan added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1388
         break;
-      if (!Line->Tokens.begin()->Tok->is(tok::kw_typedef) &&
-          isC78ParameterDecl(FormatTok)) {
+      const FormatToken *Next = AllTokens[Tokens->getPosition() + 1];
+      if (Next && Next->isOneOf(tok::l_paren, tok::semi))
----------------
MyDeveloperDay wrote:
> Maybe?
Yep!


================
Comment at: clang/unittests/Format/FormatTest.cpp:8258
+  verifyFormat("bool f(int a, int) override;\n"
+               "Bar g(int a, Bar) final; // comment",
+               Style);
----------------
MyDeveloperDay wrote:
> can you check with out the comment and without a having a type (I know it shocking code) but just want to be sure.
> 
> ```
> Bar g(int a, Bar) final;
> Bar g(a, Bar) final;
> ```
Sure. Will also add a test case for the assertion failure.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107961/new/

https://reviews.llvm.org/D107961



More information about the cfe-commits mailing list