summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaPseudoObject.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-07-30 19:24:48 +0000
committerFangrui Song <maskray@google.com>2018-07-30 19:24:48 +0000
commitabdbb605f2c3cbe63cd589da230f648535dff76b (patch)
tree5f8677c5a6cdf9e4aebd71560932f399f956f7cc /lib/Sema/SemaPseudoObject.cpp
parent19e630a4739c684e5848d2f926d0beb114bbce7b (diff)
downloadclang-abdbb605f2c3cbe63cd589da230f648535dff76b.tar.gz
Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaPseudoObject.cpp')
-rw-r--r--lib/Sema/SemaPseudoObject.cpp134
1 files changed, 67 insertions, 67 deletions
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp
index 4484e9b351..a8af75d87c 100644
--- a/lib/Sema/SemaPseudoObject.cpp
+++ b/lib/Sema/SemaPseudoObject.cpp
@@ -316,10 +316,10 @@ namespace {
OpaqueValueExpr *InstanceKey;
ObjCMethodDecl *AtIndexGetter;
Selector AtIndexGetterSelector;
-
+
ObjCMethodDecl *AtIndexSetter;
Selector AtIndexSetterSelector;
-
+
public:
ObjCSubscriptOpBuilder(Sema &S, ObjCSubscriptRefExpr *refExpr, bool IsUnique)
: PseudoOpBuilder(S, refExpr->getSourceRange().getBegin(), IsUnique),
@@ -367,7 +367,7 @@ namespace {
/// Capture the given expression in an OpaqueValueExpr.
OpaqueValueExpr *PseudoOpBuilder::capture(Expr *e) {
// Make a new OVE whose source is the given expression.
- OpaqueValueExpr *captured =
+ OpaqueValueExpr *captured =
new (S.Context) OpaqueValueExpr(GenericLoc, e->getType(),
e->getValueKind(), e->getObjectKind(),
e);
@@ -389,7 +389,7 @@ OpaqueValueExpr *PseudoOpBuilder::captureValueAsResult(Expr *e) {
assert(ResultIndex == PseudoObjectExpr::NoResult);
// If the expression hasn't already been captured, just capture it
- // and set the new semantic
+ // and set the new semantic
if (!isa<OpaqueValueExpr>(e)) {
OpaqueValueExpr *cap = capture(e);
setResultToLastSemantic();
@@ -618,11 +618,11 @@ bool ObjCPropertyOpBuilder::findGetter() {
// Must build the getter selector the hard way.
ObjCMethodDecl *setter = RefExpr->getImplicitPropertySetter();
assert(setter && "both setter and getter are null - cannot happen");
- IdentifierInfo *setterName =
+ IdentifierInfo *setterName =
setter->getSelector().getIdentifierInfoForSlot(0);
IdentifierInfo *getterName =
&S.Context.Idents.get(setterName->getName().substr(3));
- GetterSelector =
+ GetterSelector =
S.PP.getSelectorTable().getNullarySelector(getterName);
return false;
}
@@ -636,7 +636,7 @@ bool ObjCPropertyOpBuilder::findGetter() {
/// Try to find the most accurate setter declaration for the property
/// reference.
///
-/// \return true if a setter was found, in which case Setter
+/// \return true if a setter was found, in which case Setter
bool ObjCPropertyOpBuilder::findSetter(bool warn) {
// For implicit properties, just trust the lookup we already did.
if (RefExpr->isImplicitProperty()) {
@@ -987,9 +987,9 @@ ExprResult ObjCPropertyOpBuilder::complete(Expr *SyntacticForm) {
// ObjCSubscript build stuff.
//
-/// objective-c subscripting-specific behavior for doing lvalue-to-rvalue
+/// objective-c subscripting-specific behavior for doing lvalue-to-rvalue
/// conversion.
-/// FIXME. Remove this routine if it is proven that no additional
+/// FIXME. Remove this routine if it is proven that no additional
/// specifity is needed.
ExprResult ObjCSubscriptOpBuilder::buildRValueOperation(Expr *op) {
ExprResult result = PseudoOpBuilder::buildRValueOperation(op);
@@ -1007,21 +1007,21 @@ ObjCSubscriptOpBuilder::buildAssignmentOperation(Scope *Sc,
// There must be a method to do the Index'ed assignment.
if (!findAtIndexSetter())
return ExprError();
-
+
// Verify that we can do a compound assignment.
if (opcode != BO_Assign && !findAtIndexGetter())
return ExprError();
-
+
ExprResult result =
PseudoOpBuilder::buildAssignmentOperation(Sc, opcLoc, opcode, LHS, RHS);
if (result.isInvalid()) return ExprError();
-
+
// Various warnings about objc Index'ed assignments in ARC.
if (S.getLangOpts().ObjCAutoRefCount && InstanceBase) {
S.checkRetainCycles(InstanceBase->getSourceExpr(), RHS);
S.checkUnsafeExprAssigns(opcLoc, LHS, RHS);
}
-
+
return result;
}
@@ -1049,15 +1049,15 @@ Expr *ObjCSubscriptOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) {
return syntacticBase;
}
-/// CheckSubscriptingKind - This routine decide what type
+/// CheckSubscriptingKind - This routine decide what type
/// of indexing represented by "FromE" is being done.
-Sema::ObjCSubscriptKind
+Sema::ObjCSubscriptKind
Sema::CheckSubscriptingKind(Expr *FromE) {
// If the expression already has integral or enumeration type, we're golden.
QualType T = FromE->getType();
if (T->isIntegralOrEnumerationType())
return OS_Array;
-
+
// If we don't have a class type in C++, there's no way we can get an
// expression of integral or enumeration type.
const RecordType *RecordTy = T->getAs<RecordType>();
@@ -1066,7 +1066,7 @@ Sema::ObjCSubscriptKind
// All other scalar cases are assumed to be dictionary indexing which
// caller handles, with diagnostics if needed.
return OS_Dictionary;
- if (!getLangOpts().CPlusPlus ||
+ if (!getLangOpts().CPlusPlus ||
!RecordTy || RecordTy->isIncompleteType()) {
// No indexing can be done. Issue diagnostics and quit.
const Expr *IndexExpr = FromE->IgnoreParenImpCasts();
@@ -1078,12 +1078,12 @@ Sema::ObjCSubscriptKind
<< T;
return OS_Error;
}
-
+
// We must have a complete class type.
- if (RequireCompleteType(FromE->getExprLoc(), T,
+ if (RequireCompleteType(FromE->getExprLoc(), T,
diag::err_objc_index_incomplete_class_type, FromE))
return OS_Error;
-
+
// Look for a conversion to an integral, enumeration type, or
// objective-C pointer type.
int NoIntegrals=0, NoObjCIdPointers=0;
@@ -1125,17 +1125,17 @@ Sema::ObjCSubscriptKind
/// CheckKeyForObjCARCConversion - This routine suggests bridge casting of CF
/// objects used as dictionary subscript key objects.
-static void CheckKeyForObjCARCConversion(Sema &S, QualType ContainerT,
+static void CheckKeyForObjCARCConversion(Sema &S, QualType ContainerT,
Expr *Key) {
if (ContainerT.isNull())
return;
// dictionary subscripting.
// - (id)objectForKeyedSubscript:(id)key;
IdentifierInfo *KeyIdents[] = {
- &S.Context.Idents.get("objectForKeyedSubscript")
+ &S.Context.Idents.get("objectForKeyedSubscript")
};
Selector GetterSelector = S.Context.Selectors.getSelector(1, KeyIdents);
- ObjCMethodDecl *Getter = S.LookupMethodInObjectType(GetterSelector, ContainerT,
+ ObjCMethodDecl *Getter = S.LookupMethodInObjectType(GetterSelector, ContainerT,
true /*instance*/);
if (!Getter)
return;
@@ -1147,25 +1147,25 @@ static void CheckKeyForObjCARCConversion(Sema &S, QualType ContainerT,
bool ObjCSubscriptOpBuilder::findAtIndexGetter() {
if (AtIndexGetter)
return true;
-
+
Expr *BaseExpr = RefExpr->getBaseExpr();
QualType BaseT = BaseExpr->getType();
-
+
QualType ResultType;
if (const ObjCObjectPointerType *PTy =
BaseT->getAs<ObjCObjectPointerType>()) {
ResultType = PTy->getPointeeType();
}
- Sema::ObjCSubscriptKind Res =
+ Sema::ObjCSubscriptKind Res =
S.CheckSubscriptingKind(RefExpr->getKeyExpr());
if (Res == Sema::OS_Error) {
if (S.getLangOpts().ObjCAutoRefCount)
- CheckKeyForObjCARCConversion(S, ResultType,
+ CheckKeyForObjCARCConversion(S, ResultType,
RefExpr->getKeyExpr());
return false;
}
bool arrayRef = (Res == Sema::OS_Array);
-
+
if (ResultType.isNull()) {
S.Diag(BaseExpr->getExprLoc(), diag::err_objc_subscript_base_type)
<< BaseExpr->getType() << arrayRef;
@@ -1175,24 +1175,24 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() {
// dictionary subscripting.
// - (id)objectForKeyedSubscript:(id)key;
IdentifierInfo *KeyIdents[] = {
- &S.Context.Idents.get("objectForKeyedSubscript")
+ &S.Context.Idents.get("objectForKeyedSubscript")
};
AtIndexGetterSelector = S.Context.Selectors.getSelector(1, KeyIdents);
}
else {
// - (id)objectAtIndexedSubscript:(size_t)index;
IdentifierInfo *KeyIdents[] = {
- &S.Context.Idents.get("objectAtIndexedSubscript")
+ &S.Context.Idents.get("objectAtIndexedSubscript")
};
-
+
AtIndexGetterSelector = S.Context.Selectors.getSelector(1, KeyIdents);
}
-
- AtIndexGetter = S.LookupMethodInObjectType(AtIndexGetterSelector, ResultType,
+
+ AtIndexGetter = S.LookupMethodInObjectType(AtIndexGetterSelector, ResultType,
true /*instance*/);
-
+
if (!AtIndexGetter && S.getLangOpts().DebuggerObjCLiteral) {
- AtIndexGetter = ObjCMethodDecl::Create(S.Context, SourceLocation(),
+ AtIndexGetter = ObjCMethodDecl::Create(S.Context, SourceLocation(),
SourceLocation(), AtIndexGetterSelector,
S.Context.getObjCIdType() /*ReturnType*/,
nullptr /*TypeSourceInfo */,
@@ -1220,20 +1220,20 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() {
<< BaseExpr->getType() << 0 << arrayRef;
return false;
}
- AtIndexGetter =
- S.LookupInstanceMethodInGlobalPool(AtIndexGetterSelector,
- RefExpr->getSourceRange(),
+ AtIndexGetter =
+ S.LookupInstanceMethodInGlobalPool(AtIndexGetterSelector,
+ RefExpr->getSourceRange(),
true);
}
-
+
if (AtIndexGetter) {
QualType T = AtIndexGetter->parameters()[0]->getType();
if ((arrayRef && !T->isIntegralOrEnumerationType()) ||
(!arrayRef && !T->isObjCObjectPointerType())) {
- S.Diag(RefExpr->getKeyExpr()->getExprLoc(),
+ S.Diag(RefExpr->getKeyExpr()->getExprLoc(),
arrayRef ? diag::err_objc_subscript_index_type
: diag::err_objc_subscript_key_type) << T;
- S.Diag(AtIndexGetter->parameters()[0]->getLocation(),
+ S.Diag(AtIndexGetter->parameters()[0]->getLocation(),
diag::note_parameter_type) << T;
return false;
}
@@ -1251,32 +1251,32 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() {
bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
if (AtIndexSetter)
return true;
-
+
Expr *BaseExpr = RefExpr->getBaseExpr();
QualType BaseT = BaseExpr->getType();
-
+
QualType ResultType;
if (const ObjCObjectPointerType *PTy =
BaseT->getAs<ObjCObjectPointerType>()) {
ResultType = PTy->getPointeeType();
}
-
- Sema::ObjCSubscriptKind Res =
+
+ Sema::ObjCSubscriptKind Res =
S.CheckSubscriptingKind(RefExpr->getKeyExpr());
if (Res == Sema::OS_Error) {
if (S.getLangOpts().ObjCAutoRefCount)
- CheckKeyForObjCARCConversion(S, ResultType,
+ CheckKeyForObjCARCConversion(S, ResultType,
RefExpr->getKeyExpr());
return false;
}
bool arrayRef = (Res == Sema::OS_Array);
-
+
if (ResultType.isNull()) {
S.Diag(BaseExpr->getExprLoc(), diag::err_objc_subscript_base_type)
<< BaseExpr->getType() << arrayRef;
return false;
}
-
+
if (!arrayRef) {
// dictionary subscripting.
// - (void)setObject:(id)object forKeyedSubscript:(id)key;
@@ -1294,7 +1294,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
};
AtIndexSetterSelector = S.Context.Selectors.getSelector(2, KeyIdents);
}
- AtIndexSetter = S.LookupMethodInObjectType(AtIndexSetterSelector, ResultType,
+ AtIndexSetter = S.LookupMethodInObjectType(AtIndexSetterSelector, ResultType,
true /*instance*/);
if (!AtIndexSetter && S.getLangOpts().DebuggerObjCLiteral) {
@@ -1328,35 +1328,35 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
Params.push_back(key);
AtIndexSetter->setMethodParams(S.Context, Params, None);
}
-
+
if (!AtIndexSetter) {
if (!BaseT->isObjCIdType()) {
- S.Diag(BaseExpr->getExprLoc(),
+ S.Diag(BaseExpr->getExprLoc(),
diag::err_objc_subscript_method_not_found)
<< BaseExpr->getType() << 1 << arrayRef;
return false;
}
- AtIndexSetter =
- S.LookupInstanceMethodInGlobalPool(AtIndexSetterSelector,
- RefExpr->getSourceRange(),
+ AtIndexSetter =
+ S.LookupInstanceMethodInGlobalPool(AtIndexSetterSelector,
+ RefExpr->getSourceRange(),
true);
}
-
+
bool err = false;
if (AtIndexSetter && arrayRef) {
QualType T = AtIndexSetter->parameters()[1]->getType();
if (!T->isIntegralOrEnumerationType()) {
- S.Diag(RefExpr->getKeyExpr()->getExprLoc(),
+ S.Diag(RefExpr->getKeyExpr()->getExprLoc(),
diag::err_objc_subscript_index_type) << T;
- S.Diag(AtIndexSetter->parameters()[1]->getLocation(),
+ S.Diag(AtIndexSetter->parameters()[1]->getLocation(),
diag::note_parameter_type) << T;
err = true;
}
T = AtIndexSetter->parameters()[0]->getType();
if (!T->isObjCObjectPointerType()) {
- S.Diag(RefExpr->getBaseExpr()->getExprLoc(),
+ S.Diag(RefExpr->getBaseExpr()->getExprLoc(),
diag::err_objc_subscript_object_type) << T << arrayRef;
- S.Diag(AtIndexSetter->parameters()[0]->getLocation(),
+ S.Diag(AtIndexSetter->parameters()[0]->getLocation(),
diag::note_parameter_type) << T;
err = true;
}
@@ -1371,7 +1371,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
else
S.Diag(RefExpr->getBaseExpr()->getExprLoc(),
diag::err_objc_subscript_dic_object_type) << T;
- S.Diag(AtIndexSetter->parameters()[i]->getLocation(),
+ S.Diag(AtIndexSetter->parameters()[i]->getLocation(),
diag::note_parameter_type) << T;
err = true;
}
@@ -1385,13 +1385,13 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
ExprResult ObjCSubscriptOpBuilder::buildGet() {
if (!findAtIndexGetter())
return ExprError();
-
+
QualType receiverType = InstanceBase->getType();
-
+
// Build a message-send.
ExprResult msg;
Expr *Index = InstanceKey;
-
+
// Arguments.
Expr *args[] = { Index };
assert(InstanceBase);
@@ -1417,17 +1417,17 @@ ExprResult ObjCSubscriptOpBuilder::buildSet(Expr *op, SourceLocation opcLoc,
S.DiagnoseUseOfDecl(AtIndexSetter, GenericLoc);
QualType receiverType = InstanceBase->getType();
Expr *Index = InstanceKey;
-
+
// Arguments.
Expr *args[] = { op, Index };
-
+
// Build a message-send.
ExprResult msg = S.BuildInstanceMessageImplicit(InstanceBase, receiverType,
GenericLoc,
AtIndexSetterSelector,
AtIndexSetter,
MultiExprArg(args, 2));
-
+
if (!msg.isInvalid() && captureSetValueAsResult) {
ObjCMessageExpr *msgExpr =
cast<ObjCMessageExpr>(msg.get()->IgnoreImplicit());
@@ -1435,7 +1435,7 @@ ExprResult ObjCSubscriptOpBuilder::buildSet(Expr *op, SourceLocation opcLoc,
if (CanCaptureValue(arg))
msgExpr->setArg(0, captureValueAsResult(arg));
}
-
+
return msg;
}