13#ifndef LLVM_CLANG_ANALYSIS_ANYCALL_H
14#define LLVM_CLANG_ANALYSIS_ANYCALL_H
19#include "llvm/ADT/SmallVector.h"
63 const Expr *E =
nullptr;
67 const Decl *D =
nullptr;
81 : E(ME), D(ME->getMethodDecl()), K(
ObjCMethod) {}
84 : E(NE), D(NE->getOperatorNew()), K(
Allocator) {}
87 : E(NE), D(NE->getOperatorDelete()), K(
Deallocator) {}
115 if (
const auto *ME = dyn_cast<ObjCMessageExpr>(E)) {
117 }
else if (
const auto *CE = dyn_cast<CallExpr>(E)) {
119 }
else if (
const auto *CXNE = dyn_cast<CXXNewExpr>(E)) {
121 }
else if (
const auto *CXDE = dyn_cast<CXXDeleteExpr>(E)) {
123 }
else if (
const auto *CXCE = dyn_cast<CXXConstructExpr>(E)) {
125 }
else if (
const auto *CXCIE = dyn_cast<CXXInheritedCtorInitExpr>(E)) {
136 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
138 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
149 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
150 return FD->parameters();
151 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
152 return MD->parameters();
153 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
154 return BD->parameters();
178 if (
const auto *MCE = dyn_cast<CXXMemberCallExpr>(CE))
179 Args.push_back(MCE->getImplicitObjectArgument());
180 Args.append(CE->arg_begin(), CE->arg_end());
182 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(CE))
185 if (
const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
186 FD && FD->isStatic() && OCE->getOperator() == OO_Call)
187 Args.erase(Args.begin());
192 return {CE->arg_begin(), CE->arg_end()};
196 return {ME->arg_begin(), ME->arg_end()};
200 return {CE->arg_begin(), CE->arg_end()};
208 llvm_unreachable(
"Unknown AnyCall::Kind");
239 llvm_unreachable(
"Unknown AnyCall::Kind");
245 if (
const auto *ND = dyn_cast_or_null<NamedDecl>(D))
246 return ND->getIdentifier();
Defines the clang::Expr interface and subclasses for C++ expressions.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
size_t param_size() const
AnyCall(const CXXConstructExpr *NE)
ArrayRef< ParmVarDecl * >::const_iterator param_const_iterator
param_const_iterator param_end() const
AnyCall(const CallExpr *CE)
const Decl * getDecl() const
AnyCall(const CXXDestructorDecl *D)
const IdentifierInfo * getIdentifier() const
param_const_iterator param_begin() const
AnyCall(const CXXNewExpr *NE)
static std::optional< AnyCall > forDecl(const Decl *D)
If D is a callable (Objective-C method or a function), return a constructed AnyCall object.
AnyCall(const ObjCMessageExpr *ME)
static std::optional< AnyCall > forExpr(const Expr *E)
If E is a generic call (to ObjC method /function/block/etc), return a constructed AnyCall object.
AnyCall(const CXXConstructorDecl *D)
AnyCall(const CXXInheritedCtorInitExpr *CIE)
ArrayRef< ParmVarDecl * > parameters() const
@ Destructor
An implicit C++ destructor call (called implicitly or by operator 'delete')
@ ObjCMethod
A call to an Objective-C method.
@ Deallocator
A C++ deallocation function call (operator delete), via C++ delete-expression.
@ Function
A function, function pointer, or a C++ method call.
@ Allocator
A C++ allocation function call (operator new), via C++ new-expression.
@ Constructor
An implicit or explicit C++ constructor call.
@ InheritedConstructor
A C++ inherited constructor produced by a "using T::T" directive.
@ Block
A call to an Objective-C block.
AnyCall(const ObjCMethodDecl *D)
QualType getReturnType(ASTContext &Ctx) const
const Expr * getArg(unsigned I) const
llvm::SmallVector< const Expr *, 4 > arguments() const
const Expr * getExpr() const
AnyCall(const CXXDeleteExpr *NE)
AnyCall(const FunctionDecl *D)
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents a C++ destructor within a class.
Represents a call to an inherited base class constructor from an inheriting constructor.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl - Represents an instance or class method declaration.
A (possibly-)qualified type.
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)