| Issue |
203209
|
| Summary |
[clang-format] AllowShortFunctionsOnASingleLine: Inline does not for work member function inside namespace after preprocessor define
|
| Labels |
clang-format
|
| Assignees |
|
| Reporter |
CDAlexanderW
|
This may be a regression starting with v21.x
It seems that a member function with a preprocessor value define and a namespace changes the function body to not be a single line, but in an extra line. Have a look at ```Function1```
If you remove namespace or move the define the function stays single line
Problematic source code:
```c++
namespace NamespaceName
{
class ClassName
{
#define DEFINEMACROVALUE 1
int Function1() { return 1; }
};
}
namespace NamespaceName2
{
class ClassName2
{
int Function2() { return 1; }
};
}
class ClassName3
{
#define DEFINEMACROVALUE2 2
int Function3() { return 1; }
};
```
minimal repro .clang-format
```yaml
---
Language: Cpp
BraceWrapping:
AfterClass: true
AfterFunction: true
AfterNamespace: true
BreakBeforeBraces: Custom
ColumnLimit: 120
FixNamespaceComments: false
IndentWidth: 2
#relevant for repro
NamespaceIndentation: All
AllowShortFunctionsOnASingleLine: Inline
```
clang-format 20.1.8 does not change the format, so it looks exactly the same.
clang-format 21.1.7 & 22.1.3 & 22.1.7 do change the format to:
```c++
namespace NamespaceName
{
class ClassName
{
#define DEFINEMACROVALUE 1
int Function1()
{
return 1;
}
};
}
namespace NamespaceName2
{
class ClassName2
{
int Function2() { return 1; }
};
}
class ClassName3
{
#define DEFINEMACROVALUE2 2
int Function3() { return 1; }
};
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs