Skip to content

[clang-format] Regression: Include sorting is broken with backslashes in multiline comments. #109864

@Jhuighuy

Description

@Jhuighuy

Hi everyone,

The latest released clang-format (19.1.5) cannot sort includes and remove duplicates if those are preceded with /* */ comments containing backslashes.

clang-format 18.1.8 produces correct results.

The problem can be reproduced regardless of the presence or contents of .clang-format.

Example:

~ » cat a.cpp
/* COPYRIGHT *\
\* (C) 2024  */

#include <b>
#include <a>
#include <b>

~ » clang-format a.cpp
/* COPYRIGHT *\
\* (C) 2024  */

#include <b>
#include <a>
#include <b>

~ » cat b.cpp
/* COPYRIGHT *
 * (C) 2024  */

#include <b>
#include <a>
#include <b>

~ » clang-format b.cpp
/* COPYRIGHT *
 * (C) 2024  */

#include <a>
#include <b>

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions