[clang] [clang-format] Don't break module names (PR #193834)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 25 12:16:35 PDT 2026


HazardyKnusperkeks wrote:

> > We have the line type for import, I think we should use it.
> 
> Looks like `LT_ImportStatement` is for Objective-C `#import` directive and JavaScript `import` statement.

Yes, because C++ didn't have those back in the days. Now we have.

I can agree that the question if a line break is allowed at all (but maybe not on all places?) is open to debate. As far as I understand the draft the C++ standard does not impose that limitation, but reality is that GCC doesn't accept it, and clang in recent versions too. So we have the possibility to break real world usage.

If a line break is allowed, we have to take the route with annotating and setting the canbreak, etc. which was actually my first approach.

But if we decide a line break is not allowed, I think the import statement type is really neat, because it already does what we need and we don't need all the state checking if breaking or not, it always goes the route of no breaking.

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


More information about the cfe-commits mailing list