[clang-tools-extra] 0076957 - [clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)
Salman Javed via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 9 04:11:38 PST 2021
Author: Salman Javed
Date: 2021-11-10T01:09:35+13:00
New Revision: 00769572025f9b0d36dc832d3c1bc61500091ed5
URL: https://github.com/llvm/llvm-project/commit/00769572025f9b0d36dc832d3c1bc61500091ed5
DIFF: https://github.com/llvm/llvm-project/commit/00769572025f9b0d36dc832d3c1bc61500091ed5.diff
LOG: [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
Added:
Modified:
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 456de0e979db..9771d90de63d 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -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;
}
More information about the cfe-commits
mailing list