[PATCH] D108094: [clang-format] Improve detection of parameter declarations in K&R C

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 16 00:50:07 PDT 2021


MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1025
   if (!isC78Type(*Tok) &&
       !Tok->isOneOf(tok::kw_register, tok::kw_struct, tok::kw_union))
     return false;
----------------
should we have test cases showing these examples?


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1029
+  if (Next->isNot(tok::star) && !Next->Tok.getIdentifierInfo())
+    return false;
+
----------------
Can you add unit tests for these cases?


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1397
       assert(Position < AllTokens.size());
-      const FormatToken *Next = AllTokens[Position];
-      if (Next && Next->isOneOf(tok::l_paren, tok::semi))
-        break;
-      if (isC78ParameterDecl(FormatTok)) {
+      if (isC78ParameterDecl(FormatTok, AllTokens[Position], Previous)) {
         addUnwrappedLine();
----------------
Can't next be null once again?


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

https://reviews.llvm.org/D108094



More information about the cfe-commits mailing list