[PATCH] D63085: Provide a fix-it hint for -Wswitch, which adds missing cases. If there are >3 cases, the inserted text will contain newlines so it will not be shown in console output (but will be applied by -fixit, available to libclang and clangd, etc).

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 00:58:28 PDT 2019


ilya-biryukov added a comment.

One major drawback that I see is the lack of indentation (and other format options) in the added code.
Should we have this fix at a higher level that can have formatting (either now or in the future)? E.g. in `clangd` directly?



================
Comment at: lib/Sema/SemaStmt.cpp:1208
+        llvm::raw_string_ostream NewCasesOS(NewCases);
+        // Include \n to separate new cases added if there are many.
+        // This suppresses printing the (long) insert text.
----------------
Maybe always put each `case` on a new line?
>From my experience, having multiple cases on the same line is not very common.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63085





More information about the cfe-commits mailing list