clang: lib/ASTMatchers/LowLevelHelpers.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14#include <type_traits>
15
18
25
26template
28 const ExprNode &Node,
29 llvm::function_ref<void(QualType , const Expr * )>
30 OnParamAndArg) {
31 static_assert(std::is_same_v<CallExpr, ExprNode> ||
32 std::is_same_v<CXXConstructExpr, ExprNode>);
33
34
35
36 unsigned ArgIndex = 0;
37 if (const auto *CE = dyn_cast(&Node)) {
38 const auto *MD = dyn_cast_or_null(CE->getDirectCallee());
39 if (MD && !MD->isExplicitObjectMemberFunction()) {
40
41
42
43
44 ++ArgIndex;
45 }
46 }
47
49
50 if (const auto *Call = dyn_cast(&Node)) {
51 if (const auto *Value =
52 dyn_cast_or_null(Call->getCalleeDecl())) {
54
55
56
59
62 assert(MP && "Must be member-pointer if its a memberfunctionpointer");
64 assert(FProto &&
65 "The call must have happened through a member function "
66 "pointer");
67 }
68 }
69 }
70
71 unsigned ParamIndex = 0;
72 unsigned NumArgs = Node.getNumArgs();
74 NumArgs = std::min(NumArgs, FProto->getNumParams());
75
76 for (; ArgIndex < NumArgs; ++ArgIndex, ++ParamIndex) {
78 if (FProto && FProto->getNumParams() > ParamIndex)
82 ParamType = FD->getParamDecl(ParamIndex)->getType();
83 else
84 continue;
85
86 OnParamAndArg(ParamType, Node.getArg(ArgIndex)->IgnoreParenCasts());
87 }
88}
89
92 llvm::function_ref<void(QualType , const Expr * )>
93 OnParamAndArg) {
95}
96
99 llvm::function_ref<void(QualType , const Expr * )>
100 OnParamAndArg) {
102}
103
104}
105
106}
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Represents a call to a C++ constructor.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
This represents one expression.
Represents a function declaration or definition.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
A pointer to member type per C++ 8.3.3 - Pointers to members.
A (possibly-)qualified type.
QualType getCanonicalType() const
bool isFunctionPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isMemberFunctionPointerType() const
const T * getAs() const
Member-template getAs'.
static const FunctionDecl * getCallee(const CXXConstructExpr &D)
Definition LowLevelHelpers.cpp:19
static void matchEachArgumentWithParamTypeImpl(const ExprNode &Node, llvm::function_ref< void(QualType, const Expr *)> OnParamAndArg)
Definition LowLevelHelpers.cpp:27
void matchEachArgumentWithParamType(const CallExpr &Node, llvm::function_ref< void(QualType, const Expr *)> OnParamAndArg)
Definition LowLevelHelpers.cpp:90
The JSON file list parser is used to communicate input to InstallAPI.