clang  20.0.0git
Macros | Typedefs | Functions
BodyFarm.cpp File Reference
#include "clang/Analysis/BodyFarm.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/Analysis/CodeInjector.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/OperatorKinds.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Debug.h"
#include <optional>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "body-farm"
 

Typedefs

typedef Stmt *(* FunctionFarmer) (ASTContext &C, const FunctionDecl *D)
 

Functions

static bool isDispatchBlock (QualType Ty)
 
static CallExprcreate_call_once_funcptr_call (ASTContext &C, ASTMaker M, const ParmVarDecl *Callback, ArrayRef< Expr * > CallArgs)
 
static CallExprcreate_call_once_lambda_call (ASTContext &C, ASTMaker M, const ParmVarDecl *Callback, CXXRecordDecl *CallbackDecl, ArrayRef< Expr * > CallArgs)
 
static Stmtcreate_std_move_forward (ASTContext &C, const FunctionDecl *D)
 Create a fake body for 'std::move' or 'std::forward'. More...
 
static Stmtcreate_call_once (ASTContext &C, const FunctionDecl *D)
 Create a fake body for std::call_once. More...
 
static Stmtcreate_dispatch_once (ASTContext &C, const FunctionDecl *D)
 Create a fake body for dispatch_once. More...
 
static Stmtcreate_dispatch_sync (ASTContext &C, const FunctionDecl *D)
 Create a fake body for dispatch_sync. More...
 
static Stmtcreate_OSAtomicCompareAndSwap (ASTContext &C, const FunctionDecl *D)
 
static const ObjCIvarDeclfindBackingIvar (const ObjCPropertyDecl *Prop)
 
static StmtcreateObjCPropertyGetter (ASTContext &Ctx, const ObjCMethodDecl *MD)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "body-farm"

Definition at line 29 of file BodyFarm.cpp.

Typedef Documentation

◆ FunctionFarmer

typedef Stmt*(* FunctionFarmer) (ASTContext &C, const FunctionDecl *D)

Definition at line 259 of file BodyFarm.cpp.

Function Documentation

◆ create_call_once()

static Stmt* create_call_once ( ASTContext C,
const FunctionDecl D 
)
static

Create a fake body for std::call_once.

Emulates the following function body:

typedef struct once_flag_s {
unsigned long __state = 0;
} once_flag;
template<class Callable>
void call_once(once_flag& o, Callable func) {
if (!o.__state) {
func();
}
o.__state = 1;
}

Definition at line 346 of file BodyFarm.cpp.

References D.

◆ create_call_once_funcptr_call()

static CallExpr* create_call_once_funcptr_call ( ASTContext C,
ASTMaker  M,
const ParmVarDecl Callback,
ArrayRef< Expr * >  CallArgs 
)
static

Definition at line 261 of file BodyFarm.cpp.

◆ create_call_once_lambda_call()

static CallExpr* create_call_once_lambda_call ( ASTContext C,
ASTMaker  M,
const ParmVarDecl Callback,
CXXRecordDecl CallbackDecl,
ArrayRef< Expr * >  CallArgs 
)
static

Definition at line 287 of file BodyFarm.cpp.

◆ create_dispatch_once()

static Stmt* create_dispatch_once ( ASTContext C,
const FunctionDecl D 
)
static

◆ create_dispatch_sync()

static Stmt* create_dispatch_sync ( ASTContext C,
const FunctionDecl D 
)
static

Create a fake body for dispatch_sync.

Definition at line 592 of file BodyFarm.cpp.

References clang::CallExpr::Create(), D, clang::ValueDecl::getType(), isDispatchBlock(), and clang::VK_PRValue.

◆ create_OSAtomicCompareAndSwap()

static Stmt* create_OSAtomicCompareAndSwap ( ASTContext C,
const FunctionDecl D 
)
static

◆ create_std_move_forward()

static Stmt* create_std_move_forward ( ASTContext C,
const FunctionDecl D 
)
static

Create a fake body for 'std::move' or 'std::forward'.

This is just:

return static_cast<return_type>(param);

Definition at line 320 of file BodyFarm.cpp.

References clang::interp::Cast(), and D.

◆ createObjCPropertyGetter()

static Stmt* createObjCPropertyGetter ( ASTContext Ctx,
const ObjCMethodDecl MD 
)
static

◆ findBackingIvar()

static const ObjCIvarDecl* findBackingIvar ( const ObjCPropertyDecl Prop)
static

◆ isDispatchBlock()

static bool isDispatchBlock ( QualType  Ty)
static