clang-tools  8.0.0
UseEmplaceCheck.h
Go to the documentation of this file.
1 //===--- UseEmplaceCheck.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_USE_EMPLACE_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EMPLACE_H
12 
13 #include "../ClangTidy.h"
14 #include <string>
15 #include <vector>
16 
17 namespace clang {
18 namespace tidy {
19 namespace modernize {
20 
21 /// This check looks for cases when inserting new element into std::vector but
22 /// the element is constructed temporarily.
23 /// It replaces those calls for emplace_back of arguments passed to
24 /// constructor of temporary object.
25 ///
26 /// For the user-facing documentation see:
27 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html
29 public:
30  UseEmplaceCheck(StringRef Name, ClangTidyContext *Context);
31  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
32  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
33  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
34 
35 private:
36  const bool IgnoreImplicitConstructors;
37  const std::vector<std::string> ContainersWithPushBack;
38  const std::vector<std::string> SmartPointers;
39  const std::vector<std::string> TupleTypes;
40  const std::vector<std::string> TupleMakeFunctions;
41 };
42 
43 } // namespace modernize
44 } // namespace tidy
45 } // namespace clang
46 
47 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EMPLACE_H
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
UseEmplaceCheck(StringRef Name, ClangTidyContext *Context)
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
This check looks for cases when inserting new element into std::vector but the element is constructed...