[all-commits] [llvm/llvm-project] 2b2dbe: [clangd] Selection: Prune gtest TEST()s earlier

Sam McCall via All-commits all-commits at lists.llvm.org
Thu Jan 13 04:58:56 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2b2dbe6126f8c016e0cbef45a6d22e1359ce39fd
      https://github.com/llvm/llvm-project/commit/2b2dbe6126f8c016e0cbef45a6d22e1359ce39fd
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2022-01-13 (Thu, 13 Jan 2022)

  Changed paths:
    M clang-tools-extra/clangd/Selection.cpp

  Log Message:
  -----------
  [clangd] Selection: Prune gtest TEST()s earlier

When searching for AST nodes that may overlap the selection, mayHit() was only
attempting to prune nodes whose begin/end are both in the main file.

While failing to prune never gives wrong results, it hurts performance.
In GTest unit-tests, `TEST()` macros at the top level declare classes.
These were never pruned and we traversed *every* such class for any selection.

We fix this by reasoning about what tokens such a node might claim.
They must lie within its ultimate macro expansion range, so if this doesn't
overlap with the selection, we can prune the node.

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




More information about the All-commits mailing list