This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Avoid crash in LevelIndentTracker.
ClosedPublic

Authored by curdeius on Jul 4 2022, 2:34 AM.

Diff Detail

Event Timeline

curdeius created this revision.Jul 4 2022, 2:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2022, 2:34 AM
curdeius requested review of this revision.Jul 4 2022, 2:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2022, 2:34 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
curdeius added a project: Restricted Project.Jul 4 2022, 2:35 AM
This revision is now accepted and ready to land.Jul 4 2022, 3:43 AM
owenpan added inline comments.Jul 4 2022, 2:46 PM
clang/lib/Format/UnwrappedLineFormatter.cpp
68–69

You can delete both lines as the body of the if statement is unreachable. (After the while loop on lines 62-63, IndentForLevel.size() is larger than Line.Level.)

clang/lib/Format/UnwrappedLineFormatter.cpp
62–69

So how about that?

owenpan added inline comments.Jul 5 2022, 2:21 PM
clang/lib/Format/UnwrappedLineFormatter.cpp
62–69

Good idea, but it's an unrelated change. Let's take care of it in D129105, which I will update to use resize() instead of insert().

curdeius updated this revision to Diff 442482.Jul 6 2022, 2:32 AM
curdeius marked an inline comment as done.

Address comments.

owenpan accepted this revision.Jul 6 2022, 12:53 PM
This revision was automatically updated to reflect the committed changes.