[clang-tools-extra] [clang-tidy] Add modernize-use-cpp-style-comments check (PR #99713)

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 23:17:36 PDT 2024


================
@@ -0,0 +1,38 @@
+//===--- UseCppStyleCommentsCheck.h - clang-tidy---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_CPP_STYLE_COMMENTS_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_CPP_STYLE_COMMENTS_CHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::modernize {
+/// detects C-style comments and suggests to use C++ style comments instead
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-cpp-style-comments.html
+class UseCppStyleCommentsCheck : public ClangTidyCheck {
+public:
+  UseCppStyleCommentsCheck(StringRef Name, ClangTidyContext *Context);
+  ~UseCppStyleCommentsCheck() override;
+
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+    return LangOpts.CPlusPlus;
+  }
+
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+                           Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
----------------
njames93 wrote:

This callback will never get run, so there is no need to override it.

https://github.com/llvm/llvm-project/pull/99713


More information about the cfe-commits mailing list