Skip to content

Add option to IndentPPDirectives to respect indentation of context #35368

@aardappel

Description

@aardappel
Bugzilla Link 36020
Version trunk
OS All

Extended Description

With IndentPPDirectives: AfterHash, preprocessor directives are indented, but only relative to other preprocessor directives, not to the surrounding code. So code that is intended to look like:

void foo() {
    if (bar) {
        A;
#       ifdef D
#           define E
            B;
#       endif
        C;
    }
}

is clang-formatted to:

void foo() {
    if (bar) {
        A;
#ifdef D
#    define E
        B;
#endif
        C;
    }
}

This is a follow-up from bug #17736
Related feature: llvm/llvm-bugzilla-archive#36019

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