llvm-project/clang-tools-extra
Utkarsh Saxena aa979084df [clang][Syntax] Optimize expandedTokens for token ranges.
`expandedTokens(SourceRange)` used to do a binary search to get the
expanded tokens belonging to a source range. Each binary search uses
`isBeforeInTranslationUnit` to order two source locations. This is
inherently very slow.
By profiling clangd we found out that users like clangd::SelectionTree
spend 95% of time in `isBeforeInTranslationUnit`. Also it is worth
noting that users of `expandedTokens(SourceRange)` majorly use ranges
provided by AST to query this funciton. The ranges provided by AST are
token ranges (starting at the beginning of a token and ending at the
beginning of another token).

Therefore we can avoid the binary search in majority of the cases by
maintaining an index of ExpandedToken by their SourceLocations. We still
do binary search for ranges which are not token ranges but such
instances are quite low.

Performance:
`~/build/bin/clangd --check=clang/lib/Serialization/ASTReader.cpp`
Before: Took 2:10s to complete.
Now: Took 1:13s to complete.

Differential Revision: https://reviews.llvm.org/D99086
2021-03-25 18:54:15 +01:00
..
clang-apply-replacements [clang-tools-extra] Prevent linking to duplicate .a libs and dylib 2020-06-17 19:00:26 +02:00
clang-change-namespace [clang-tooling] Prevent llvm::fatal_error on invalid CLI option 2021-01-29 10:15:06 +01:00
clang-doc [openmp] Add missing dependencies for OMP.h.inc after d90443b 2020-06-23 11:48:04 -04:00
clang-include-fixer [clang-include-fixer] Pre-reserve vector size. NFC 2021-02-03 08:30:45 +01:00
clang-move [clang-tooling] Prevent llvm::fatal_error on invalid CLI option 2021-01-29 10:15:06 +01:00
clang-query [clang-query] Fix help text after D91918 2021-03-03 15:57:49 +00:00
clang-reorder-fields [clang-tooling] Prevent llvm::fatal_error on invalid CLI option 2021-01-29 10:15:06 +01:00
clang-tidy [clang-tidy] Fix mpi checks when running multiple TUs per clang-tidy process 2021-03-25 14:38:37 +00:00
clangd [clang][Syntax] Optimize expandedTokens for token ranges. 2021-03-25 18:54:15 +01:00
docs new altera unroll loops check 2021-03-22 13:09:53 -04:00
modularize [cte][NFC] Remove all references to stdlib stream headers. 2021-03-02 21:57:16 +00:00
pp-trace [clang-tools-extra] NFC: Fix trivial typo in documents and comments 2020-04-05 15:28:40 +09:00
test fix readability-braces-around-statements Stmt type dependency 2021-03-25 09:44:41 -04:00
tool-template [OpenMP] "UnFix" layering problem with FrontendOpenMP 2020-04-07 14:41:18 -05:00
unittests [clang-tidy] Remove OptionError 2021-03-01 17:55:17 +00:00
.gitignore
CMakeLists.txt Add an explicit toggle for the static analyzer in clang-tidy 2020-09-10 10:48:17 -04:00
CODE_OWNERS.TXT [clangd] add CODE_OWNERS 2020-01-29 12:43:19 +01:00
LICENSE.TXT
README.txt

README.txt

//===----------------------------------------------------------------------===//
// Clang Tools repository
//===----------------------------------------------------------------------===//

Welcome to the repository of extra Clang Tools.  This repository holds tools
that are developed as part of the LLVM compiler infrastructure project and the
Clang frontend.  These tools are kept in a separate "extra" repository to
allow lighter weight checkouts of the core Clang codebase.

This repository is only intended to be checked out inside of a full LLVM+Clang
tree, and in the 'tools/extra' subdirectory of the Clang checkout.

All discussion regarding Clang, Clang-based tools, and code in this repository
should be held using the standard Clang mailing lists:
  http://lists.llvm.org/mailman/listinfo/cfe-dev

Code review for this tree should take place on the standard Clang patch and
commit lists:
  http://lists.llvm.org/mailman/listinfo/cfe-commits

If you find a bug in these tools, please file it in the LLVM bug tracker:
  http://llvm.org/bugs/