[llvm-bugs] [Bug 50287] New: Preprocessor directives force inline functions to unfold

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 10 08:14:10 PDT 2021


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

            Bug ID: 50287
           Summary: Preprocessor directives force inline functions to
                    unfold
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: evg656e at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Steps to Reproduce:
1. Create style with `AllowShortFunctionsOnASingleLine` set to `Inline` or
`All`.
2. Create C++ file with following contents:
```cpp
struct Foo {
#ifdef FOO
#endif
    void foo() {}
};

#ifdef BAR
#endif
void bar() {}
```
3. Format file.

Actual Results:
```cpp
struct Foo {
#ifdef FOO
#endif
    void foo()
    {
    }
};

#ifdef BAR
#endif
void bar()
{
}
```

Expected Results:
```cpp
struct Foo {
#ifdef FOO
#endif
    void foo() {}
};

#ifdef BAR
#endif
void bar() {}
```

Additional Information:
Adding comment line between pp directive and function make clang-format behave
like intended

-- 
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/20210510/a512d569/attachment.html>


More information about the llvm-bugs mailing list