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; }
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; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits