2014-03-18 12:46:45 +08:00
|
|
|
//===--- ArgumentCommentCheck.h - clang-tidy --------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-03-10 00:52:33 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ARGUMENTCOMMENTCHECK_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ARGUMENTCOMMENTCHECK_H
|
2014-03-18 12:46:45 +08:00
|
|
|
|
|
|
|
#include "../ClangTidy.h"
|
|
|
|
#include "llvm/Support/Regex.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
2015-03-02 20:25:03 +08:00
|
|
|
namespace misc {
|
2014-03-18 12:46:45 +08:00
|
|
|
|
2015-08-28 02:01:58 +08:00
|
|
|
/// Checks that argument comments match parameter names.
|
|
|
|
///
|
|
|
|
/// The check understands argument comments in the form `/*parameter_name=*/`
|
|
|
|
/// that are placed right before the argument.
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// void f(bool foo);
|
|
|
|
///
|
|
|
|
/// ...
|
|
|
|
/// f(/*bar=*/true);
|
|
|
|
/// // warning: argument name 'bar' in comment does not match parameter name 'foo'
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
/// The check tries to detect typos and suggest automated fixes for them.
|
2014-03-18 12:46:45 +08:00
|
|
|
class ArgumentCommentCheck : public ClangTidyCheck {
|
|
|
|
public:
|
2014-09-12 16:53:36 +08:00
|
|
|
ArgumentCommentCheck(StringRef Name, ClangTidyContext *Context);
|
2014-03-18 15:22:43 +08:00
|
|
|
|
2014-03-18 12:46:45 +08:00
|
|
|
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
|
|
|
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
|
|
|
|
|
|
|
private:
|
2014-03-18 15:22:43 +08:00
|
|
|
llvm::Regex IdentRE;
|
2014-03-18 12:46:45 +08:00
|
|
|
|
|
|
|
bool isLikelyTypo(llvm::ArrayRef<ParmVarDecl *> Params, StringRef ArgName,
|
|
|
|
unsigned ArgIndex);
|
|
|
|
std::vector<std::pair<SourceLocation, StringRef>>
|
|
|
|
getCommentsInRange(ASTContext *Ctx, SourceRange Range);
|
|
|
|
void checkCallArgs(ASTContext *Ctx, const FunctionDecl *Callee,
|
|
|
|
SourceLocation ArgBeginLoc,
|
|
|
|
llvm::ArrayRef<const Expr *> Args);
|
|
|
|
};
|
|
|
|
|
2015-03-02 20:25:03 +08:00
|
|
|
} // namespace misc
|
2014-03-18 12:46:45 +08:00
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|
|
|
|
|
2015-03-10 00:52:33 +08:00
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ARGUMENTCOMMENTCHECK_H
|