[clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with other containers.

Summary:
Previously TranslationUnitDecl would never be selected.
This means root() is never null, and returns a reference.

commonAncestor() is in principle never null also, but returning TUDecl
here requires tweaks to be careful not to traverse it (this was already
possible when selecting multiple top-level decls, and there are associated bugs!)
Instead, never allow commonAncestor() to return TUDecl, return null instead.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65101

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@366893 91177308-0d34-0410-b5e6-96231b3b80d8
5 files changed