[all-commits] [llvm/llvm-project] c0687e: Add support for `NOLINTBEGIN` ... `NOLINTEND` comm...

Salman Javed via All-commits all-commits at lists.llvm.org
Tue Sep 28 04:53:39 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c0687e1984a82925918c874b7bb68ad34c32aed0
      https://github.com/llvm/llvm-project/commit/c0687e1984a82925918c874b7bb68ad34c32aed0
  Author: Salman Javed <mail at salmanjaved.org>
  Date:   2021-09-28 (Tue, 28 Sep 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
    M clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/docs/clang-tidy/index.rst
    A clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/error_in_include.inc
    A clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/nolint_in_include.inc
    M clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-at-eof.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-global-end-specific.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-specific-end-global.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-without-end.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-end-at-sof.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-end-without-begin.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-delims.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-typo-in-check-name.cpp
    A clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
    M clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

  Log Message:
  -----------
  Add support for `NOLINTBEGIN` ... `NOLINTEND` comments

Add support for NOLINTBEGIN ... NOLINTEND comments to suppress
clang-tidy warnings over multiple lines. All lines between the "begin"
and "end" markers are suppressed.

Example:

// NOLINTBEGIN(some-check)
<Code with warnings to be suppressed, line 1>
<Code with warnings to be suppressed, line 2>
<Code with warnings to be suppressed, line 3>
// NOLINTEND(some-check)
Follows similar syntax as the NOLINT and NOLINTNEXTLINE comments
that are already implemented, i.e. allows multiple checks to be provided
in parentheses; suppresses all checks if the parentheses are omitted,
etc.

If the comments are misused, e.g. using a NOLINTBEGIN but not
terminating it with a NOLINTEND, a clang-tidy-nolint diagnostic
message pointing to the misuse is generated.

As part of implementing this feature, the following bugs were fixed in
existing code:

IsNOLINTFound(): IsNOLINTFound("NOLINT", Str) returns true when Str is
"NOLINTNEXTLINE". This is because the textual search finds NOLINT as
the stem of NOLINTNEXTLINE.

LineIsMarkedWithNOLINT(): NOLINTNEXTLINEs on the very first line of a
file are ignored. This is due to rsplit('\n\').second returning a blank
string when there are no more newline chars to split on.




More information about the All-commits mailing list