diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h')
-rw-r--r-- | clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h index bfd84d100c2..e224dcc9068 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h +++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h @@ -18,6 +18,9 @@ namespace performance { /// Finds possible inefficient `std::vector` operations (e.g. `push_back`) in /// for loops that may cause unnecessary memory reallocations. /// +/// When EnableProto, also finds calls that add element to protobuf repeated +/// field without calling Reserve() first. +/// /// For the user-facing documentation see: /// http://clang.llvm.org/extra/clang-tidy/checks/performance-inefficient-vector-operation.html class InefficientVectorOperationCheck : public ClangTidyCheck { @@ -28,7 +31,14 @@ public: void storeOptions(ClangTidyOptions::OptionMap &Opts) override; private: + void AddMatcher(const ast_matchers::DeclarationMatcher &TargetRecordDecl, + StringRef VarDeclName, StringRef VarDeclStmtName, + const ast_matchers::DeclarationMatcher &AppendMethodDecl, + StringRef AppendCallName, ast_matchers::MatchFinder *Finder); const std::vector<std::string> VectorLikeClasses; + + // If true, also check inefficient operations for proto repeated fields. + bool EnableProto; }; } // namespace performance |