[PATCH] D90180: [clang-tidy] find/fix unneeded semicolon after switch

Tom Roeder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 26 12:17:02 PDT 2020


tmroeder added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp:25
         "linuxkernel-must-check-errs");
+    CheckFactories.registerCheck<SwitchSemiCheck>(
+        "linuxkernel-switch-semi");
----------------
Please fix the linter error, here and in the other cases.


================
Comment at: clang-tools-extra/clang-tidy/linuxkernel/SwitchSemiCheck.cpp:34
+      if (const auto *N = dyn_cast<NullStmt>(*Next)) {
+        if (!N->hasLeadingEmptyMacro() && S->getBody()->getEndLoc().isValid() &&
+            N->getSemiLoc().isValid()) {
----------------
nit: I could use a short comment about the reason for this check for hasLeadingEmptyMacro.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/linuxkernel-switch-semi.c:4-9
+  switch (a) {
+  case 1:
+    return 0;
+  default:
+    break;
+  };
----------------
Maybe also a test that shows that it doesn't apply to a normal switch statement (without the extra semicolon)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90180



More information about the cfe-commits mailing list