[all-commits] [llvm/llvm-project] 19eaad: [clang-tidy] Cache the locations of NOLINTBEGIN/EN...

Salman Javed via All-commits all-commits at lists.llvm.org
Wed Jan 26 03:24:21 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 19eaad94c47f92dd23989b0b6832bb6751dde979
      https://github.com/llvm/llvm-project/commit/19eaad94c47f92dd23989b0b6832bb6751dde979
  Author: Salman Javed <mail at salmanjaved.org>
  Date:   2022-01-27 (Thu, 27 Jan 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/CMakeLists.txt
    M clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
    M clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
    A clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
    A clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h
    M clang-tools-extra/clangd/ParsedAST.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/1st-translation-unit.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/2nd-translation-unit.cpp
    M clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-LIFO.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-all-end-glob.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-all-end-specific.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-glob-end-all.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-glob-end-specific.cpp
    R clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-global-end-specific.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-multiple-end-single.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-single-end-multiple.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-specific-end-all.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-specific-end-glob.cpp
    R clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-specific-end-global.cpp
    M clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp
    M clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-delims.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-multiple-TUs.cpp
    M clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-typo-in-check-name.cpp
    M clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp

  Log Message:
  -----------
  [clang-tidy] Cache the locations of NOLINTBEGIN/END blocks

Support for NOLINT(BEGIN/END) blocks (implemented in D108560) is
currently costly. This patch aims to improve the performance with the
following changes:

- The use of tokenized NOLINTs instead of a series of repetitive ad-hoc
string operations (`find()`, `split()`, `slice()`, regex matching etc).
- The caching of NOLINT(BEGIN/END) block locations. Determining these
locations each time a new diagnostic is raised is wasteful as it
requires reading and parsing the entire source file.

Move NOLINT-specific code from `ClangTidyDiagnosticConsumer` to new
purpose-built class `NoLintDirectiveHandler`.

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




More information about the All-commits mailing list