Skip to content

Using clang as CPP makes unexpected indentation changes #78778

@trini

Description

@trini

For background, over in U-Boot we use the same "Kconfig" language as the Linux kernel, and so have a config file for a build that is defined with CONFIG_FOO=y and # CONFIG_BAR is not set. What we're doing now is allowing for a config file to #include another valid config file fragment, and using $(CC) -E to handle the include directive.

When using GCC, this works as expected and nothing about the files is changed. However, with clang-16 # CONFIG_FOO is not set becomes # CONFIG_FOO is not set, which is invalid for the Kconfig language. I can pass in -traditional-cpp as another flag and in some cases this will keep the expected behavior, but in others, it does not.

I've put an example of what I'm doing at: https://gist.github.com/trini/a9fec05a1010611f287661e58b17cbd0 which shows the trivial case. Using the starfive_visionfive2_defconfig file as non-trivial testcase shows that even with -traditional-cpp we still get some whitespace changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions