[llvm-bugs] [Bug 50707] New: SplitEmptyRecord also affects whether to SplitEmptyFunction

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 14 09:28:28 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50707

            Bug ID: 50707
           Summary: SplitEmptyRecord also affects whether to
                    SplitEmptyFunction
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lichray at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 24952
  --> https://bugs.llvm.org/attachment.cgi?id=24952&action=edit
test case

Given the following .clang-format file:

---
BasedOnStyle: Microsoft
AccessModifierOffset: '-4'
AllowAllConstructorInitializersOnNextLine: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
AllowShortFunctionsOnASingleLine: Empty
BreakConstructorInitializers: AfterColon
ColumnLimit: '80'
Language: Cpp
Standard: Latest
BraceWrapping:
  SplitEmptyFunction: true
  SplitEmptyRecord: false

...

Long function bodies are not becoming
{
}

Expects (test.cc): --

class Short
{};

class Test
{
public:
    Test() :
        bEnabled(false),
        eDestination(eOutputDestination::file),
        uiMaxSize(DEFAULT_MAX_LOGGER_FILE_SIZE)
    {
    }

    void memFun(void *caller, std::function<int(char const *, char)> cb,
                std::tuple<bool, std::string> param)
    {
    }
};

void regularFun(void *caller, std::function<int(char const *, char)> cb,
                std::tuple<bool, std::string> param)
{
}

Got: --

class Short
{};

class Test
{
public:
    Test() :
        bEnabled(false),
        eDestination(eOutputDestination::file),
        uiMaxSize(DEFAULT_MAX_LOGGER_FILE_SIZE)
    {}

    void memFun(void *caller, std::function<int(char const *, char)> cb,
                std::tuple<bool, std::string> param)
    {}
};

void regularFun(void *caller, std::function<int(char const *, char)> cb,
                std::tuple<bool, std::string> param)
{}

Trying out all 4 combinations of SplitEmptyFunction and SplitEmptyRecord and
got a surprising result.

SplitEmptyFunction: false
SplitEmptyRecord: false
Good

SplitEmptyFunction: true
SplitEmptyRecord: false
Bad, same as above

SplitEmptyFunction: false
SplitEmptyRecord: true
Good

SplitEmptyFunction: true
SplitEmptyRecord: true
Good

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210614/9bda58bb/attachment.html>


More information about the llvm-bugs mailing list