This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix for #58188
AbandonedPublic

Authored by sstwcw on Oct 6 2022, 9:17 AM.

Details

Summary

This is intended to provide a hint for how to fix the bug. The patch fixes the bug itself, but a problem remains.

Diff Detail

Event Timeline

sstwcw created this revision.Oct 6 2022, 9:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 9:17 AM
sstwcw requested review of this revision.Oct 6 2022, 9:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 9:17 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

What is the problem that remains?

Please add a test case.

clang/lib/Format/UnwrappedLineParser.cpp
1142–1143

Could you remove the negation? I find negations of compound statements always harder to read.

sstwcw updated this revision to Diff 465772.Oct 6 2022, 9:27 AM
sstwcw added a comment.Oct 6 2022, 9:32 AM

The problem that remains is this, as I explained in the issue. The second branch of the second block is not indented.

#if 1
{
#endif
#if X
  x;
#else
x;
#endif
}

I didn't add a test case because I was not expecting this patch to be committed as there is still a problem.

sstwcw abandoned this revision.Oct 11 2022, 7:27 PM

I am closing it now there is D135740.