Debian Codegraph @

src/checks/manuallevel/qstring-ref.h

raw
1 /*
2 SPDX-FileCopyrightText: 2015 Sergio Martins <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 #ifndef QSTRING_REF_H
8 #define QSTRING_REF_H
9
10 #include "checkbase.h"
11
12 #include <clang/Basic/Diagnostic.h>
13 #include <vector>
14
15 namespace clang
16 {
17 class CallExpr;
18 class CXXMemberCallExpr;
19 }
20
21 /**
22 * Finds places where the QString::fooRef() should be used instead QString::foo(), to save allocations
23 *
24 * See README-qstringref for more info.
25 */
26 class StringRefCandidates : public CheckBase
27 {
28 public:
29 using CheckBase::CheckBase;
30 void VisitStmt(clang::Stmt *stmt) override;
31
32 private:
33 bool processCase1(clang::CXXMemberCallExpr *);
34 bool processCase2(clang::CallExpr *call);
35 bool isConvertedToSomethingElse(clang::Stmt *s) const;
36
37 std::vector<clang::CallExpr *> m_alreadyProcessedChainedCalls;
38 std::vector<clang::FixItHint> fixit(clang::CXXMemberCallExpr *);
39 };
40
41 #endif