| 1 | //===--- ArgumentCommentCheck.h - clang-tidy --------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ARGUMENTCOMMENTCHECK_H |
| 10 | #define |
| 11 | |
| 12 | #include "../ClangTidyCheck.h" |
| 13 | #include "llvm/Support/Regex.h" |
| 14 | |
| 15 | namespace clang::tidy::bugprone { |
| 16 | |
| 17 | /// Checks that argument comments match parameter names. |
| 18 | /// |
| 19 | /// The check understands argument comments in the form `/*parameter_name=*/` |
| 20 | /// that are placed right before the argument. |
| 21 | /// |
| 22 | /// \code |
| 23 | /// void f(bool foo); |
| 24 | /// |
| 25 | /// ... |
| 26 | /// f(/*bar=*/true); |
| 27 | /// // warning: argument name 'bar' in comment does not match parameter name |
| 28 | /// 'foo' |
| 29 | /// \endcode |
| 30 | /// |
| 31 | /// The check tries to detect typos and suggest automated fixes for them. |
| 32 | class : public ClangTidyCheck { |
| 33 | public: |
| 34 | (StringRef Name, ClangTidyContext *Context); |
| 35 | |
| 36 | void (ast_matchers::MatchFinder *Finder) override; |
| 37 | void (const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 38 | void (ClangTidyOptions::OptionMap &Opts) override; |
| 39 | |
| 40 | private: |
| 41 | const unsigned : 1; |
| 42 | const unsigned : 1; |
| 43 | const unsigned : 1; |
| 44 | const unsigned : 1; |
| 45 | const unsigned : 1; |
| 46 | const unsigned : 1; |
| 47 | const unsigned : 1; |
| 48 | const unsigned : 1; |
| 49 | const unsigned : 1; |
| 50 | llvm::Regex ; |
| 51 | |
| 52 | void (ASTContext *Ctx, const FunctionDecl *Callee, |
| 53 | SourceLocation ArgBeginLoc, |
| 54 | llvm::ArrayRef<const Expr *> Args); |
| 55 | |
| 56 | bool (const Expr *Arg) const; |
| 57 | }; |
| 58 | |
| 59 | } // namespace clang::tidy::bugprone |
| 60 | |
| 61 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ARGUMENTCOMMENTCHECK_H |
| 62 | |