Skip to content

Clang-Format ignores disabled conditional preprocessor blocks #38603

Closed as not planned
@MarcusJohnson91

Description

@MarcusJohnson91
Bugzilla Link 39255
Version trunk
OS MacOS X

Extended Description

preprocessor blocks aren't formatted properly at all.

Example:

Before:

#if (defined(UNIX))
#define _FILE_OFFSET_BITS 64
#elif (defined _WIN32)
#define _UNICODE
#endif

After:
#if (defined(UNIX))

define _FILE_OFFSET_BITS 64

#elif (defined _WIN32)
#define _UNICODE
#endif

and let's say we're compiling on a UNIX platform, so the first branch of the preprocessor directive is enabled, but not the second.

Only the enabled block would actually be formatted, the disabled block is completely ignored.

I'm not sure if this is just because the formatter is running after the preprocessor, or if it's a lot deeper than that, and Clang is removing the unavailable preprocessor tokens before anyone else has access to it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang-formatobsoleteIssues with old (unsupported) versions of LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions