[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)

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
This commit is contained in:
Salman Javed 2021-11-10 01:03:26 +13:00
parent 9b7c584ed8
commit 0076957202

View File

@ -374,13 +374,11 @@ static ClangTidyError createNolintError(const ClangTidyContext &Context,
bool IsNolintBegin) { bool IsNolintBegin) {
ClangTidyError Error("clang-tidy-nolint", ClangTidyError::Error, ClangTidyError Error("clang-tidy-nolint", ClangTidyError::Error,
Context.getCurrentBuildDirectory(), false); Context.getCurrentBuildDirectory(), false);
StringRef Message = auto Message = Twine("unmatched 'NOLINT") +
IsNolintBegin (IsNolintBegin ? "BEGIN" : "END") + "' comment without a " +
? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' " (IsNolintBegin ? "subsequent" : "previous") + " 'NOLINT" +
"comment" (IsNolintBegin ? "END" : "BEGIN") + "' comment";
: "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' " Error.Message = tooling::DiagnosticMessage(Message.str(), SM, Loc);
"comment";
Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
return Error; return Error;
} }