diff options
author | Alp Toker <alp@nuanti.com> | 2014-01-25 16:55:45 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-01-25 16:55:45 +0000 |
commit | 37545f747c61382bbf5291d28a47fef6fc4d2d0e (patch) | |
tree | d2e58c43721336cda82aa7e36b49ce3aa10e34fe /lib/Sema/SemaExprObjC.cpp | |
parent | 1c42a7d28ea54606d2edde52789b4b55bb27a561 (diff) | |
download | clang-37545f747c61382bbf5291d28a47fef6fc4d2d0e.tar.gz clang-37545f747c61382bbf5291d28a47fef6fc4d2d0e.tar.bz2 clang-37545f747c61382bbf5291d28a47fef6fc4d2d0e.tar.xz |
Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.
A result type is the (potentially adjusted) type of the value of an expression
that calls the function.
Rule of thumb:
* Declarations have return types and parameters.
* Expressions have result types and arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 87cff1273a..54aa6a610e 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -152,7 +152,7 @@ static bool validateBoxingMethod(Sema &S, SourceLocation Loc, } // Make sure the return type is reasonable. - QualType ReturnType = Method->getResultType(); + QualType ReturnType = Method->getReturnType(); if (!ReturnType->isObjCObjectPointerType()) { S.Diag(Loc, diag::err_objc_literal_method_sig) << Sel; @@ -224,16 +224,15 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, ObjCMethodDecl *Method = S.NSNumberDecl->lookupClassMethod(Sel); if (!Method && S.getLangOpts().DebuggerObjCLiteral) { // create a stub definition this NSNumber factory method. - TypeSourceInfo *ResultTInfo = 0; - Method = ObjCMethodDecl::Create(CX, SourceLocation(), SourceLocation(), Sel, - S.NSNumberPointer, ResultTInfo, - S.NSNumberDecl, - /*isInstance=*/false, /*isVariadic=*/false, - /*isPropertyAccessor=*/false, - /*isImplicitlyDeclared=*/true, - /*isDefined=*/false, - ObjCMethodDecl::Required, - /*HasRelatedResultType=*/false); + TypeSourceInfo *ReturnTInfo = 0; + Method = + ObjCMethodDecl::Create(CX, SourceLocation(), SourceLocation(), Sel, + S.NSNumberPointer, ReturnTInfo, S.NSNumberDecl, + /*isInstance=*/false, /*isVariadic=*/false, + /*isPropertyAccessor=*/false, + /*isImplicitlyDeclared=*/true, + /*isDefined=*/false, ObjCMethodDecl::Required, + /*HasRelatedResultType=*/false); ParmVarDecl *value = ParmVarDecl::Create(S.Context, Method, SourceLocation(), SourceLocation(), &CX.Idents.get("value"), @@ -492,17 +491,15 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { BoxingMethod = NSStringDecl->lookupClassMethod(stringWithUTF8String); if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) { // Debugger needs to work even if NSString hasn't been defined. - TypeSourceInfo *ResultTInfo = 0; - ObjCMethodDecl *M = - ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), - stringWithUTF8String, NSStringPointer, - ResultTInfo, NSStringDecl, - /*isInstance=*/false, /*isVariadic=*/false, - /*isPropertyAccessor=*/false, - /*isImplicitlyDeclared=*/true, - /*isDefined=*/false, - ObjCMethodDecl::Required, - /*HasRelatedResultType=*/false); + TypeSourceInfo *ReturnTInfo = 0; + ObjCMethodDecl *M = ObjCMethodDecl::Create( + Context, SourceLocation(), SourceLocation(), stringWithUTF8String, + NSStringPointer, ReturnTInfo, NSStringDecl, + /*isInstance=*/false, /*isVariadic=*/false, + /*isPropertyAccessor=*/false, + /*isImplicitlyDeclared=*/true, + /*isDefined=*/false, ObjCMethodDecl::Required, + /*HasRelatedResultType=*/false); QualType ConstCharType = Context.CharTy.withConst(); ParmVarDecl *value = ParmVarDecl::Create(Context, M, @@ -660,17 +657,14 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { Sel = NSAPIObj->getNSArraySelector(NSAPI::NSArr_arrayWithObjectsCount); ObjCMethodDecl *Method = NSArrayDecl->lookupClassMethod(Sel); if (!Method && getLangOpts().DebuggerObjCLiteral) { - TypeSourceInfo *ResultTInfo = 0; - Method = ObjCMethodDecl::Create(Context, - SourceLocation(), SourceLocation(), Sel, - IdT, - ResultTInfo, - Context.getTranslationUnitDecl(), - false /*Instance*/, false/*isVariadic*/, - /*isPropertyAccessor=*/false, - /*isImplicitlyDeclared=*/true, /*isDefined=*/false, - ObjCMethodDecl::Required, - false); + TypeSourceInfo *ReturnTInfo = 0; + Method = ObjCMethodDecl::Create( + Context, SourceLocation(), SourceLocation(), Sel, IdT, ReturnTInfo, + Context.getTranslationUnitDecl(), false /*Instance*/, + false /*isVariadic*/, + /*isPropertyAccessor=*/false, + /*isImplicitlyDeclared=*/true, /*isDefined=*/false, + ObjCMethodDecl::Required, false); SmallVector<ParmVarDecl *, 2> Params; ParmVarDecl *objects = ParmVarDecl::Create(Context, Method, SourceLocation(), @@ -1120,7 +1114,8 @@ QualType Sema::getMessageSendResultType(QualType ReceiverType, static const ObjCMethodDecl * findExplicitInstancetypeDeclarer(const ObjCMethodDecl *MD, QualType instancetype) { - if (MD->getResultType() == instancetype) return MD; + if (MD->getReturnType() == instancetype) + return MD; // For these purposes, a method in an @implementation overrides a // declaration in the @interface. @@ -1155,7 +1150,7 @@ void Sema::EmitRelatedResultTypeNoteForReturn(QualType destType) { // type doesn't match the method's declared return type. ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurContext); if (!MD || !MD->hasRelatedResultType() || - Context.hasSameUnqualifiedType(destType, MD->getResultType())) + Context.hasSameUnqualifiedType(destType, MD->getReturnType())) return; // Look for a method overridden by this method which explicitly uses @@ -1164,7 +1159,7 @@ void Sema::EmitRelatedResultTypeNoteForReturn(QualType destType) { findExplicitInstancetypeDeclarer(MD, Context.getObjCInstanceType())) { SourceLocation loc; SourceRange range; - if (TypeSourceInfo *TSI = overridden->getResultTypeSourceInfo()) { + if (TypeSourceInfo *TSI = overridden->getReturnTypeSourceInfo()) { range = TSI->getTypeLoc().getSourceRange(); loc = range.getBegin(); } @@ -1195,13 +1190,12 @@ void Sema::EmitRelatedResultTypeNote(const Expr *E) { if (!Method->hasRelatedResultType()) return; - - if (Context.hasSameUnqualifiedType(Method->getResultType() - .getNonReferenceType(), - MsgSend->getType())) + + if (Context.hasSameUnqualifiedType( + Method->getReturnType().getNonReferenceType(), MsgSend->getType())) return; - - if (!Context.hasSameUnqualifiedType(Method->getResultType(), + + if (!Context.hasSameUnqualifiedType(Method->getReturnType(), Context.getObjCInstanceType())) return; @@ -1287,7 +1281,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, ReturnType = getMessageSendResultType(ReceiverType, Method, isClassMessage, isSuperMessage); - VK = Expr::getValueKindForType(Method->getResultType()); + VK = Expr::getValueKindForType(Method->getReturnType()); unsigned NumNamedArgs = Sel.getNumArgs(); // Method might have more arguments than selector indicates. This is due @@ -1456,7 +1450,7 @@ static void DiagnoseARCUseOfWeakReceiver(Sema &S, Expr *Receiver) { if (PRE->isImplicitProperty()) { GDecl = PRE->getImplicitPropertyGetter(); if (GDecl) { - T = GDecl->getResultType(); + T = GDecl->getReturnType(); } } else { @@ -2115,8 +2109,8 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, ReturnType, VK)) return ExprError(); - if (Method && !Method->getResultType()->isVoidType() && - RequireCompleteType(LBracLoc, Method->getResultType(), + if (Method && !Method->getReturnType()->isVoidType() && + RequireCompleteType(LBracLoc, Method->getReturnType(), diag::err_illegal_message_expr_incomplete_type)) return ExprError(); @@ -2506,9 +2500,9 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, ClassMessage, SuperLoc.isValid(), LBracLoc, RBracLoc, ReturnType, VK)) return ExprError(); - - if (Method && !Method->getResultType()->isVoidType() && - RequireCompleteType(LBracLoc, Method->getResultType(), + + if (Method && !Method->getReturnType()->isVoidType() && + RequireCompleteType(LBracLoc, Method->getReturnType(), diag::err_illegal_message_expr_incomplete_type)) return ExprError(); @@ -2906,7 +2900,7 @@ namespace { ACCResult checkCallToFunction(FunctionDecl *fn) { // Require a CF*Ref return type. - if (!isCFType(fn->getResultType())) + if (!isCFType(fn->getReturnType())) return ACC_invalid; if (!isAnyRetainable(TargetClass)) @@ -2959,7 +2953,7 @@ namespace { // Check for message sends to functions returning CF types. We // just obey the Cocoa conventions with these, even though the // return type is CF. - if (!isAnyRetainable(TargetClass) || !isCFType(method->getResultType())) + if (!isAnyRetainable(TargetClass) || !isCFType(method->getReturnType())) return ACC_invalid; // If the method is explicitly marked not-retained, it's +0. |