Skip to content

[clang-format] Allow excluding preproccesor directives from IntegerLiteralSeparator #161848

@Alunderin

Description

@Alunderin

Given the config

IntegerLiteralSeparator:
    Decimal:                3
    DecimalMinDigits:       5

all numbers, including numbers inside of preprocessor directives, will have separators inserted:

#if __cpp_constexpr >= 201'603L  // i.e 2016-03

I believe that there is a legitimate use-case for wanting directives to be left as-is, e.g. for feature testing (like above) or if someone wanted to use a C99 preprocessor for their C23/C++14 code.


I was thinking the option for it could look something like this:

IntegerLiteralSeparator:
    Decimal:                3
    DecimalMinDigits:       5
    PPDirectives:           true

One could also consider something more fine-grained like Always/Never/Leave, although I can't imagine that being very beneficial.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions