40 #include "llvm/ADT/SmallString.h"
42 using namespace clang;
47 template <
class T>
struct Rebuilder {
49 Rebuilder(
Sema &
S) : S(S) {}
51 T &getDerived() {
return static_cast<T&
>(*this); }
55 if (
typename T::specific_type *specific
56 = dyn_cast<typename T::specific_type>(e))
57 return getDerived().rebuildSpecific(specific);
62 if (
ParenExpr *parens = dyn_cast<ParenExpr>(e)) {
63 e = rebuild(parens->getSubExpr());
71 e = rebuild(uop->getSubExpr());
76 uop->getOperatorLoc());
80 assert(!gse->isResultDependent());
81 unsigned resultIndex = gse->getResultIndex();
82 unsigned numAssocs = gse->getNumAssocs();
87 for (
unsigned i = 0; i != numAssocs; ++i) {
88 Expr *assoc = gse->getAssocExpr(i);
89 if (i == resultIndex) assoc = rebuild(assoc);
91 assocTypes[i] = gse->getAssocTypeSourceInfo(i);
96 gse->getControllingExpr(),
101 gse->containsUnexpandedParameterPack(),
105 if (
ChooseExpr *ce = dyn_cast<ChooseExpr>(e)) {
106 assert(!ce->isConditionDependent());
108 Expr *LHS = ce->getLHS(), *RHS = ce->getRHS();
109 Expr *&rebuiltExpr = ce->isConditionTrue() ? LHS : RHS;
110 rebuiltExpr = rebuild(rebuiltExpr);
119 ce->isConditionTrue(),
124 llvm_unreachable(
"bad expression to rebuild!");
128 struct ObjCPropertyRefRebuilder : Rebuilder<ObjCPropertyRefRebuilder> {
130 ObjCPropertyRefRebuilder(
Sema &
S,
Expr *newBase)
131 : Rebuilder<ObjCPropertyRefRebuilder>(S), NewBase(newBase) {}
155 struct ObjCSubscriptRefRebuilder : Rebuilder<ObjCSubscriptRefRebuilder> {
158 ObjCSubscriptRefRebuilder(
Sema &
S,
Expr *newBase,
Expr *newKeyExpr)
159 : Rebuilder<ObjCSubscriptRefRebuilder>(S),
160 NewBase(newBase), NewKeyExpr(newKeyExpr) {}
177 struct MSPropertyRefRebuilder : Rebuilder<MSPropertyRefRebuilder> {
179 MSPropertyRefRebuilder(
Sema &
S,
Expr *newBase)
180 : Rebuilder<MSPropertyRefRebuilder>(S), NewBase(newBase) {}
194 class PseudoOpBuilder {
197 unsigned ResultIndex;
203 GenericLoc(genericLoc) {}
205 virtual ~PseudoOpBuilder() {}
208 void addSemanticExpr(
Expr *semantic) {
209 Semantics.push_back(semantic);
213 void addResultSemanticExpr(
Expr *resultExpr) {
215 ResultIndex = Semantics.size();
216 Semantics.push_back(resultExpr);
233 void setResultToLastSemantic() {
235 ResultIndex = Semantics.size() - 1;
239 bool CanCaptureValue(
Expr *
exp) {
247 return ClassDecl->isTriviallyCopyable();
251 virtual Expr *rebuildAndCaptureObject(
Expr *) = 0;
254 bool captureSetValueAsResult) = 0;
258 class ObjCPropertyOpBuilder :
public PseudoOpBuilder {
270 PseudoOpBuilder(S, refExpr->getLocation()), RefExpr(refExpr),
271 SyntacticRefExpr(nullptr), InstanceReceiver(nullptr), Getter(nullptr),
285 bool findSetter(
bool warn=
true);
287 void DiagnoseUnsupportedPropertyUse();
289 Expr *rebuildAndCaptureObject(
Expr *syntacticBase)
override;
294 bool isWeakProperty()
const;
298 class ObjCSubscriptOpBuilder :
public PseudoOpBuilder {
310 PseudoOpBuilder(S, refExpr->getSourceRange().getBegin()),
312 InstanceBase(nullptr), InstanceKey(nullptr),
313 AtIndexGetter(nullptr), AtIndexSetter(nullptr) {}
320 Expr *rebuildAndCaptureObject(
Expr *syntacticBase)
override;
322 bool findAtIndexGetter();
323 bool findAtIndexSetter();
329 class MSPropertyOpBuilder :
public PseudoOpBuilder {
334 PseudoOpBuilder(S, refExpr->getSourceRange().getBegin()),
337 Expr *rebuildAndCaptureObject(
Expr *)
override;
352 addSemanticExpr(captured);
367 if (!isa<OpaqueValueExpr>(e)) {
369 setResultToLastSemantic();
377 assert(index < Semantics.size() &&
378 "captured expression not found in semantics!");
379 if (e == Semantics[index])
break;
382 return cast<OpaqueValueExpr>(e);
388 Semantics, ResultIndex);
393 Expr *syntacticBase = rebuildAndCaptureObject(op);
397 addResultSemanticExpr(getExpr.
get());
399 return complete(syntacticBase);
411 if (isa<UnresolvedLookupExpr>(RHS))
414 Expr *syntacticLHS = rebuildAndCaptureObject(LHS);
421 result = capturedRHS;
423 opcode, capturedRHS->
getType(),
434 opLHS.
get(), capturedRHS);
439 result.
get()->getType(),
440 result.
get()->getValueKind(),
442 opLHS.
get()->getType(),
443 result.
get()->getType(),
449 result = buildSet(result.
get(), opcLoc,
true);
451 addSemanticExpr(result.
get());
453 return complete(syntactic);
464 Expr *syntacticOp = rebuildAndCaptureObject(op);
474 (result.
get()->isTypeDependent() || CanCaptureValue(result.
get()))) {
475 result = capture(result.
get());
476 setResultToLastSemantic();
495 addSemanticExpr(result.
get());
500 return complete(syntactic);
544 bool ObjCPropertyOpBuilder::isWeakProperty()
const {
546 if (RefExpr->isExplicitProperty()) {
549 return !Prop->
hasAttr<IBOutletAttr>();
553 T = Getter->getReturnType();
561 bool ObjCPropertyOpBuilder::findGetter() {
562 if (Getter)
return true;
565 if (RefExpr->isImplicitProperty()) {
566 if ((Getter = RefExpr->getImplicitPropertyGetter())) {
567 GetterSelector = Getter->getSelector();
573 assert(setter &&
"both setter and getter are null - cannot happen");
586 return (Getter !=
nullptr);
593 bool ObjCPropertyOpBuilder::findSetter(
bool warn) {
595 if (RefExpr->isImplicitProperty()) {
596 if (
ObjCMethodDecl *setter = RefExpr->getImplicitPropertySetter()) {
602 RefExpr->getImplicitPropertyGetter()->getSelector()
603 .getIdentifierInfoForSlot(0);
622 StringRef thisPropertyName = prop->
getName();
624 char front = thisPropertyName.front();
627 PropertyName[0] = front;
630 if (prop != prop1 && (prop1->getSetterMethodDecl() == setter)) {
631 S.
Diag(RefExpr->getExprLoc(), diag::error_property_setter_ambiguous_use)
634 S.
Diag(prop1->getLocation(), diag::note_property_declare);
649 void ObjCPropertyOpBuilder::DiagnoseUnsupportedPropertyUse() {
654 S.
Diag(RefExpr->getLocation(),
655 diag::err_property_function_in_objc_container);
662 Expr *ObjCPropertyOpBuilder::rebuildAndCaptureObject(
Expr *syntacticBase) {
663 assert(InstanceReceiver ==
nullptr);
667 if (RefExpr->isObjectReceiver()) {
668 InstanceReceiver = capture(RefExpr->getBase());
671 ObjCPropertyRefRebuilder(
S, InstanceReceiver).rebuild(syntacticBase);
675 refE = dyn_cast<ObjCPropertyRefExpr>(syntacticBase->IgnoreParens()))
676 SyntacticRefExpr = refE;
678 return syntacticBase;
682 ExprResult ObjCPropertyOpBuilder::buildGet() {
685 DiagnoseUnsupportedPropertyUse();
689 if (SyntacticRefExpr)
690 SyntacticRefExpr->setIsMessagingGetter();
693 if (!Getter->isImplicit())
697 if ((Getter->isInstanceMethod() && !RefExpr->isClassReceiver()) ||
698 RefExpr->isObjectReceiver()) {
699 assert(InstanceReceiver || RefExpr->isSuperReceiver());
701 GenericLoc, Getter->getSelector(),
705 GenericLoc, Getter->getSelector(),
716 bool captureSetValueAsResult) {
717 if (!findSetter(
false)) {
718 DiagnoseUnsupportedPropertyUse();
722 if (SyntacticRefExpr)
723 SyntacticRefExpr->setIsMessagingSetter();
731 QualType paramType = (*Setter->param_begin())->getType()
734 Setter->getDeclContext(),
746 assert(op &&
"successful assignment left argument invalid?");
749 Expr *Initializer = OVE->getSourceExpr();
753 if (isa<InitListExpr>(Initializer) &&
761 Expr *args[] = { op };
765 if (!Setter->isImplicit())
767 if ((Setter->isInstanceMethod() && !RefExpr->isClassReceiver()) ||
768 RefExpr->isObjectReceiver()) {
770 GenericLoc, SetterSelector, Setter,
775 SetterSelector, Setter,
779 if (!msg.
isInvalid() && captureSetValueAsResult) {
781 cast<ObjCMessageExpr>(msg.
get()->IgnoreImplicit());
783 if (CanCaptureValue(arg))
784 msgExpr->
setArg(0, captureValueAsResult(arg));
791 ExprResult ObjCPropertyOpBuilder::buildRValueOperation(
Expr *op) {
794 if (RefExpr->isImplicitProperty() && !RefExpr->getImplicitPropertyGetter()) {
795 S.
Diag(RefExpr->getLocation(), diag::err_getter_not_found)
796 << RefExpr->getSourceRange();
800 ExprResult result = PseudoOpBuilder::buildRValueOperation(op);
803 if (RefExpr->isExplicitProperty() && !Getter->hasRelatedResultType())
805 Getter, RefExpr->getLocation());
809 if (RefExpr->isExplicitProperty() && result.
get()->isRValue()) {
811 QualType propType = RefExpr->getExplicitProperty()
812 ->getUsageType(receiverType);
813 if (result.
get()->getType()->isObjCIdType()) {
816 if (!ptr->isObjCIdType())
823 if (!
S.
Diags.
isIgnored(diag::warn_arc_repeated_use_of_weak, RefExpr->getLocation()))
835 bool ObjCPropertyOpBuilder::tryBuildGetOfReference(
Expr *op,
848 QualType resultType = Getter->getReturnType();
851 result = buildRValueOperation(op);
857 ObjCPropertyOpBuilder::buildAssignmentOperation(
Scope *Sc,
867 if (tryBuildGetOfReference(LHS, result)) {
873 S.
Diag(opcLoc, diag::err_nosetter_property_assignment)
874 <<
unsigned(RefExpr->isImplicitProperty())
876 << LHS->getSourceRange() << RHS->getSourceRange();
883 if (opcode !=
BO_Assign && !findGetter()) {
884 S.
Diag(opcLoc, diag::err_nogetter_property_compound_assignment)
885 << LHS->getSourceRange() << RHS->getSourceRange();
890 PseudoOpBuilder::buildAssignmentOperation(Sc, opcLoc, opcode, LHS, RHS);
894 if (
S.
getLangOpts().ObjCAutoRefCount && InstanceReceiver) {
911 if (tryBuildGetOfReference(op, result)) {
917 S.
Diag(opcLoc, diag::err_nosetter_property_incdec)
918 <<
unsigned(RefExpr->isImplicitProperty())
921 << op->getSourceRange();
929 assert(RefExpr->isImplicitProperty());
930 S.
Diag(opcLoc, diag::err_nogetter_property_incdec)
933 << op->getSourceRange();
937 return PseudoOpBuilder::buildIncDecOperation(Sc, opcLoc, opcode, op);
941 if (
S.
getLangOpts().ObjCAutoRefCount && isWeakProperty() &&
943 SyntacticForm->getLocStart()))
945 SyntacticRefExpr->isMessagingGetter());
947 return PseudoOpBuilder::complete(SyntacticForm);
957 ExprResult ObjCSubscriptOpBuilder::buildRValueOperation(
Expr *op) {
958 ExprResult result = PseudoOpBuilder::buildRValueOperation(op);
965 ObjCSubscriptOpBuilder::buildAssignmentOperation(
Scope *Sc,
971 if (!findAtIndexSetter())
975 if (opcode !=
BO_Assign && !findAtIndexGetter())
979 PseudoOpBuilder::buildAssignmentOperation(Sc, opcLoc, opcode, LHS, RHS);
992 Expr *ObjCSubscriptOpBuilder::rebuildAndCaptureObject(
Expr *syntacticBase) {
993 assert(InstanceBase ==
nullptr);
997 InstanceBase = capture(RefExpr->getBaseExpr());
998 InstanceKey = capture(RefExpr->getKeyExpr());
1001 ObjCSubscriptRefRebuilder(
S, InstanceBase,
1002 InstanceKey).rebuild(syntacticBase);
1004 return syntacticBase;
1023 return OS_Dictionary;
1024 if (!getLangOpts().CPlusPlus ||
1028 if (isa<StringLiteral>(IndexExpr))
1032 Diag(FromE->
getExprLoc(), diag::err_objc_subscript_type_conversion)
1038 if (RequireCompleteType(FromE->
getExprLoc(), T,
1039 diag::err_objc_index_incomplete_class_type, FromE))
1044 int NoIntegrals=0, NoObjCIdPointers=0;
1048 ->getVisibleConversionFunctions()) {
1050 dyn_cast<CXXConversionDecl>(D->getUnderlyingDecl())) {
1051 QualType CT = Conversion->getConversionType().getNonReferenceType();
1054 ConversionDecls.push_back(Conversion);
1058 ConversionDecls.push_back(Conversion);
1062 if (NoIntegrals ==1 && NoObjCIdPointers == 0)
1064 if (NoIntegrals == 0 && NoObjCIdPointers == 1)
1065 return OS_Dictionary;
1066 if (NoIntegrals == 0 && NoObjCIdPointers == 0) {
1068 Diag(FromE->
getExprLoc(), diag::err_objc_subscript_type_conversion)
1072 Diag(FromE->
getExprLoc(), diag::err_objc_multiple_subscript_type_conversion)
1074 for (
unsigned int i = 0; i < ConversionDecls.size(); i++)
1075 Diag(ConversionDecls[i]->getLocation(), diag::not_conv_function_declared_at);
1101 bool ObjCSubscriptOpBuilder::findAtIndexGetter() {
1105 Expr *BaseExpr = RefExpr->getBaseExpr();
1118 RefExpr->getKeyExpr());
1123 if (ResultType.
isNull()) {
1125 << BaseExpr->
getType() << arrayRef;
1150 if (!AtIndexGetter &&
S.
getLangOpts().DebuggerObjCLiteral) {
1170 AtIndexGetter->setMethodParams(
S.
Context, Argument, None);
1173 if (!AtIndexGetter) {
1174 if (!receiverIdType) {
1175 S.
Diag(BaseExpr->
getExprLoc(), diag::err_objc_subscript_method_not_found)
1176 << BaseExpr->
getType() << 0 << arrayRef;
1181 RefExpr->getSourceRange(),
1185 if (AtIndexGetter) {
1186 QualType T = AtIndexGetter->parameters()[0]->getType();
1189 S.
Diag(RefExpr->getKeyExpr()->getExprLoc(),
1190 arrayRef ? diag::err_objc_subscript_index_type
1191 : diag::err_objc_subscript_key_type) << T;
1192 S.
Diag(AtIndexGetter->parameters()[0]->getLocation(),
1193 diag::note_parameter_type) << T;
1196 QualType R = AtIndexGetter->getReturnType();
1198 S.
Diag(RefExpr->getKeyExpr()->getExprLoc(),
1199 diag::err_objc_indexing_method_result_type) << R << arrayRef;
1200 S.
Diag(AtIndexGetter->getLocation(), diag::note_method_declared_at) <<
1201 AtIndexGetter->getDeclName();
1207 bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
1211 Expr *BaseExpr = RefExpr->getBaseExpr();
1225 RefExpr->getKeyExpr());
1230 if (ResultType.
isNull()) {
1232 << BaseExpr->
getType() << arrayRef;
1259 if (!AtIndexSetter &&
S.
getLangOpts().DebuggerObjCLiteral) {
1277 Params.push_back(
object);
1287 Params.push_back(key);
1288 AtIndexSetter->setMethodParams(
S.
Context, Params, None);
1291 if (!AtIndexSetter) {
1292 if (!receiverIdType) {
1294 diag::err_objc_subscript_method_not_found)
1295 << BaseExpr->
getType() << 1 << arrayRef;
1300 RefExpr->getSourceRange(),
1305 if (AtIndexSetter && arrayRef) {
1306 QualType T = AtIndexSetter->parameters()[1]->getType();
1308 S.
Diag(RefExpr->getKeyExpr()->getExprLoc(),
1309 diag::err_objc_subscript_index_type) << T;
1310 S.
Diag(AtIndexSetter->parameters()[1]->getLocation(),
1311 diag::note_parameter_type) << T;
1314 T = AtIndexSetter->parameters()[0]->getType();
1316 S.
Diag(RefExpr->getBaseExpr()->getExprLoc(),
1317 diag::err_objc_subscript_object_type) << T << arrayRef;
1318 S.
Diag(AtIndexSetter->parameters()[0]->getLocation(),
1319 diag::note_parameter_type) << T;
1323 else if (AtIndexSetter && !arrayRef)
1324 for (
unsigned i=0; i <2; i++) {
1325 QualType T = AtIndexSetter->parameters()[i]->getType();
1328 S.
Diag(RefExpr->getKeyExpr()->getExprLoc(),
1329 diag::err_objc_subscript_key_type) << T;
1331 S.
Diag(RefExpr->getBaseExpr()->getExprLoc(),
1332 diag::err_objc_subscript_dic_object_type) << T;
1333 S.
Diag(AtIndexSetter->parameters()[i]->getLocation(),
1334 diag::note_parameter_type) << T;
1344 ExprResult ObjCSubscriptOpBuilder::buildGet() {
1345 if (!findAtIndexGetter())
1348 QualType receiverType = InstanceBase->getType();
1352 Expr *Index = InstanceKey;
1355 Expr *args[] = { Index };
1356 assert(InstanceBase);
1361 AtIndexGetterSelector, AtIndexGetter,
1372 bool captureSetValueAsResult) {
1373 if (!findAtIndexSetter())
1377 QualType receiverType = InstanceBase->getType();
1378 Expr *Index = InstanceKey;
1381 Expr *args[] = { op, Index };
1386 AtIndexSetterSelector,
1390 if (!msg.
isInvalid() && captureSetValueAsResult) {
1392 cast<ObjCMessageExpr>(msg.
get()->IgnoreImplicit());
1394 if (CanCaptureValue(arg))
1395 msgExpr->
setArg(0, captureValueAsResult(arg));
1405 Expr *MSPropertyOpBuilder::rebuildAndCaptureObject(
Expr *syntacticBase) {
1406 Expr *NewBase = capture(RefExpr->getBaseExpr());
1409 MSPropertyRefRebuilder(
S, NewBase).rebuild(syntacticBase);
1411 return syntacticBase;
1415 if (!RefExpr->getPropertyDecl()->hasGetter()) {
1416 S.
Diag(RefExpr->getMemberLoc(), diag::err_no_accessor_for_property)
1417 << 0 << RefExpr->getPropertyDecl();
1425 SS.
Adopt(RefExpr->getQualifierLoc());
1428 RefExpr->isArrow() ? tok::arrow : tok::period, SS,
SourceLocation(),
1429 GetterName,
nullptr);
1431 S.
Diag(RefExpr->getMemberLoc(),
1432 diag::error_cannot_find_suitable_accessor) << 0
1433 << RefExpr->getPropertyDecl();
1439 RefExpr->getSourceRange().getBegin(), ArgExprs,
1440 RefExpr->getSourceRange().getEnd());
1444 bool captureSetValueAsResult) {
1445 if (!RefExpr->getPropertyDecl()->hasSetter()) {
1446 S.
Diag(RefExpr->getMemberLoc(), diag::err_no_accessor_for_property)
1447 << 1 << RefExpr->getPropertyDecl();
1455 SS.
Adopt(RefExpr->getQualifierLoc());
1458 RefExpr->isArrow() ? tok::arrow : tok::period, SS,
SourceLocation(),
1459 SetterName,
nullptr);
1461 S.
Diag(RefExpr->getMemberLoc(),
1462 diag::error_cannot_find_suitable_accessor) << 1
1463 << RefExpr->getPropertyDecl();
1468 ArgExprs.push_back(op);
1470 RefExpr->getSourceRange().getBegin(), ArgExprs,
1471 op->getSourceRange().getEnd());
1481 = dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
1482 ObjCPropertyOpBuilder builder(*
this, refExpr);
1483 return builder.buildRValueOperation(E);
1486 = dyn_cast<ObjCSubscriptRefExpr>(opaqueRef)) {
1487 ObjCSubscriptOpBuilder builder(*
this, refExpr);
1488 return builder.buildRValueOperation(E);
1490 = dyn_cast<MSPropertyRefExpr>(opaqueRef)) {
1491 MSPropertyOpBuilder builder(*
this, refExpr);
1492 return builder.buildRValueOperation(E);
1494 llvm_unreachable(
"unknown pseudo-object kind!");
1509 = dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
1510 ObjCPropertyOpBuilder builder(*
this, refExpr);
1511 return builder.buildIncDecOperation(Sc, opcLoc, opcode, op);
1512 }
else if (isa<ObjCSubscriptRefExpr>(opaqueRef)) {
1513 Diag(opcLoc, diag::err_illegal_container_subscripting_op);
1516 = dyn_cast<MSPropertyRefExpr>(opaqueRef)) {
1517 MSPropertyOpBuilder builder(*
this, refExpr);
1518 return builder.buildIncDecOperation(Sc, opcLoc, opcode, op);
1520 llvm_unreachable(
"unknown pseudo-object kind!");
1534 ExprResult result = CheckPlaceholderExpr(RHS);
1541 = dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
1542 ObjCPropertyOpBuilder builder(*
this, refExpr);
1543 return builder.buildAssignmentOperation(S, opcLoc, opcode, LHS, RHS);
1545 = dyn_cast<ObjCSubscriptRefExpr>(opaqueRef)) {
1546 ObjCSubscriptOpBuilder builder(*
this, refExpr);
1547 return builder.buildAssignmentOperation(S, opcLoc, opcode, LHS, RHS);
1549 = dyn_cast<MSPropertyRefExpr>(opaqueRef)) {
1550 MSPropertyOpBuilder builder(*
this, refExpr);
1551 return builder.buildAssignmentOperation(S, opcLoc, opcode, LHS, RHS);
1553 llvm_unreachable(
"unknown pseudo-object kind!");
1563 = dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
1565 if (refExpr->isClassReceiver() || refExpr->isSuperReceiver())
1568 assert(refExpr->isObjectReceiver() &&
"Unknown receiver kind?");
1570 return ObjCPropertyRefRebuilder(S, baseOVE->getSourceExpr()).rebuild(E);
1572 = dyn_cast<ObjCSubscriptRefExpr>(opaqueRef)) {
1574 OpaqueValueExpr *keyOVE = cast<OpaqueValueExpr>(refExpr->getKeyExpr());
1575 return ObjCSubscriptRefRebuilder(S, baseOVE->
getSourceExpr(),
1576 keyOVE->getSourceExpr()).rebuild(E);
1578 = dyn_cast<MSPropertyRefExpr>(opaqueRef)) {
1580 return MSPropertyRefRebuilder(S, baseOVE->
getSourceExpr()).rebuild(E);
1582 llvm_unreachable(
"unknown pseudo-object kind!");
1597 uop->getValueKind(), uop->getObjectKind(),
1598 uop->getOperatorLoc());
1600 = dyn_cast<CompoundAssignOperator>(syntax)) {
1602 Expr *rhs = cast<OpaqueValueExpr>(cop->getRHS())->getSourceExpr();
1605 cop->getValueKind(),
1606 cop->getObjectKind(),
1607 cop->getComputationLHSType(),
1608 cop->getComputationResultType(),
1609 cop->getOperatorLoc(),
false);
1610 }
else if (
BinaryOperator *bop = dyn_cast<BinaryOperator>(syntax)) {
1612 Expr *rhs = cast<OpaqueValueExpr>(bop->getRHS())->getSourceExpr();
1614 bop->
getType(), bop->getValueKind(),
1615 bop->getObjectKind(),
1616 bop->getOperatorLoc(),
false);
ExprObjectKind getObjectKind() const
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
Scope * getCurScope() const
Retrieve the parser's current scope.
StringRef getName() const
Expr * getSyntacticForm()
Smart pointer class that efficiently represents Objective-C method names.
bool isNonOverloadPlaceholderType() const
SelectorTable & getSelectorTable()
bool isObjCContainer() const
static Opcode getOpForCompoundAssignment(Opcode Opc)
ObjCInterfaceDecl * getClassInterface()
DeclContext * getCurLexicalContext() const
const LangOptions & getLangOpts() const
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
bool isRecordType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
ObjCMethodDecl * getAtIndexMethodDecl() const
bool isVoidPointerType() const
A container of type source information.
bool isBlockPointerType() const
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
bool isExplicitProperty() const
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
DiagnosticsEngine & Diags
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
static void CheckKeyForObjCARCConversion(Sema &S, QualType ContainerT, Expr *Key)
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false)
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
ObjCInterfaceDecl * getClassReceiver() const
ExprResult BuildClassMessageImplicit(QualType ReceiverType, bool isSuperReceiver, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static ObjCMethodDecl * LookupMethodInReceiverType(Sema &S, Selector sel, const ObjCPropertyRefExpr *PRE)
static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)
Return the default setter selector for the given identifier.
Represents a C++ unqualified-id that has been parsed.
Selector getNullarySelector(IdentifierInfo *ID)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static Expr * stripOpaqueValuesFromPseudoObjectRef(Sema &S, Expr *E)
bool isSuperReceiver() const
A builtin binary operation expression such as "x + y" or "x <= y".
bool isValueDependent() const
RecordDecl * getDecl() const
Selector getSetterName() const
Expr * getBaseExpr() const
Represents a C++ nested-name-specifier or a global scope specifier.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
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.
const Expr * getBase() const
Represents an ObjC class declaration.
ObjCMethodDecl * setAtIndexMethodDecl() const
PropertyAttributeKind getPropertyAttributes() const
MSPropertyDecl * getPropertyDecl() const
ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op)
Check an increment or decrement of a pseudo-object expression.
Sema - This implements semantic analysis and AST building for C.
bool isAssignmentOp() const
SourceLocation getMemberLoc() const
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - Returns lifetime attribute of this type.
NestedNameSpecifierLoc getQualifierLoc() const
QualType getPointeeType() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
StringRef getName() const
Return the actual identifier string.
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
TranslationUnitDecl * getTranslationUnitDecl() const
Defines the clang::Preprocessor interface.
ObjCMethodDecl * getImplicitPropertyGetter() const
DeclContext * getDeclContext()
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e. the innermost semantic parent of this con...
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
bool isObjCIdType() const
SourceLocation getLocation() const
bool isDependentType() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
An expression that sends a message to the given Objective-C object or class.
A member reference to an MSPropertyDecl.
Represents a C++ conversion function within a class.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
ArrayRef< ParmVarDecl * > parameters() const
SelectorTable & Selectors
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
SourceLocation getRBracket() const
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Expr * getSourceExpr() const
void checkRetainCycles(ObjCMessageExpr *msg)
Check a message send to see if it's likely to cause a retain cycle.
IdentifierTable & getIdentifierTable()
bool isPropertyAccessor() const
Represents one property declaration in an Objective-C interface.
bool isTypeDependent() const
sema::FunctionScopeInfo * getCurFunction() const
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool isObjectReceiver() const
MutableArrayRef< Expr * > MultiExprArg
SourceLocation getExprLoc() const LLVM_READONLY
Represents a C11 generic selection.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
void recordUseOfEvaluatedWeak(const ExprT *E, bool IsRead=true)
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
bool isClassReceiver() const
Selector getGetterName() const
Selector getSelector() const
ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)
bool isLValueReferenceType() const
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
Expr * getBaseExpr() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
QualType getPointeeType() const
ExprResult checkPseudoObjectRValue(Expr *E)
void markSafeWeakUse(const Expr *E)
static LLVM_READONLY bool isLowercase(unsigned char c)
Return true if this character is a lowercase ASCII letter: [a-z].
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
bool isDecrementOp() const
Decl::Kind getDeclKind() const
CanQualType UnsignedLongTy
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
bool isObjCQualifiedIdType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
QualType getSuperReceiverType() const
Expr * getKeyExpr() const
bool isIncrementOp() const
ObjCPropertyDecl * getExplicitProperty() const
Reading or writing from this object requires a barrier call.
bool isObjCClassType() const
Represents a C++ struct/union/class.
bool isObjCObjectPointerType() const
The parameter type of a method or function.
static LLVM_READONLY char toLowercase(char c)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds...
ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, SourceLocation Loc)
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
An l-value expression is a reference to an object with independent storage.
static LLVM_READONLY char toUppercase(char c)
SourceLocation getLocation() const
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isIncrementDecrementOp() const
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
ObjCMethodDecl * getImplicitPropertySetter() const
Expr * IgnoreParens() LLVM_READONLY