Skip to content

Sort includes pass will sort inside raw strings #48642

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 49298
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

clang-format does not respect raw string literals when sorting includes

Take this snippet:

const char *RawStr = R"(
#include "headerB.h"
#include "headerA.h"
)";

Running clang-format over with SortIncludes enabled transforms this code to:

const char *RawStr = R"(
#include "headerA.h"
#include "headerB.h"
)";

The formatter should not sort these includes as they are part of a raw string without a language delimiter.

The cause for this is pretty obvious, the include sorter runs without parsing the code, so it can't see that include tokens should actually be part of a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions