[all-commits] [llvm/llvm-project] 7af119: [clang-format] Fix short functions being considere...
Marek Kurdej via All-commits
all-commits at lists.llvm.org
Fri Jan 14 12:57:13 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7af11989be21df00ad6a510a831ea2425e48fa90
https://github.com/llvm/llvm-project/commit/7af11989be21df00ad6a510a831ea2425e48fa90
Author: Marek Kurdej <marek.kurdej+llvm.org at gmail.com>
Date: 2022-01-14 (Fri, 14 Jan 2022)
Changed paths:
M clang/lib/Format/UnwrappedLineFormatter.cpp
M clang/unittests/Format/FormatTest.cpp
M clang/unittests/Format/FormatTestCSharp.cpp
M clang/unittests/Format/FormatTestJava.cpp
Log Message:
-----------
[clang-format] Fix short functions being considered as inline inside an indented namespace.
Fixes https://github.com/llvm/llvm-project/issues/24784.
With config:
```
AllowShortFunctionsOnASingleLine: Inline
NamespaceIndentation: All
```
The code:
```
namespace Test
{
void f()
{
return;
}
}
```
was incorrectly formatted to:
```
namespace Test
{
void f() { return; }
}
```
since the function `f` was considered being inside a class/struct/record.
That's because the check was simplistic and only checked for a non-zero indentation level of the line starting `f`.
Reviewed By: MyDeveloperDay, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D117142
More information about the All-commits
mailing list