[PATCH] D113472: [clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)
Salman Javed via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 9 02:07:40 PST 2021
salman-javed-nz created this revision.
salman-javed-nz added a reviewer: carlosgalvezp.
salman-javed-nz added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.
salman-javed-nz requested review of this revision.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113472
Files:
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -374,13 +374,11 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113472.385741.patch
Type: text/x-patch
Size: 1166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211109/c2efbca9/attachment.bin>
More information about the cfe-commits
mailing list