clang-tools  10.0.0
UseTrailingReturnTypeCheck.h
Go to the documentation of this file.
1 //===--- UseTrailingReturnTypeCheck.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_MODERNIZE_USETRAILINGRETURNTYPECHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USETRAILINGRETURNTYPECHECK_H
12 
13 #include "../ClangTidy.h"
14 
15 namespace clang {
16 namespace tidy {
17 namespace modernize {
18 
20  Token T;
23 };
24 
25 /// Rewrites function signatures to use a trailing return type.
26 ///
27 /// For the user-facing documentation see:
28 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-trailing-type-return.html
30 public:
32  : ClangTidyCheck(Name, Context) {}
33  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
35  Preprocessor *ModuleExpanderPP) override;
36  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
37 
38 private:
39  Preprocessor *PP = nullptr;
40 
41  SourceLocation findTrailingReturnTypeSourceLocation(
42  const FunctionDecl &F, const FunctionTypeLoc &FTL, const ASTContext &Ctx,
43  const SourceManager &SM, const LangOptions &LangOpts);
44  llvm::Optional<SmallVector<ClassifiedToken, 8>>
45  classifyTokensBeforeFunctionName(const FunctionDecl &F, const ASTContext &Ctx,
46  const SourceManager &SM,
47  const LangOptions &LangOpts);
48  SourceRange findReturnTypeAndCVSourceRange(const FunctionDecl &F,
49  const ASTContext &Ctx,
50  const SourceManager &SM,
51  const LangOptions &LangOpts);
52  bool keepSpecifiers(std::string &ReturnType, std::string &Auto,
53  SourceRange ReturnTypeCVRange, const FunctionDecl &F,
54  const FriendDecl *Fr, const ASTContext &Ctx,
55  const SourceManager &SM, const LangOptions &LangOpts);
56 };
57 
58 } // namespace modernize
59 } // namespace tidy
60 } // namespace clang
61 
62 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USETRAILINGRETURNTYPECHECK_H
Base class for all clang-tidy checks.
Context Ctx
static constexpr llvm::StringLiteral Name
std::string ReturnType
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
UseTrailingReturnTypeCheck(StringRef Name, ClangTidyContext *Context)
Rewrites function signatures to use a trailing return type.