[llvm-bugs] [Bug 50243] New: [clang-format] Misformatted initializion list with preprocessor directives

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 6 05:57:57 PDT 2021


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

            Bug ID: 50243
           Summary: [clang-format] Misformatted initializion list with
                    preprocessor directives
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: curdeius at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

That's somehow related to https://llvm.org/PR31427.

It seems that in the presence of preprocessor directives, the braces in the
ctor's initialization list are considered to be braces that start the function
body scope.

With default LLVM style:
```
class Sok
{
    Sok()
        : i{0}
    {}
};

// actual:
class Sbad
{
    Sbad()
#ifdef X
        : i
    {
        0
    }
#else
        : i
    {
        1
    }
#endif
    {}
};

/* expected:
class Sbad
{
    Sbad()
#ifdef X
        : i{0}
#else
        : i{1}
#endif
    {}
};
*/
```

-- 
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/20210506/05ba0981/attachment.html>


More information about the llvm-bugs mailing list