diff options
Diffstat (limited to 'include/clang/Format/Format.h')
-rw-r--r-- | include/clang/Format/Format.h | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h index 1891c06eba512..c1b62477ed1c6 100644 --- a/include/clang/Format/Format.h +++ b/include/clang/Format/Format.h @@ -184,9 +184,23 @@ struct FormatStyle { enum ShortFunctionStyle { /// \brief Never merge functions into a single line. SFS_None, + /// \brief Only merge functions defined inside a class. Same as "inline", + /// except it does not implies "empty": i.e. top level empty functions + /// are not merged either. + /// \code + /// class Foo { + /// void f() { foo(); } + /// }; + /// void f() { + /// foo(); + /// } + /// void f() { + /// } + /// \endcode + SFS_InlineOnly, /// \brief Only merge empty functions. /// \code - /// void f() { bar(); } + /// void f() {} /// void f2() { /// bar2(); /// } @@ -197,6 +211,10 @@ struct FormatStyle { /// class Foo { /// void f() { foo(); } /// }; + /// void f() { + /// foo(); + /// } + /// void f() {} /// \endcode SFS_Inline, /// \brief Merge all functions fitting on a single line. @@ -634,12 +652,12 @@ struct FormatStyle { /// struct foo /// { /// int x; - /// } + /// }; /// /// false: /// struct foo { /// int x; - /// } + /// }; /// \endcode bool AfterStruct; /// \brief Wrap union definitions. @@ -715,7 +733,7 @@ struct FormatStyle { /// ? firstValue /// : SecondValueVeryVeryVeryVeryLong; /// - /// true: + /// false: /// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ? /// firstValue : /// SecondValueVeryVeryVeryVeryLong; @@ -723,8 +741,7 @@ struct FormatStyle { bool BreakBeforeTernaryOperators; /// \brief Different ways to break initializers. - enum BreakConstructorInitializersStyle - { + enum BreakConstructorInitializersStyle { /// Break constructor initializers before the colon and after the commas. /// \code /// Constructor() @@ -749,7 +766,7 @@ struct FormatStyle { BCIS_AfterColon }; - /// \brief The constructor initializers style to use.. + /// \brief The constructor initializers style to use. BreakConstructorInitializersStyle BreakConstructorInitializers; /// \brief Break after each annotation on a field in Java files. @@ -1253,6 +1270,14 @@ struct FormatStyle { /// \endcode bool SortIncludes; + /// \brief If ``true``, clang-format will sort using declarations. + /// \code + /// false: true: + /// using std::cout; vs. using std::cin; + /// using std::cin; using std::cout; + /// \endcode + bool SortUsingDeclarations; + /// \brief If ``true``, a space is inserted after C style casts. /// \code /// true: false: @@ -1641,6 +1666,16 @@ tooling::Replacements fixNamespaceEndComments(const FormatStyle &Style, ArrayRef<tooling::Range> Ranges, StringRef FileName = "<stdin>"); +/// \brief Sort consecutive using declarations in the given \p Ranges in +/// \p Code. +/// +/// Returns the ``Replacements`` that sort the using declarations in all +/// \p Ranges in \p Code. +tooling::Replacements sortUsingDeclarations(const FormatStyle &Style, + StringRef Code, + ArrayRef<tooling::Range> Ranges, + StringRef FileName = "<stdin>"); + /// \brief Returns the ``LangOpts`` that the formatter expects you to set. /// /// \param Style determines specific settings for lexing mode. |