[clang-tools-extra] [clang-tidy] Fix false positive in `bugprone-std-namespace-modification` when opening subnamespaces of `std::` (PR #174170)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 4 13:31:58 PST 2026


localspook wrote:

I don't completely follow what you mean, so I want to make sure we're on the same page.

> I think we should strictly follow "allowed cases" from https://en.cppreference.com/w/cpp/language/extending_std.html, which include some modifications of ranges but say nothing about chrono.

There's a rule that users are allowed to specialize any standard library class template, as long as the specialization depends on a user-defined type. That means users *are* allowed to modify `chrono`. For example, [`clock_time_conversion`](https://en.cppreference.com/w/cpp/chrono/clock_time_conversion.html) is made to be specialized.

> I can't imagine why someone would just open std namespace without any declarations in it

They would want to open it to add specializations, which (I guess) aren't considered declarations.

I'm not sure if that clears things up. If it doesn't, do say so!

https://github.com/llvm/llvm-project/pull/174170


More information about the cfe-commits mailing list