Skip to content

Commit

Permalink
[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)
Browse files Browse the repository at this point in the history
Calling clang-tidy on ClangTidyDiagnosticConsumer.cpp gives a
"unmatched NOLINTBEGIN without a subsequent NOLINTEND" warning.

The "NOLINTBEGIN" and "NOLINTEND" string literals used in the
implementation of `createNolintError()` get mistaken for actual
NOLINTBEGIN/END comments used to suppress clang-tidy warnings.

Rewrite the string literals so that they can no longer be mistaken for
actual suppression comments.

Differential Revision: https://reviews.llvm.org/D113472
  • Loading branch information
salman-javed-nz committed Nov 9, 2021
1 parent 9b7c584 commit 0076957
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Expand Up @@ -374,13 +374,11 @@ static ClangTidyError createNolintError(const ClangTidyContext &Context,
bool IsNolintBegin) {
ClangTidyError Error("clang-tidy-nolint", ClangTidyError::Error,
Context.getCurrentBuildDirectory(), false);
StringRef Message =
IsNolintBegin
? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' "
"comment"
: "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' "
"comment";
Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
auto Message = Twine("unmatched 'NOLINT") +
(IsNolintBegin ? "BEGIN" : "END") + "' comment without a " +
(IsNolintBegin ? "subsequent" : "previous") + " 'NOLINT" +
(IsNolintBegin ? "END" : "BEGIN") + "' comment";
Error.Message = tooling::DiagnosticMessage(Message.str(), SM, Loc);
return Error;
}

Expand Down

0 comments on commit 0076957

Please sign in to comment.