[PATCH] D135466: [clang-format] Add support to remove unnecessary semicolons after function definition

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 7 10:27:10 PDT 2022


MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: HazardyKnusperkeks, owenpan, curdeius, rymiel, Eugene.Zelenko.
MyDeveloperDay added projects: clang, clang-format.
Herald added a project: All.
MyDeveloperDay requested review of this revision.

Fixes: #58217

This change is to remove extraneous and unnecessary ';' from after a function declaration, its off by default and carries the same "code modification" warning as some of our other code manipulating changes.

  int max(int a, int b)
  {
      return a>b?a:b;
  };
  
  class Foo
  {
      int getSomething() const { return something; };
  };

At first, I thought this was a minor problem and not worth anything other than using `-Wextra-semi/-Wextra-semi-stmt` as pointed out in the issue comments. But clang-format is used by people who may not use the clang compiler, and not all compilers have this extra semi warning (AFAIK)

However, I ran this over the clang-codebase and realized (in clang and even the clang-format Tests!) how prevalent this is.

This is implemented very much on the same lines as @owenpan does for removing the `{}` with RemoveBracesLLVM, there is some repeated code that we could rationalize down if accepted. (I didn't want to be too invasive on that work)

This is definitely one of those changes that it would be nice for those of us that use "clang-format on save" could get without having to go through a compile phase in order to catch the warnings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135466

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135466.466115.patch
Type: text/x-patch
Size: 10528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221007/1101ccb6/attachment-0001.bin>


More information about the cfe-commits mailing list