Debian Codegraph @

src/checks/level0/temporary-iterator.h

raw
1 /*
2 SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB a KDAB Group company [email protected]
3 SPDX-FileContributor: Sérgio Martins <[email protected]>
4 SPDX-FileCopyrightText: 2015-2016 Sergio Martins <[email protected]>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8
9 #ifndef TEMPORARY_ITERATOR_H
10 #define TEMPORARY_ITERATOR_H
11
12 #include "checkbase.h"
13
14 #include <llvm/ADT/StringRef.h>
15
16 #include <map>
17 #include <string>
18 #include <vector>
19
20 /**
21 * Finds places where you're using iterators on temporary containers.
22 *
23 * For example getList().constBegin(), getList().constEnd() would provoke a crash when dereferencing
24 * the iterator.
25 */
26 class TemporaryIterator : public CheckBase
27 {
28 public:
29 TemporaryIterator(const std::string &name, Options options);
30 void VisitStmt(clang::Stmt *stm) override;
31
32 private:
33 std::map<llvm::StringRef, std::vector<llvm::StringRef>> m_methodsByType;
34 };
35
36 #endif