blob: 565000d41a7fc4c88d76fa5e8dc1fef46a43950c [file] [log] [blame]
//===--- UseTrailingReturnTypeCheck.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.
#include "../ClangTidy.h"
namespace clang {
namespace tidy {
namespace modernize {
struct ClassifiedToken {
Token T;
bool isQualifier;
bool isSpecifier;
/// Rewrites function signatures to use a trailing return type.
/// For the user-facing documentation see:
class UseTrailingReturnTypeCheck : public ClangTidyCheck {
UseTrailingReturnTypeCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
Preprocessor *PP = nullptr;
SourceLocation findTrailingReturnTypeSourceLocation(
const FunctionDecl &F, const FunctionTypeLoc &FTL, const ASTContext &Ctx,
const SourceManager &SM, const LangOptions &LangOpts);
llvm::Optional<SmallVector<ClassifiedToken, 8>>
classifyTokensBeforeFunctionName(const FunctionDecl &F, const ASTContext &Ctx,
const SourceManager &SM,
const LangOptions &LangOpts);
SourceRange findReturnTypeAndCVSourceRange(const FunctionDecl &F,
const ASTContext &Ctx,
const SourceManager &SM,
const LangOptions &LangOpts);
bool keepSpecifiers(std::string &ReturnType, std::string &Auto,
SourceRange ReturnTypeCVRange, const FunctionDecl &F,
const FriendDecl *Fr, const ASTContext &Ctx,
const SourceManager &SM, const LangOptions &LangOpts);
} // namespace modernize
} // namespace tidy
} // namespace clang