Skip to content

Commit 0076957

Browse files
[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
1 parent 9b7c584 commit 0076957

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,11 @@ static ClangTidyError createNolintError(const ClangTidyContext &Context,
374374
bool IsNolintBegin) {
375375
ClangTidyError Error("clang-tidy-nolint", ClangTidyError::Error,
376376
Context.getCurrentBuildDirectory(), false);
377-
StringRef Message =
378-
IsNolintBegin
379-
? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' "
380-
"comment"
381-
: "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' "
382-
"comment";
383-
Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
377+
auto Message = Twine("unmatched 'NOLINT") +
378+
(IsNolintBegin ? "BEGIN" : "END") + "' comment without a " +
379+
(IsNolintBegin ? "subsequent" : "previous") + " 'NOLINT" +
380+
(IsNolintBegin ? "END" : "BEGIN") + "' comment";
381+
Error.Message = tooling::DiagnosticMessage(Message.str(), SM, Loc);
384382
return Error;
385383
}
386384

0 commit comments

Comments
 (0)