File indexing completed on 2024-04-28 05:38:27
0001 /* 0002 SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB a KDAB Group company info@kdab.com 0003 SPDX-FileContributor: Sérgio Martins <sergio.martins@kdab.com> 0004 SPDX-FileCopyrightText: 2015-2016 Sergio Martins <smartins@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef TEMPORARY_ITERATOR_H 0010 #define TEMPORARY_ITERATOR_H 0011 0012 #include "checkbase.h" 0013 0014 #include <llvm/ADT/StringRef.h> 0015 0016 #include <map> 0017 #include <string> 0018 #include <vector> 0019 0020 class ClazyContext; 0021 namespace clang 0022 { 0023 class Stmt; 0024 } // namespace clang 0025 0026 /** 0027 * Finds places where you're using iterators on temporary containers. 0028 * 0029 * For example getList().constBegin(), getList().constEnd() would provoke a crash when dereferencing 0030 * the iterator. 0031 */ 0032 class TemporaryIterator : public CheckBase 0033 { 0034 public: 0035 TemporaryIterator(const std::string &name, ClazyContext *context); 0036 void VisitStmt(clang::Stmt *stm) override; 0037 0038 private: 0039 std::map<llvm::StringRef, std::vector<llvm::StringRef>> m_methodsByType; 0040 }; 0041 0042 #endif