This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Allow disble down traversals from root.
ClosedPublic

Authored by ioeric on Oct 16 2018, 3:03 AM.

Details

Summary

This is useful for symbo scope proximity, where down traversals from
the global scope if not desired.

Diff Detail

Event Timeline

ioeric created this revision.Oct 16 2018, 3:03 AM
sammccall accepted this revision.Oct 16 2018, 3:22 AM

Works for me! I think the code can be simplified slightly.

clangd/FileDistance.cpp
138

I think this is more power than it needs to be... and in fact messes up the caching.

if (KnownNode == RootHash && !Opts.AllowDownTraversalFromRoot && !Ancestors.empty())
 Cost = Unreachable;

should be enough.

Or maybe even clearer, after line 126:

if (Hash == RootHash && !Ancestors.empty() && !Opts.AllowDownTraversalFromRoot) {
  Cost = Unreachable;
  break;
}

then you never have to store KnownNode.

This revision is now accepted and ready to land.Oct 16 2018, 3:22 AM
ioeric updated this revision to Diff 169804.Oct 16 2018, 3:39 AM
ioeric marked an inline comment as done.
  • Simplify according to review suggestion.
This revision was automatically updated to reflect the committed changes.