Debian Codegraph @

src/checks/level2/function-args-by-value.h

raw
1 /*
2 SPDX-FileCopyrightText: 2016 Sergio Martins <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 #ifndef CLAZY_FUNC_ARGS_BY_VALUE_H
8 #define CLAZY_FUNC_ARGS_BY_VALUE_H
9
10 #include "checkbase.h"
11
12 #include <clang/Basic/Diagnostic.h>
13
14 namespace clang
15 {
16 class FunctionDecl;
17 class ParmVarDecl;
18 }
19
20 namespace clazy
21 {
22 struct QualTypeClassification;
23 }
24
25 /**
26 * Finds arguments that should be passed by value instead of const-ref
27 *
28 * See README-function-args-by-value for more info
29 */
30 class FunctionArgsByValue : public CheckBase
31 {
32 public:
33 using CheckBase::CheckBase;
34 void VisitDecl(clang::Decl *decl) override;
35 void VisitStmt(clang::Stmt *stmt) override;
36
37 private:
38 void processFunction(clang::FunctionDecl *);
39 bool shouldIgnoreClass(clang::CXXRecordDecl *);
40 static bool shouldIgnoreOperator(clang::FunctionDecl *);
41 static bool shouldIgnoreFunction(clang::FunctionDecl *);
42 clang::FixItHint fixit(clang::FunctionDecl *func, const clang::ParmVarDecl *param, clazy::QualTypeClassification);
43 };
44
45 #endif