blob: 2efb212998c23220e6b340d19daacee2376ab987 [file] [log] [blame]
Piotr Padlewski552d4492016-06-21 15:23:27 +00001//===--- 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"
Piotr Padlewski8f802292016-07-29 02:10:23 +000014#include <string>
15#include <vector>
Piotr Padlewski552d4492016-06-21 15:23:27 +000016
17namespace clang {
18namespace tidy {
19namespace 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.
Piotr Padlewski8f802292016-07-29 02:10:23 +000025///
Piotr Padlewski552d4492016-06-21 15:23:27 +000026/// For the user-facing documentation see:
27/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html
28class UseEmplaceCheck : public ClangTidyCheck {
29public:
Piotr Padlewski8f802292016-07-29 02:10:23 +000030 UseEmplaceCheck(StringRef Name, ClangTidyContext *Context);
Piotr Padlewski552d4492016-06-21 15:23:27 +000031 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
32 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
Piotr Padlewski8f802292016-07-29 02:10:23 +000033 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
34
35private:
Alexander Kornienkoff6b2af2017-08-10 12:19:05 +000036 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;
Piotr Padlewski552d4492016-06-21 15:23:27 +000041};
42
43} // namespace modernize
44} // namespace tidy
45} // namespace clang
46
47#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EMPLACE_H