20 const Expr *
E,
bool StopAtFirstRefCountedObj,
21 std::function<
bool(
const clang::Expr *,
bool)> callback) {
23 if (
auto *tempExpr = dyn_cast<MaterializeTemporaryExpr>(
E)) {
24 E = tempExpr->getSubExpr();
27 if (
auto *tempExpr = dyn_cast<CXXBindTemporaryExpr>(
E)) {
28 E = tempExpr->getSubExpr();
31 if (
auto *tempExpr = dyn_cast<CXXTemporaryObjectExpr>(
E)) {
32 if (
auto *
C = tempExpr->getConstructor()) {
34 return callback(
E,
true);
38 if (
auto *tempExpr = dyn_cast<ParenExpr>(
E)) {
39 E = tempExpr->getSubExpr();
42 if (
auto *
Expr = dyn_cast<ConditionalOperator>(
E)) {
48 if (
auto *
cast = dyn_cast<CastExpr>(
E)) {
49 if (StopAtFirstRefCountedObj) {
50 if (
auto *ConversionFunc =
51 dyn_cast_or_null<FunctionDecl>(
cast->getConversionFunction())) {
53 return callback(
E,
true);
58 E =
cast->getSubExpr();
61 if (
auto *call = dyn_cast<CallExpr>(
E)) {
62 if (
auto *memberCall = dyn_cast<CXXMemberCallExpr>(call)) {
63 if (
auto *
decl = memberCall->getMethodDecl()) {
65 if (IsGetterOfRefCt && *IsGetterOfRefCt) {
66 E = memberCall->getImplicitObjectArgument();
67 if (StopAtFirstRefCountedObj) {
68 return callback(
E,
true);
75 if (
auto *operatorCall = dyn_cast<CXXOperatorCallExpr>(
E)) {
76 if (operatorCall->getNumArgs() == 1) {
77 E = operatorCall->getArg(0);
82 if (
auto *callee = call->getDirectCallee()) {
84 if (StopAtFirstRefCountedObj)
85 return callback(
E,
true);
92 return callback(
E,
true);
95 return callback(
E,
true);
103 if (
auto *unaryOp = dyn_cast<UnaryOperator>(
E)) {
105 E = unaryOp->getSubExpr();
112 return callback(
E,
false);
117 if (
auto *Ref = dyn_cast<DeclRefExpr>(
E)) {
118 if (
auto *
D = dyn_cast_or_null<VarDecl>(Ref->getFoundDecl())) {
119 if (isa<ParmVarDecl>(
D) ||
D->isLocalVarDecl())
125 return isa<CXXThisExpr>(
E);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
This represents one expression.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
std::optional< bool > isGetterOfRefCounted(const CXXMethodDecl *M)
bool isPtrConversion(const FunctionDecl *F)
bool isCtorOfRefCounted(const clang::FunctionDecl *F)
bool isASafeCallArg(const Expr *E)
For E referring to a ref-countable/-counted pointer/reference we return whether it's a safe call argu...
bool isSingleton(const FunctionDecl *F)
bool isRefCounted(const CXXRecordDecl *R)
bool isReturnValueRefCounted(const clang::FunctionDecl *F)
bool tryToFindPtrOrigin(const Expr *E, bool StopAtFirstRefCountedObj, std::function< bool(const clang::Expr *, bool)> callback)
This function de-facto defines a set of transformations that we consider safe (in heuristical sense).
U cast(CodeGen::Address addr)
@ Class
The "class" keyword introduces the elaborated-type-specifier.