File indexing completed on 2024-04-28 05:38:30
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_FUNC_ARGS_BY_VALUE_H 0008 #define CLAZY_FUNC_ARGS_BY_VALUE_H 0009 0010 #include "checkbase.h" 0011 0012 #include <clang/Basic/Diagnostic.h> 0013 0014 #include <string> 0015 0016 class ClazyContext; 0017 0018 namespace clang 0019 { 0020 class Stmt; 0021 class Decl; 0022 class FunctionDecl; 0023 class ParmVarDecl; 0024 } 0025 0026 namespace clazy 0027 { 0028 struct QualTypeClassification; 0029 } 0030 0031 /** 0032 * Finds arguments that should be passed by value instead of const-ref 0033 * 0034 * See README-function-args-by-value for more info 0035 */ 0036 class FunctionArgsByValue : public CheckBase 0037 { 0038 public: 0039 explicit FunctionArgsByValue(const std::string &name, ClazyContext *context); 0040 void VisitDecl(clang::Decl *decl) override; 0041 void VisitStmt(clang::Stmt *stmt) override; 0042 0043 private: 0044 void processFunction(clang::FunctionDecl *); 0045 static bool shouldIgnoreClass(clang::CXXRecordDecl *); 0046 static bool shouldIgnoreOperator(clang::FunctionDecl *); 0047 static bool shouldIgnoreFunction(clang::FunctionDecl *); 0048 clang::FixItHint fixit(clang::FunctionDecl *func, const clang::ParmVarDecl *param, clazy::QualTypeClassification); 0049 }; 0050 0051 #endif