21 #include "llvm/ADT/StringSwitch.h"
23 using namespace clang;
98 const_cast<Expr*
>(RHS),
100 C.getLogicalOperationType(),
114 const_cast<VarDecl*>(D),
123 return new (
C)
UnaryOperator(const_cast<Expr*>(Arg), UO_Deref, Ty,
129 const_cast<Expr*>(Arg),
nullptr,
VK_RValue);
134 return const_cast<Expr*>(Arg);
137 const_cast<Expr*>(Arg),
nullptr,
VK_RValue);
142 const_cast<Expr*>(Arg),
nullptr,
VK_RValue);
146 QualType Ty =
C.getBOOLDecl() ?
C.getBOOLType() :
C.ObjCBuiltinBoolTy;
217 M.makeLvalueToRvalue(
218 M.makeDeclRefExpr(Predicate), PredicateQPtrTy),
220 M.makeIntegralCast(IL, PredicateTy),
224 Stmt *Stmts[] = { B, CE };
229 M.makeLvalueToRvalue(
231 M.makeLvalueToRvalue(
232 M.makeDeclRefExpr(Predicate),
302 assert(OldValueTy == NewValueTy);
315 M.makeLvalueToRvalue(M.makeDeclRefExpr(OldValue), OldValueTy),
316 M.makeLvalueToRvalue(
318 M.makeLvalueToRvalue(M.makeDeclRefExpr(TheValue), TheValueTy),
328 M.makeLvalueToRvalue(M.makeDeclRefExpr(TheValue), TheValueTy),
330 M.makeLvalueToRvalue(M.makeDeclRefExpr(NewValue), NewValueTy),
333 Expr *BoolVal = M.makeObjCBool(
true);
334 Expr *RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal)
335 : M.makeIntegralCast(BoolVal, ResultTy);
336 Stmts[1] = M.makeReturn(RetVal);
340 BoolVal = M.makeObjCBool(
false);
341 RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal)
342 : M.makeIntegralCast(BoolVal, ResultTy);
343 Stmt *Else = M.makeReturn(RetVal);
357 return Val.getValue();
370 if (Name.startswith(
"OSAtomicCompareAndSwap") ||
371 Name.startswith(
"objc_atomicCompareAndSwap")) {
375 FF = llvm::StringSwitch<FunctionFarmer>(
Name)
381 if (FF) { Val = FF(C, D); }
382 else if (Injector) { Val = Injector->
getBody(D); }
383 return Val.getValue();
401 auto *Container = cast<ObjCContainerDecl>(Prop->getDeclContext());
403 if (
auto *InterfaceDecl = dyn_cast<ObjCInterfaceDecl>(Container)) {
404 PrimaryInterface = InterfaceDecl;
405 }
else if (
auto *CategoryDecl = dyn_cast<ObjCCategoryDecl>(Container)) {
406 PrimaryInterface = CategoryDecl->getClassInterface();
407 }
else if (
auto *ImplDecl = dyn_cast<ObjCImplDecl>(Container)) {
408 PrimaryInterface = ImplDecl->getClassInterface();
418 if (ShadowingProp && ShadowingProp != Prop) {
419 IVar = ShadowingProp->getPropertyIvarDecl();
445 if (
I->getPropertyDecl() != Prop)
448 if (
I->getGetterCXXConstructor()) {
450 return M.makeReturn(
I->getGetterCXXConstructor());
473 M.makeLvalueToRvalue(
474 M.makeDeclRefExpr(selfVar),
479 loadedIVar = M.makeLvalueToRvalue(loadedIVar, IVar->
getType());
481 return M.makeReturn(loadedIVar);
493 return Val.getValue();
514 return Val.getValue();
Defines the clang::ASTContext interface.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
IfStmt - This represents an if/then/else.
bool isBooleanType() const
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
static bool isDispatchBlock(QualType Ty)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCMethodDecl - Represents an instance or class method declaration.
unsigned param_size() const
ParmVarDecl - Represents a parameter to a function.
unsigned getNumParams() const
bool isComparisonOp() const
const ObjCInterfaceDecl * getContainingInterface() const
Return the class interface that this ivar is logically contained in; this is either the interface whe...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
bool isReferenceType() const
Defines the clang::CodeInjector interface which is responsible for injecting AST of function definiti...
QualType getReturnType() const
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
QualType getReturnType() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
A builtin binary operation expression such as "x + y" or "x <= y".
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An ordinary object is located at an address in memory.
Represents an ObjC class declaration.
propimpl_range property_impls() const
detail::InMemoryDirectory::const_iterator I
PropertyAttributeKind getPropertyAttributes() const
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
ObjCMethodDecl * getCanonicalDecl() override
virtual Stmt * getBody(const FunctionDecl *D)=0
CompoundStmt - This represents a group of statements like { stmt stmt }.
Represents a prototype with parameter type info, e.g.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
static const ObjCIvarDecl * findBackingIvar(const ObjCPropertyDecl *Prop)
QualType getPointeeType() const
Expr - This represents one expression.
const ParmVarDecl * getParamDecl(unsigned i) const
ImplicitParamDecl * getSelfDecl() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
static Stmt * create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
static Stmt * createObjCPropertyGetter(ASTContext &Ctx, const ObjCPropertyDecl *Prop)
Encodes a location in the source.
static Stmt * create_dispatch_sync(ASTContext &C, const FunctionDecl *D)
Create a fake body for dispatch_sync.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isPropertyAccessor() const
Represents one property declaration in an Objective-C interface.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
QualType getPointeeType() const
static Stmt * create_dispatch_once(ASTContext &C, const FunctionDecl *D)
Create a fake body for dispatch_once.
ObjCIvarDecl * getPropertyIvarDecl() const
Stmt * getBody(const FunctionDecl *D)
Factory method for creating bodies for ordinary functions.
size_t param_size() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
ObjCMethodDecl * getGetterMethodDecl() const
const T * getAs() const
Member-template getAs<specific type>'.
ObjCImplementationDecl * getImplementation() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
Stmt *(* FunctionFarmer)(ASTContext &C, const FunctionDecl *D)
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCPropertyQueryKind getQueryKind() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
A reference to a declared variable, function, enum, etc.
An l-value expression is a reference to an object with independent storage.
FunctionDecl * getCanonicalDecl() override
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).