[cfe-dev] Doubts regarding clang-format

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Tue Apr 27 11:16:58 PDT 2021


On Tue, Apr 27, 2021 at 12:45 AM saloni goyal <saloniggoyal at gmail.com> wrote:
>
>
>
> On Tue, Apr 27, 2021 at 10:41 AM David Blaikie <dblaikie at gmail.com> wrote:
>>
>> On Mon, Apr 26, 2021 at 9:13 PM saloni goyal via cfe-dev
>> <cfe-dev at lists.llvm.org> wrote:
>>
> <snip>
>>
>>
>> > 2. For some comments the indent level should be more or the clang-format should accept some comment intend level as it.
>>
>> I guess clang-format already does some indent handling for comments (I
>> think it generally aligns it with the code/indent of the surrounding
>> elements) - so you might be able to modify the logic that chooses and
>> performs that comment indentation to do what you want?
>
>
> Basically there are some comments that are indented one level more than above line. So I want that these indented comments should not get aligned back with the above line, should remain one level indented. Can you please tell me the file name or path of the file in which these changes should be made so that I can get the desired results?

Sorry, I don't know where that is - if I were trying to figure it out
I'd create some code with an incorrect indentation, figure out the bit
of clang-format that actually makes changes to the code & set a
breakpoint in a debugger there to see when that's executed and walk
backwards up the stack to see what motivated the change which might
hopefully point to the indentation formatting. (but maybe there's too
much indirection there - perhaps clang-format does all the deciding,
builds a representation of what the code should look like, then runs
that to produce the output (so the intermediate representation would
be the thing you'd want to try to figure out how it's built) - maybe
searching through the code for words like 'comment' might help find
what you're looking for - not sure)

- Dave


More information about the cfe-dev mailing list