HomePhabricator

[clang-format] Add IndentPragma style to eliminate common clang-format off…
Concern Raisede9e6e3b34a8e

Authored by MyDeveloperDay on Dec 10 2020, 3:17 AM.

Description

[clang-format] Add IndentPragma style to eliminate common clang-format off scenario

A quick search of github.com, shows one common scenario for excessive use of //clang-format off/on is the indentation of #pragma's, especially around the areas of loop optimization or OpenMP

This revision aims to help that by introducing an IndentPragmas style, the aim of which is to keep the pragma at the current level of scope

    for (int i = 0; i < 5; i++) {
// clang-format off
        #pragma HLS UNROLL
        // clang-format on
        for (int j = 0; j < 5; j++) {
// clang-format off
            #pragma HLS UNROLL
            // clang-format on
     ....

can become

for (int i = 0; i < 5; i++) {
    #pragma HLS UNROLL
    for (int j = 0; j < 5; j++) {
        #pragma HLS UNROLL
    ....

This revision also support working alongside the IndentPPDirective of BeforeHash and AfterHash (see unit tests for examples)

Reviewed By: curdeius

Differential Revision: https://reviews.llvm.org/D92753

Event Timeline

RatTac raised a concern with this commit.Jan 7 2021, 2:45 AM
RatTac added a subscriber: RatTac.
This comment was removed by RatTac.
This commit now has outstanding concerns.Jan 7 2021, 2:45 AM

@RatTac Would you please consider copying the comment onto the review D92753: [clang-format] Add IndentPragma style to eliminate common clang-format off scenario and not the commit, I have a reply but don't want to write it here.

@RatTac Would you please consider copying the comment onto the review D92753: [clang-format] Add IndentPragma style to eliminate common clang-format off scenario and not the commit, I have a reply but don't want to write it here.

@MyDeveloperDay: Thx, I moved the comment according to your request