clang-tools  3.9.0
FoldInitTypeCheck.h
Go to the documentation of this file.
1 //===--- FoldInitTypeCheck.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_FOLD_INIT_TYPE_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FOLD_INIT_TYPE_H
12 
13 #include "../ClangTidy.h"
14 
15 namespace clang {
16 namespace tidy {
17 namespace misc {
18 
19 /// Find and flag invalid initializer values in folds, e.g. std::accumulate.
20 /// Example:
21 /// \code
22 /// auto v = {65536L * 65536 * 65536};
23 /// std::accumulate(begin(v), end(v), 0 /* int type is too small */);
24 /// \endcode
25 ///
26 /// For the user-facing documentation see:
27 /// http://clang.llvm.org/extra/clang-tidy/checks/misc-fold-init-type.html
29 public:
31  : ClangTidyCheck(Name, Context) {}
32  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
33  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
34 
35 private:
36  void doCheck(const BuiltinType &IterValueType, const BuiltinType &InitType,
37  const ASTContext &Context, const CallExpr &CallNode);
38 };
39 
40 } // namespace misc
41 } // namespace tidy
42 } // namespace clang
43 
44 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FOLD_INIT_TYPE_H
const std::string Name
Definition: USRFinder.cpp:140
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:210
Base class for all clang-tidy checks.
Definition: ClangTidy.h:110
Find and flag invalid initializer values in folds, e.g.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
FoldInitTypeCheck(StringRef Name, ClangTidyContext *Context)
const NamedDecl * Result
Definition: USRFinder.cpp:137