Skip to content

[clang-format] Breaking too long module name breaks compilation #193676

@ChuanqiXu9

Description

@ChuanqiXu9

Reproducer:

export module a.dwaldjlaiwjdwiajdilawjdliwajdlwajdlwajdijawldjawljdlwajdlawjdlajhwldijawildjwalidjawlijdlwaijdilawjdilwajdilwahgfliuehluksebvilu;

And let's format it:

$ bin/clang-format  a.cppm -i
$ cat a.cppm
export module a
    .dwaldjlaiwjdwiajdilawjdliwajdlwajdlwajdijawldjawljdlwajdlawjdlajhwldijawildjwalidjawlijdlwaijdilawjdilwajdilwahgfliuehluksebvilu;

then clang will reject it: https://godbolt.org/z/T1z49caj8

error: unexpected preprocessing token '.' after module name, only ';' and '[' (start of attribute specifier sequence) are allowed

This is somewhat problematic as in practice it is possible to have long module name. (It is annoying to say "ISO C++ disallows long module name".

And I am not sure how can we fix this. Should we ask clang-format to not format module name?

BTW, import a long module name seems to have a similar problem.

Metadata

Metadata

Labels

clang-formatinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compiles

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions