From 4e65c98f67b80a7f85ecd5b550a5e10a834f702c Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Mon, 2 Sep 2013 16:39:23 +0000 Subject: [PATCH] Added WebKit style to the BasedOnStyle handling and to the relevant help messages. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189765 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ClangFormat.rst | 7 ++++--- lib/Format/Format.cpp | 3 ++- tools/clang-format/ClangFormat.cpp | 2 +- tools/clang-format/clang-format-diff.py | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/ClangFormat.rst b/docs/ClangFormat.rst index 489b9b71b1..b932007dd7 100644 --- a/docs/ClangFormat.rst +++ b/docs/ClangFormat.rst @@ -54,7 +54,7 @@ to format C/C++/Obj-C code. Can only be used with one input file. -output-replacements-xml - Output replacements as XML. -style= - Coding style, currently supports: - LLVM, Google, Chromium, Mozilla. + LLVM, Google, Chromium, Mozilla, WebKit. Use -style=file to load style configuration from .clang-format file located in one of the parent directories of the source file (or current @@ -139,12 +139,13 @@ a unified diff and reformats all contained lines with :program:`clang-format`. usage: clang-format-diff.py [-h] [-p P] [-style STYLE] - Reformat changed lines in diff + Reformat changed lines in diff. optional arguments: -h, --help show this help message and exit -p P strip the smallest prefix containing P slashes - -style STYLE formatting style to apply (LLVM, Google, Chromium) + -style STYLE formatting style to apply (LLVM, Google, Chromium, Mozilla, + WebKit) So to reformat all the lines in the latest :program:`git` commit, just do: diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 39d2c0f96c..76e6faa40c 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -68,7 +68,8 @@ struct ScalarEnumerationTraits< template <> struct MappingTraits { static void mapping(llvm::yaml::IO &IO, clang::format::FormatStyle &Style) { if (IO.outputting()) { - StringRef StylesArray[] = { "LLVM", "Google", "Chromium", "Mozilla" }; + StringRef StylesArray[] = { "LLVM", "Google", "Chromium", + "Mozilla", "WebKit" }; ArrayRef Styles(StylesArray); for (size_t i = 0, e = Styles.size(); i < e; ++i) { StringRef StyleName(Styles[i]); diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp index cd28c595fd..2d415b358f 100644 --- a/tools/clang-format/ClangFormat.cpp +++ b/tools/clang-format/ClangFormat.cpp @@ -64,7 +64,7 @@ LineRanges("lines", cl::desc(": - format a range of\n" static cl::opt Style("style", cl::desc("Coding style, currently supports:\n" - " LLVM, Google, Chromium, Mozilla.\n" + " LLVM, Google, Chromium, Mozilla, WebKit.\n" "Use -style=file to load style configuration from\n" ".clang-format file located in one of the parent\n" "directories of the source file (or current\n" diff --git a/tools/clang-format/clang-format-diff.py b/tools/clang-format/clang-format-diff.py index bb18730b63..89fa0521ee 100755 --- a/tools/clang-format/clang-format-diff.py +++ b/tools/clang-format/clang-format-diff.py @@ -82,11 +82,13 @@ def formatRange(r, style): def main(): parser = argparse.ArgumentParser(description= - 'Reformat changed lines in diff') + 'Reformat changed lines in diff.') parser.add_argument('-p', default=0, help='strip the smallest prefix containing P slashes') - parser.add_argument('-style', - help='formatting style to apply (LLVM, Google, Chromium)') + parser.add_argument( + '-style', + help= + 'formatting style to apply (LLVM, Google, Chromium, Mozilla, WebKit)') args = parser.parse_args() filename = None -- 2.40.0