This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix tabs when using BreakBeforeTernaryOperators=false.
ClosedPublic

Authored by curdeius on Dec 15 2021, 7:45 AM.

Details

Summary

Fixes https://github.com/llvm/llvm-project/issues/52724.

This is rather a workaround than a correct fix. To properly fix it, we'd need to find a better way to tell when not to decrease the StartOfTokenColumn.

Diff Detail

Unit TestsFailed

Event Timeline

curdeius requested review of this revision.Dec 15 2021, 7:45 AM
curdeius created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2021, 7:45 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

So am I right in thinking the <tab> got replaced out because C.Spaces was > C.StartOfTokenColumn? (i.e. appendIndentText was given a negative number as the 4th argument)

So am I right in thinking the <tab> got replaced out because C.Spaces was > C.StartOfTokenColumn? (i.e. appendIndentText was given a negative number as the 4th argument)

Yes, that's it. It's not actually negative because that's an unsigned value, so it underflows and gets big. That's also a reason why we can't just check for a non-positive value instead of a zero i. appendIndentText (that would be a different workaround though).

MyDeveloperDay accepted this revision.Dec 15 2021, 3:02 PM
This revision is now accepted and ready to land.Dec 15 2021, 3:02 PM
owenpan accepted this revision.Dec 15 2021, 10:54 PM
This revision was landed with ongoing or failed builds.Dec 16 2021, 12:28 AM
This revision was automatically updated to reflect the committed changes.