Page MenuHomePhabricator

[clang-format] Avoid crash in LevelIndentTracker.
ClosedPublic

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

Diff Detail

Unit TestsFailed

TimeTest
820 msx64 debian > SanitizerCommon-tsan-x86_64-Linux.Linux::decorate_proc_maps.cpp
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=thread -m64 -funwind-tables -ldl -g /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/decorate_proc_maps.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/sanitizer_common/tsan-x86_64-Linux/Linux/Output/decorate_proc_maps.cpp.tmp

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
69–70

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–70

So how about that?

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

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.