[clang] [Clang] improve -Wstring-concatenation to warn on every missing comma in initializer lists (PR #154018)

Richard Barnes via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 20 10:10:30 PDT 2025


r-barnes wrote:

We noticed false positives in our internal codebase as well, and used parens to fix them.

As expect, the warning also identified additional bugs.

I hope there will either be a flag that performs as expected (concatenation is bad unless it is explicitly marked as good) or a clang-tidy to capture the same effect. It seems perverse to rely on indentation and project formatting to signal safety, as many of the above false positives do. 

This reminds me of implicit fallthroughs where projects used [many inconsistent variants](https://lwn.net/Articles/794944/) of `// fallthrough` to indicate intentional fallthrough. While GCC's flags allowed this diversity to persist clang, wisely, require use of the standard `[[fallthrough]]`.

Here there are many ways to signal intended concatenation, but they all rely on fallible human inspection to determine that they're fine. I don't think it's good to rely on visual inspection.

clang-tidy is less desirable from our perspective because it is often a retroactive catch rather than an immediate catch.

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


More information about the cfe-commits mailing list