File indexing completed on 2024-04-28 05:38:25

0001 /*
0002     SPDX-FileCopyrightText: 2016 Sergio Martins <smartins@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef CLAZY_CONTAINER_ANTI_PATTERN_H
0008 #define CLAZY_CONTAINER_ANTI_PATTERN_H
0009 
0010 #include "checkbase.h"
0011 
0012 #include <string>
0013 
0014 class ClazyContext;
0015 
0016 namespace clang
0017 {
0018 class Stmt;
0019 class CXXForRangeStmt;
0020 class CXXConstructExpr;
0021 }
0022 
0023 /**
0024  * Warns when there are unneeded allocations of temporary lists because of using values(), keys()
0025  * toVector() or toList().
0026  *
0027  * See README-anti-pattern for more information
0028  */
0029 class ContainerAntiPattern : public CheckBase
0030 {
0031 public:
0032     explicit ContainerAntiPattern(const std::string &name, ClazyContext *context);
0033     void VisitStmt(clang::Stmt *stmt) override;
0034 
0035 private:
0036     bool VisitQSet(clang::Stmt *stmt);
0037     bool handleLoop(clang::Stmt *);
0038 };
0039 
0040 #endif