LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 17363 - distinguish between indentation and alignment
Summary: distinguish between indentation and alignment
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Alexander Kornienko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-25 10:59 PDT by Trass3r
Modified: 2013-09-27 11:20 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Trass3r 2013-09-25 10:59:29 PDT
Currently tabs are poorly handled by just replacing X spaces with a tab.
Note that this even breaks the AlignTrailingComments+UseTab combination.

I use tabs for indentation and spaces for any remaining alignment.
That way everyone can use their preferred tab width setting and everything is still perfectly aligned and displayed consistently.

<tab>if (... &&   // bla
<tab>    ...)     // bla

or
<tab>callFoo(param1,
<tab>        param2)
Comment 1 Manuel Klimek 2013-09-26 07:06:22 PDT
Note that w agree that "replace 8 spaces with tabs" is insane, but unfortunately it's Linus Torvald's insanity, so we'll need to keep the current behavior, and implement the proposed behavior as an option.
Comment 2 Alexander Kornienko 2013-09-27 05:04:52 PDT
(In reply to comment #0)
> Note that this even breaks the AlignTrailingComments+UseTab combination.

This particular issue should be fixed in r191497.

We're thinking about implementing the rest of your proposal under a separate style option, because the current behavior is also sometimes desired (e.g. it's what Linux Kernel uses).
Comment 3 Alexander Kornienko 2013-09-27 11:20:37 PDT
As of r191529, clang-format understands UseTab: ForIndentation, which should do what you need. See http://clang.llvm.org/docs/ClangFormatStyleOptions.html for the description.