clang 24.0.0git
clang::format::FormatStyle::ShortFunctionStyle Struct Reference

Different styles for merging short functions containing at most one statement. More...

#include "clang/Format/Format.h"

Public Member Functions

bool operator== (const ShortFunctionStyle &R) const
bool operator!= (const ShortFunctionStyle &R) const
 ShortFunctionStyle ()
 ShortFunctionStyle (bool Empty, bool Inline, bool Other)
bool isAll () const

Static Public Member Functions

static ShortFunctionStyle setEmptyOnly ()
static ShortFunctionStyle setEmptyAndInline ()
static ShortFunctionStyle setInlineOnly ()
static ShortFunctionStyle setAll ()

Public Attributes

bool Empty
 Merge top-level empty functions.
bool Inline
 Merge functions defined inside a class.
bool Other
 Merge all functions fitting on a single line.

Detailed Description

Different styles for merging short functions containing at most one statement.

They can be read as a whole for compatibility. The choices are:

  • None Never merge functions into a single line.
  • InlineOnly 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. See Inline of ShortFunctionStyle.
    class Foo {
    void f() { foo(); }
    };
    void f() {
    foo();
    }
    void f() {
    }
  • Empty Only merge empty functions. See Empty of ShortFunctionStyle.
    void f() {}
    void f2() {
    bar2();
    }
  • Inline Only merge functions defined inside a class. Implies empty. See Inline and Empty of ShortFunctionStyle.
    class Foo {
    void f() { foo(); }
    };
    void f() {
    foo();
    }
    void f() {}
  • All Merge all functions fitting on a single line.
    class Foo {
    void f() { foo(); }
    };
    void f() { bar(); }

Also can be specified as a nested configuration flag:

# Example of usage:
AllowShortFunctionsOnASingleLine: InlineOnly
# or more granular control:
AllowShortFunctionsOnASingleLine:
Empty: false
Inline: true
Other: false

Definition at line 898 of file Format.h.

Constructor & Destructor Documentation

◆ ShortFunctionStyle() [1/2]

clang::format::FormatStyle::ShortFunctionStyle::ShortFunctionStyle ( )
inline

Definition at line 935 of file Format.h.

References Empty, false, Inline, and Other.

Referenced by operator!=(), operator==(), setAll(), setEmptyAndInline(), setEmptyOnly(), and setInlineOnly().

◆ ShortFunctionStyle() [2/2]

clang::format::FormatStyle::ShortFunctionStyle::ShortFunctionStyle ( bool Empty,
bool Inline,
bool Other )
inline

Definition at line 936 of file Format.h.

References Empty, Inline, and Other.

Member Function Documentation

◆ isAll()

bool clang::format::FormatStyle::ShortFunctionStyle::isAll ( ) const
inline

Definition at line 938 of file Format.h.

References Empty, Inline, and Other.

◆ operator!=()

bool clang::format::FormatStyle::ShortFunctionStyle::operator!= ( const ShortFunctionStyle & R) const
inline

Definition at line 934 of file Format.h.

References ShortFunctionStyle().

◆ operator==()

bool clang::format::FormatStyle::ShortFunctionStyle::operator== ( const ShortFunctionStyle & R) const
inline

Definition at line 931 of file Format.h.

References Empty, Inline, Other, and ShortFunctionStyle().

◆ setAll()

ShortFunctionStyle clang::format::FormatStyle::ShortFunctionStyle::setAll ( )
inlinestatic

Definition at line 948 of file Format.h.

References ShortFunctionStyle().

Referenced by clang::format::getLLVMStyle().

◆ setEmptyAndInline()

ShortFunctionStyle clang::format::FormatStyle::ShortFunctionStyle::setEmptyAndInline ( )
inlinestatic

Definition at line 942 of file Format.h.

References ShortFunctionStyle().

Referenced by clang::format::getChromiumStyle(), and clang::format::getMozillaStyle().

◆ setEmptyOnly()

ShortFunctionStyle clang::format::FormatStyle::ShortFunctionStyle::setEmptyOnly ( )
inlinestatic

Definition at line 939 of file Format.h.

References ShortFunctionStyle().

Referenced by clang::format::getGoogleStyle().

◆ setInlineOnly()

ShortFunctionStyle clang::format::FormatStyle::ShortFunctionStyle::setInlineOnly ( )
inlinestatic

Definition at line 945 of file Format.h.

References ShortFunctionStyle().

Member Data Documentation

◆ Empty

bool clang::format::FormatStyle::ShortFunctionStyle::Empty

Merge top-level empty functions.

void f() {}
void f2() {
bar2();
}
void f3() { /* comment */ }

Definition at line 907 of file Format.h.

Referenced by isAll(), operator==(), ShortFunctionStyle(), and ShortFunctionStyle().

◆ Inline

bool clang::format::FormatStyle::ShortFunctionStyle::Inline

Merge functions defined inside a class.

class Foo {
void f() { foo(); }
void g() {}
};
void f() {
foo();
}
void f() {
}

Definition at line 920 of file Format.h.

Referenced by isAll(), operator==(), ShortFunctionStyle(), and ShortFunctionStyle().

◆ Other

bool clang::format::FormatStyle::ShortFunctionStyle::Other

Merge all functions fitting on a single line.

Please note that this control does not include Empty

class Foo {
void f() { foo(); }
};
void f() { bar(); }

Definition at line 929 of file Format.h.

Referenced by isAll(), operator==(), ShortFunctionStyle(), and ShortFunctionStyle().


The documentation for this struct was generated from the following file: