Skip to content

[ClangFormat] Adjusting Include Order for Main Headers by Prefix Match #118002

@thirumurugan-git

Description

@thirumurugan-git

Does the IncludeIsMainRegex option in the Clang format file only search for the suffix in the header stem? Is there an option to check the header prefix to identify it as "not a main file"? For example, consider the following code:

// file: a.cc
#include "b.h"
#include "../a.h"

// some code

When formatting this, a.h is prioritized as 0 (default) and always appears first. However, I want it to be placed last. Does Clang-Format support any option in the .clang-format file to address this, or would I need to use clang-off for the include section?

Note: The include must retain the relative path. Alternate approaches are not feasible. Could such an option be introduced in the future?"

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-formatquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions