`clang-format`sorts or groups namespaces in using declarations in a case-insensitive way
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`clang-format` seems to treat the namespaces in a series of using declarations in a case insensitive way.
For example, this code:
```cpp
namespace testing {
class A {};
class C {};
class E {};
}
namespace Testing {
class B {};
class D {};
}
using Testing::B;
using Testing::D;
using testing::A;
using testing::C;
using testing::E;
```
Is reformatted to this:
```cpp
namespace testing {
class A {};
class C {};
class E {};
} // namespace testing
namespace Testing {
class B {};
class D {};
} // namespace Testing
using testing::A;
using Testing::B;
using testing::C;
using Testing::D;
using testing::E;
```
Which I think is both surprising and makes reading more difficult.
It's not just a case insensitive sort though -- if you prefix `testing` with `::`, you get the same order from `clang-format`, interleaving `::testing::...` and `Testing::...` entries.
Contributor guide
Research direction
Start by reproducing the reported ordering with the clang-format example and inspect the clang-format code that sorts using declarations. Add a regression test for namespaces whose names differ only by case, then verify that formatting no longer interleaves them unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100