Debian Codegraph @

src/StringUtils.cpp

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
5 SPDX-FileCopyrightText: 2015 Sergio Martins <[email protected]>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9
10 #include "StringUtils.h"
11
12 #include <string>
13 #include <vector>
14
15 namespace clang
16 {
17 class LangOptions;
18 } // namespace clang
19
20 using namespace clang;
21
22 std::string clazy::simpleArgTypeName(clang::FunctionDecl *func, unsigned int index, const clang::LangOptions &lo)
23 {
24 if (!func || index >= func->getNumParams()) {
25 return {};
26 }
27
28 ParmVarDecl *param = func->getParamDecl(index);
29 return simpleTypeName(param, lo);
30 }
31
32 bool clazy::anyArgIsOfSimpleType(clang::FunctionDecl *func, const std::string &simpleType, const clang::LangOptions &lo)
33 {
34 if (!func) {
35 return false;
36 }
37
38 return std::ranges::any_of(Utils::functionParameters(func), [simpleType, lo](ParmVarDecl *p) {
39 return simpleTypeName(p, lo) == simpleType;
40 });
41 }
42
43 bool clazy::anyArgIsOfAnySimpleType(clang::FunctionDecl *func, const std::vector<std::string> &simpleTypes, const clang::LangOptions &lo)
44 {
45 if (!func) {
46 return false;
47 }
48
49 return std::ranges::any_of(simpleTypes, [func, lo](const std::string &simpleType) {
50 return clazy::anyArgIsOfSimpleType(func, simpleType, lo);
51 });
52 }