[clang-tidy] Format code around applied fixes
Summary:
Add -format option (disabled by default for now) to trigger formatting
of replacements.
Reviewers: ioeric
Reviewed By: ioeric
Subscribers: kimgr, malcolm.parsons, JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D30564
llvm-svn: 296864
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index b6684d0..4dc86e1 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -60,7 +60,7 @@
prefix add checks with matching names to the
set, globs with the '-' prefix remove checks
with matching names from the set of enabled
-checks. This option's value is appended to the
+checks. This option's value is appended to the
value of the 'Checks' option in .clang-tidy
file, if any.
)"),
@@ -120,12 +120,20 @@
)"),
cl::init(false), cl::cat(ClangTidyCategory));
-static cl::opt<std::string> FormatStyle("style", cl::desc(R"(
-Fallback style for reformatting after inserting fixes
-if there is no clang-format config file found.
+static cl::opt<std::string> FormatStyle("format-style", cl::desc(R"(
+Style for formatting code around applied fixes:
+ - 'none' (default) turns off formatting
+ - 'file' (literally 'file', not a placeholder)
+ uses .clang-format file in the closest parent
+ directory
+ - '{ <json> }' specifies options inline, e.g.
+ -format-style='{BasedOnStyle: llvm, IndentWidth: 8}'
+ - 'llvm', 'google', 'webkit', 'mozilla'
+See clang-format documentation for the up-to-date
+information about formatting styles and options.
)"),
- cl::init("llvm"),
- cl::cat(ClangTidyCategory));
+ cl::init("none"),
+ cl::cat(ClangTidyCategory));
static cl::opt<bool> ListChecks("list-checks", cl::desc(R"(
List all enabled checks and exit. Use with
@@ -189,7 +197,7 @@
cl::cat(ClangTidyCategory));
static cl::opt<bool> Quiet("quiet", cl::desc(R"(
-Run clang-tidy in quiet mode. This suppresses
+Run clang-tidy in quiet mode. This suppresses
printing statistics about ignored warnings and
warnings treated as errors if the respective
options are specified.