This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix an assertion crash in "ExtractVariable" tweak
ClosedPublic

Authored by hokein on Jul 11 2019, 4:13 AM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

hokein created this revision.Jul 11 2019, 4:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2019, 4:13 AM
hokein marked an inline comment as done.Jul 11 2019, 4:16 AM
hokein added inline comments.
clang-tools-extra/clangd/Selection.cpp
367 ↗(On Diff #209166)

sorry, the previous patch rL365751 didn't fix the crash, and I re-read the code more thoroughly, I think we will never hit this point, need you confirmation, @sammccall.

sammccall accepted this revision.Jul 11 2019, 4:22 AM
sammccall added inline comments.
clang-tools-extra/clangd/Selection.cpp
361 ↗(On Diff #209166)

can we just rewrite this as

while (Root->Children.size() == 1 && !Root->Selected)
  Ancestor = Ancestor->Children.front();
return Root;

seems a lot clearer, not sure what I was thinking when I wrote this...

368 ↗(On Diff #209166)

there's no termination condition for the loop. If there were, the compiler would warn us.
I think we don't need this.

This revision is now accepted and ready to land.Jul 11 2019, 4:22 AM
hokein updated this revision to Diff 209172.Jul 11 2019, 4:37 AM
hokein marked an inline comment as done.

Address comment.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2019, 5:30 AM