clang-tools  5.0.0
ArgumentCommentCheck.h
Go to the documentation of this file.
1 //===--- ArgumentCommentCheck.h - clang-tidy --------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ARGUMENTCOMMENTCHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ARGUMENTCOMMENTCHECK_H
12 
13 #include "../ClangTidy.h"
14 #include "llvm/Support/Regex.h"
15 
16 namespace clang {
17 namespace tidy {
18 namespace misc {
19 
20 /// Checks that argument comments match parameter names.
21 ///
22 /// The check understands argument comments in the form `/*parameter_name=*/`
23 /// that are placed right before the argument.
24 ///
25 /// \code
26 /// void f(bool foo);
27 ///
28 /// ...
29 /// f(/*bar=*/true);
30 /// // warning: argument name 'bar' in comment does not match parameter name 'foo'
31 /// \endcode
32 ///
33 /// The check tries to detect typos and suggest automated fixes for them.
35 public:
37 
38  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
39  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
40  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
41 
42 private:
43  const bool StrictMode;
44  llvm::Regex IdentRE;
45 
46  void checkCallArgs(ASTContext *Ctx, const FunctionDecl *Callee,
47  SourceLocation ArgBeginLoc,
48  llvm::ArrayRef<const Expr *> Args);
49 };
50 
51 } // namespace misc
52 } // namespace tidy
53 } // namespace clang
54 
55 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ARGUMENTCOMMENTCHECK_H
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
StringHandle Name
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:275
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
ArgumentCommentCheck(StringRef Name, ClangTidyContext *Context)
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
std::map< std::string, std::string > OptionMap
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
ClangTidyContext & Context
Definition: ClangTidy.cpp:87
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.