diff options
Diffstat (limited to 'clang/lib/Sema')
25 files changed, 342 insertions, 374 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 9864072b722..b13831908b4 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -431,18 +431,18 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body, bool HasNoReturn = false; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { - ReturnsVoid = FD->getResultType()->isVoidType(); + ReturnsVoid = FD->getReturnType()->isVoidType(); HasNoReturn = FD->isNoReturn(); } else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { - ReturnsVoid = MD->getResultType()->isVoidType(); + ReturnsVoid = MD->getReturnType()->isVoidType(); HasNoReturn = MD->hasAttr<NoReturnAttr>(); } else if (isa<BlockDecl>(D)) { QualType BlockTy = blkExpr->getType(); if (const FunctionType *FT = BlockTy->getPointeeType()->getAs<FunctionType>()) { - if (FT->getResultType()->isVoidType()) + if (FT->getReturnType()->isVoidType()) ReturnsVoid = true; if (FT->getNoReturnAttr()) HasNoReturn = true; diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 0d944708d2d..3a5f8453cf1 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1240,7 +1240,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, ZeroArgCallReturnTy = QualType(); Ambiguous = true; } else - ZeroArgCallReturnTy = OverloadDecl->getResultType(); + ZeroArgCallReturnTy = OverloadDecl->getReturnType(); } } } @@ -1269,7 +1269,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, if (const DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E.IgnoreParens())) { if (const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) { if (Fun->getMinRequiredArguments() == 0) - ZeroArgCallReturnTy = Fun->getResultType(); + ZeroArgCallReturnTy = Fun->getReturnType(); return true; } } @@ -1287,7 +1287,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, if (const FunctionProtoType *FPT = dyn_cast_or_null<FunctionProtoType>(FunTy)) { if (FPT->getNumParams() == 0) - ZeroArgCallReturnTy = FunTy->getResultType(); + ZeroArgCallReturnTy = FunTy->getReturnType(); return true; } return false; @@ -1338,7 +1338,7 @@ static void notePlausibleOverloads(Sema &S, SourceLocation Loc, for (OverloadExpr::decls_iterator It = Overloads.begin(), DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) { const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It); - QualType OverloadResultTy = OverloadDecl->getResultType(); + QualType OverloadResultTy = OverloadDecl->getReturnType(); if (IsPlausibleResult(OverloadResultTy)) PlausibleOverloads.addDecl(It.getDecl()); } diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index 7b0eaaac39f..47aea375939 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -379,9 +379,8 @@ static bool MightInstantiateTo(Sema &S, if (FriendTy->getNumParams() != ContextTy->getNumParams()) return false; - if (!MightInstantiateTo(S, - ContextTy->getResultType(), - FriendTy->getResultType())) + if (!MightInstantiateTo(S, ContextTy->getReturnType(), + FriendTy->getReturnType())) return false; for (unsigned I = 0, E = FriendTy->getNumParams(); I != E; ++I) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 472ae4de8dc..3e6b39a09b3 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2946,7 +2946,7 @@ bool CheckPrintfHandler::checkForCStrMembers( MI != ME; ++MI) { const CXXMethodDecl *Method = *MI; if (Method->getNumParams() == 0 && - AT.matchesType(S.Context, Method->getResultType())) { + AT.matchesType(S.Context, Method->getReturnType())) { // FIXME: Suggest parens if the expression needs them. SourceLocation EndLoc = S.getPreprocessor().getLocForEndOfToken(E->getLocEnd()); diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 33909c73077..78dd5cd3055 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -697,7 +697,7 @@ QualType clang::getDeclUsageType(ASTContext &C, const NamedDecl *ND) { } if (const FunctionType *Function = T->getAs<FunctionType>()) { - T = Function->getResultType(); + T = Function->getReturnType(); continue; } @@ -1781,10 +1781,10 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, // know the function is void or not. bool isVoid = false; if (FunctionDecl *Function = dyn_cast<FunctionDecl>(SemaRef.CurContext)) - isVoid = Function->getResultType()->isVoidType(); + isVoid = Function->getReturnType()->isVoidType(); else if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(SemaRef.CurContext)) - isVoid = Method->getResultType()->isVoidType(); + isVoid = Method->getReturnType()->isVoidType(); else if (SemaRef.getCurBlock() && !SemaRef.getCurBlock()->ReturnType.isNull()) isVoid = SemaRef.getCurBlock()->ReturnType->isVoidType(); @@ -2065,9 +2065,9 @@ static void AddResultTypeChunk(ASTContext &Context, // Determine the type of the declaration (if it has a type). QualType T; if (const FunctionDecl *Function = ND->getAsFunction()) - T = Function->getResultType(); + T = Function->getReturnType(); else if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) - T = Method->getResultType(); + T = Method->getReturnType(); else if (const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND)) T = Context.getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext())); else if (isa<UnresolvedUsingValueDecl>(ND)) { @@ -2200,7 +2200,7 @@ static std::string FormatFunctionParameter(ASTContext &Context, // We have the function prototype behind the block pointer type, as it was // written in the source. std::string Result; - QualType ResultType = Block.getTypePtr()->getResultType(); + QualType ResultType = Block.getTypePtr()->getReturnType(); if (!ResultType->isVoidType() || SuppressBlock) ResultType.getAsStringInternal(Result, Policy); @@ -2830,9 +2830,8 @@ CodeCompleteConsumer::OverloadCandidate::CreateSignatureString( // Function without a prototype. Just give the return type and a // highlighted ellipsis. const FunctionType *FT = getFunctionType(); - Result.AddTextChunk(GetCompletionTypeString(FT->getResultType(), - S.Context, Policy, - Result.getAllocator())); + Result.AddTextChunk(GetCompletionTypeString(FT->getReturnType(), S.Context, + Policy, Result.getAllocator())); Result.AddChunk(CodeCompletionString::CK_LeftParen); Result.AddChunk(CodeCompletionString::CK_CurrentParameter, "..."); Result.AddChunk(CodeCompletionString::CK_RightParen); @@ -2843,10 +2842,9 @@ CodeCompleteConsumer::OverloadCandidate::CreateSignatureString( Result.AddTextChunk( Result.getAllocator().CopyString(FDecl->getNameAsString())); else - Result.AddTextChunk( - Result.getAllocator().CopyString( - Proto->getResultType().getAsString(Policy))); - + Result.AddTextChunk(Result.getAllocator().CopyString( + Proto->getReturnType().getAsString(Policy))); + Result.AddChunk(CodeCompletionString::CK_LeftParen); unsigned NumParams = FDecl ? FDecl->getNumParams() : Proto->getNumParams(); for (unsigned I = 0; I != NumParams; ++I) { @@ -3977,10 +3975,10 @@ void Sema::CodeCompleteReturn(Scope *S) { if (BlockScopeInfo *BSI = getCurBlock()) ResultType = BSI->ReturnType; } else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext)) - ResultType = Function->getResultType(); + ResultType = Function->getReturnType(); else if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext)) - ResultType = Method->getResultType(); - + ResultType = Method->getReturnType(); + if (ResultType.isNull()) CodeCompleteOrdinaryName(S, PCC_Expression); else @@ -6196,7 +6194,7 @@ static void FindImplementableMethods(ASTContext &Context, M != MEnd; ++M) { if (M->isInstanceMethod() == WantInstanceMethods) { if (!ReturnType.isNull() && - !Context.hasSameUnqualifiedType(ReturnType, M->getResultType())) + !Context.hasSameUnqualifiedType(ReturnType, M->getReturnType())) continue; KnownMethods[M->getSelector()] = @@ -6921,10 +6919,9 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, // If the result type was not already provided, add it to the // pattern as (type). if (ReturnType.isNull()) - AddObjCPassingTypeChunk(Method->getResultType(), - Method->getObjCDeclQualifier(), - Context, Policy, - Builder); + AddObjCPassingTypeChunk(Method->getReturnType(), + Method->getObjCDeclQualifier(), Context, Policy, + Builder); Selector Sel = Method->getSelector(); @@ -6968,7 +6965,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); Builder.AddChunk(CodeCompletionString::CK_LeftBrace); Builder.AddChunk(CodeCompletionString::CK_VerticalSpace); - if (!Method->getResultType()->isVoidType()) { + if (!Method->getReturnType()->isVoidType()) { // If the result type is not void, add a return clause. Builder.AddTextChunk("return"); Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 4b82dd35aa1..33cb77fa14f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2444,12 +2444,14 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, // Redeclarations or specializations of a function or function template // with a declared return type that uses a placeholder type shall also // use that placeholder, not a deduced type. - QualType OldDeclaredReturnType = (Old->getTypeSourceInfo() - ? Old->getTypeSourceInfo()->getType()->castAs<FunctionType>() - : OldType)->getResultType(); - QualType NewDeclaredReturnType = (New->getTypeSourceInfo() - ? New->getTypeSourceInfo()->getType()->castAs<FunctionType>() - : NewType)->getResultType(); + QualType OldDeclaredReturnType = + (Old->getTypeSourceInfo() + ? Old->getTypeSourceInfo()->getType()->castAs<FunctionType>() + : OldType)->getReturnType(); + QualType NewDeclaredReturnType = + (New->getTypeSourceInfo() + ? New->getTypeSourceInfo()->getType()->castAs<FunctionType>() + : NewType)->getReturnType(); QualType ResQT; if (!Context.hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) && !((NewQType->isDependentType() || OldQType->isDependentType()) && @@ -2470,12 +2472,12 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, NewQType = ResQT; } - QualType OldReturnType = OldType->getResultType(); - QualType NewReturnType = cast<FunctionType>(NewQType)->getResultType(); + QualType OldReturnType = OldType->getReturnType(); + QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType(); if (OldReturnType != NewReturnType) { // If this function has a deduced return type and has already been // defined, copy the deduced value from the old declaration. - AutoType *OldAT = Old->getResultType()->getContainedAutoType(); + AutoType *OldAT = Old->getReturnType()->getContainedAutoType(); if (OldAT && OldAT->isDeduced()) { New->setType( SubstAutoType(New->getType(), @@ -2642,9 +2644,9 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, assert(!OldProto->hasExceptionSpec() && "Exception spec in C"); SmallVector<QualType, 16> ParamTypes(OldProto->param_type_begin(), OldProto->param_type_end()); - NewQType = Context.getFunctionType(NewFuncType->getResultType(), - ParamTypes, - OldProto->getExtProtoInfo()); + NewQType = + Context.getFunctionType(NewFuncType->getReturnType(), ParamTypes, + OldProto->getExtProtoInfo()); New->setType(NewQType); New->setHasInheritedPrototype(); @@ -2694,8 +2696,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S, = New->getType()->getAs<FunctionProtoType>(); // Determine whether this is the GNU C extension. - QualType MergedReturn = Context.mergeTypes(OldProto->getResultType(), - NewProto->getResultType()); + QualType MergedReturn = Context.mergeTypes(OldProto->getReturnType(), + NewProto->getReturnType()); bool LooseCompatible = !MergedReturn.isNull(); for (unsigned Idx = 0, End = Old->getNumParams(); LooseCompatible && Idx != End; ++Idx) { @@ -6223,10 +6225,9 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, // For record types, this is done by the AbstractClassUsageDiagnoser once // the class has been completely parsed. if (!DC->isRecord() && - SemaRef.RequireNonAbstractType(D.getIdentifierLoc(), - R->getAs<FunctionType>()->getResultType(), - diag::err_abstract_type_in_decl, - SemaRef.AbstractReturnType)) + SemaRef.RequireNonAbstractType( + D.getIdentifierLoc(), R->getAs<FunctionType>()->getReturnType(), + diag::err_abstract_type_in_decl, SemaRef.AbstractReturnType)) D.setInvalidType(); if (Name.getNameKind() == DeclarationName::CXXConstructorName) { @@ -6711,14 +6712,14 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, } if (getLangOpts().CPlusPlus1y && - NewFD->getResultType()->isUndeducedType()) + NewFD->getReturnType()->isUndeducedType()) Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_auto_fn_virtual); } if (getLangOpts().CPlusPlus1y && (NewFD->isDependentContext() || (isFriend && CurContext->isDependentContext())) && - NewFD->getResultType()->isUndeducedType()) { + NewFD->getReturnType()->isUndeducedType()) { // If the function template is referenced directly (for instance, as a // member of the current instantiation), pretend it has a dependent type. // This is not really justified by the standard, but is the only sane @@ -6727,8 +6728,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // a friend yet, so 'isDependentContext' on the FD doesn't work. const FunctionProtoType *FPT = NewFD->getType()->castAs<FunctionProtoType>(); - QualType Result = SubstAutoType(FPT->getResultType(), - Context.DependentTy); + QualType Result = + SubstAutoType(FPT->getReturnType(), Context.DependentTy); NewFD->setType(Context.getFunctionType(Result, FPT->getParamTypes(), FPT->getExtProtoInfo())); } @@ -6849,7 +6850,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, getLangOpts().CPlusPlus11 && FPT && !FPT->hasExceptionSpec()) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExceptionSpecType = EST_BasicNoexcept; - NewFD->setType(Context.getFunctionType(FPT->getResultType(), + NewFD->setType(Context.getFunctionType(FPT->getReturnType(), FPT->getParamTypes(), EPI)); } } @@ -6947,7 +6948,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Functions returning a variably modified type violate C99 6.7.5.2p2 // because all functions have linkage. if (!NewFD->isInvalidDecl() && - NewFD->getResultType()->isVariablyModifiedType()) { + NewFD->getReturnType()->isVariablyModifiedType()) { Diag(NewFD->getLocation(), diag::err_vm_func_decl); NewFD->setInvalidDecl(); } @@ -6955,7 +6956,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Handle attributes. ProcessDeclAttributes(S, NewFD, D); - QualType RetType = NewFD->getResultType(); + QualType RetType = NewFD->getReturnType(); const CXXRecordDecl *Ret = RetType->isRecordType() ? RetType->getAsCXXRecordDecl() : RetType->getPointeeCXXRecordDecl(); if (!NewFD->isInvalidDecl() && !NewFD->hasAttr<WarnUnusedResultAttr>() && @@ -7262,7 +7263,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, EPI.Variadic = true; EPI.ExtInfo = FT->getExtInfo(); - QualType R = Context.getFunctionType(FT->getResultType(), None, EPI); + QualType R = Context.getFunctionType(FT->getReturnType(), None, EPI); NewFD->setType(R); } @@ -7301,7 +7302,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, } // OpenCL v1.2, s6.9 -- Kernels can only have return type void. - if (!NewFD->getResultType()->isVoidType()) { + if (!NewFD->getReturnType()->isVoidType()) { Diag(D.getIdentifierLoc(), diag::err_expected_kernel_void_return_type); D.setInvalidType(); @@ -7322,7 +7323,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (!NewFD->isInvalidDecl() && NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { if (II->isStr("cudaConfigureCall")) { - if (!R->getAs<FunctionType>()->getResultType()->isScalarType()) + if (!R->getAs<FunctionType>()->getReturnType()->isScalarType()) Diag(NewFD->getLocation(), diag::err_config_scalar_return); Context.setcudaConfigureCallDecl(NewFD); @@ -7364,8 +7365,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsExplicitSpecialization) { - assert(!NewFD->getResultType()->isVariablyModifiedType() - && "Variably modified return types are not handled here"); + assert(!NewFD->getReturnType()->isVariablyModifiedType() && + "Variably modified return types are not handled here"); // Determine whether the type of this function should be merged with // a previous visible declaration. This never happens for functions in C++, @@ -7475,7 +7476,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, MD->getType()->castAs<FunctionProtoType>(); FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.TypeQuals |= Qualifiers::Const; - MD->setType(Context.getFunctionType(FPT->getResultType(), + MD->setType(Context.getFunctionType(FPT->getReturnType(), FPT->getParamTypes(), EPI)); // Warn that we did this, if we're not performing template instantiation. @@ -7634,7 +7635,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, // compatible, and if it does, warn the user. // But, issue any diagnostic on the first declaration only. if (NewFD->isExternC() && Previous.empty()) { - QualType R = NewFD->getResultType(); + QualType R = NewFD->getReturnType(); if (R->isIncompleteType() && !R->isVoidType()) Diag(NewFD->getLocation(), diag::warn_return_value_udt_incomplete) << NewFD << R; @@ -7704,7 +7705,7 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { const FunctionType* FT = T->castAs<FunctionType>(); // All the standards say that main() should should return 'int'. - if (Context.hasSameUnqualifiedType(FT->getResultType(), Context.IntTy)) { + if (Context.hasSameUnqualifiedType(FT->getReturnType(), Context.IntTy)) { // In C and C++, main magically returns 0 if you fall off the end; // set the flag which tells us that. // This is C++ [basic.start.main]p5 and C99 5.1.2.2.3. @@ -7809,9 +7810,9 @@ void Sema::CheckMSVCRTEntryPoint(FunctionDecl *FD) { // Set an implicit return of 'zero' if the function can return some integral, // enumeration, pointer or nullptr type. - if (FT->getResultType()->isIntegralOrEnumerationType() || - FT->getResultType()->isAnyPointerType() || - FT->getResultType()->isNullPtrType()) + if (FT->getReturnType()->isIntegralOrEnumerationType() || + FT->getReturnType()->isAnyPointerType() || + FT->getReturnType()->isNullPtrType()) // DllMain is exempt because a return value of zero means it failed. if (FD->getName() != "DllMain") FD->setHasImplicitReturnZero(true); @@ -9447,7 +9448,7 @@ static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, LambdaScopeInfo *LSI = S.PushLambdaScope(); LSI->CallOperator = CallOperator; LSI->Lambda = LambdaClass; - LSI->ReturnType = CallOperator->getResultType(); + LSI->ReturnType = CallOperator->getReturnType(); const LambdaCaptureDefault LCD = LambdaClass->getLambdaCaptureDefault(); if (LCD == LCD_None) @@ -9530,7 +9531,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { // The return type of a function definition must be complete // (C99 6.9.1p3, C++ [dcl.fct]p6). - QualType ResultType = FD->getResultType(); + QualType ResultType = FD->getReturnType(); if (!ResultType->isDependentType() && !ResultType->isVoidType() && !FD->isInvalidDecl() && RequireCompleteType(FD->getLocation(), ResultType, @@ -9697,7 +9698,7 @@ bool Sema::canSkipFunctionBody(Decl *D) { // We cannot skip the body of a function with an undeduced return type, // because any callers of that function need to know the type. if (const FunctionDecl *FD = D->getAsFunction()) - if (FD->isConstexpr() || FD->getResultType()->isUndeducedType()) + if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType()) return false; return Consumer.shouldSkipFunctionBody(D); } @@ -9725,13 +9726,13 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, FD->setBody(Body); if (getLangOpts().CPlusPlus1y && !FD->isInvalidDecl() && Body && - !FD->isDependentContext() && FD->getResultType()->isUndeducedType()) { + !FD->isDependentContext() && FD->getReturnType()->isUndeducedType()) { // If the function has a deduced result type but contains no 'return' // statements, the result type as written must be exactly 'auto', and // the deduced result type is 'void'. - if (!FD->getResultType()->getAs<AutoType>()) { + if (!FD->getReturnType()->getAs<AutoType>()) { Diag(dcl->getLocation(), diag::err_auto_fn_no_return_but_not_auto) - << FD->getResultType(); + << FD->getReturnType(); FD->setInvalidDecl(); } else { // Substitute 'void' for the 'auto' in the type. @@ -9767,8 +9768,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, if (!FD->isInvalidDecl()) { DiagnoseUnusedParameters(FD->param_begin(), FD->param_end()); DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(), - FD->getResultType(), FD); - + FD->getReturnType(), FD); + // If this is a constructor, we need a vtable. if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(FD)) MarkVTableUsed(FD->getLocation(), Constructor->getParent()); @@ -9776,7 +9777,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, // Try to apply the named return value optimization. We have to check // if we can do this here because lambdas keep return statements around // to deduce an implicit return type. - if (getLangOpts().CPlusPlus && FD->getResultType()->isRecordType() && + if (getLangOpts().CPlusPlus && FD->getReturnType()->isRecordType() && !FD->isDependentContext()) computeNRVO(Body, getCurFunction()); } @@ -9789,8 +9790,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, if (!MD->isInvalidDecl()) { DiagnoseUnusedParameters(MD->param_begin(), MD->param_end()); DiagnoseSizeOfParametersAndReturnValue(MD->param_begin(), MD->param_end(), - MD->getResultType(), MD); - + MD->getReturnType(), MD); + if (Body) computeNRVO(Body, getCurFunction()); } diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 8af151e78da..0845194a78d 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -89,8 +89,8 @@ static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx) { static QualType getFunctionOrMethodResultType(const Decl *D) { if (const FunctionType *FnTy = D->getFunctionType()) - return cast<FunctionProtoType>(FnTy)->getResultType(); - return cast<ObjCMethodDecl>(D)->getResultType(); + return cast<FunctionProtoType>(FnTy)->getReturnType(); + return cast<ObjCMethodDecl>(D)->getReturnType(); } static bool isFunctionOrMethodVariadic(const Decl *D) { @@ -1463,7 +1463,7 @@ static void handleTLSModelAttr(Sema &S, Decl *D, static void handleMallocAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { - QualType RetTy = FD->getResultType(); + QualType RetTy = FD->getReturnType(); if (RetTy->isAnyPointerType() || RetTy->isBlockPointerType()) { D->addAttr(::new (S.Context) MallocAttr(Attr.getRange(), S.Context, @@ -2006,10 +2006,10 @@ static void handleObjCMethodFamilyAttr(Sema &S, Decl *decl, return; } - if (F == ObjCMethodFamilyAttr::OMF_init && - !method->getResultType()->isObjCObjectPointerType()) { + if (F == ObjCMethodFamilyAttr::OMF_init && + !method->getReturnType()->isObjCObjectPointerType()) { S.Diag(method->getLocation(), diag::err_init_method_bad_return_type) - << method->getResultType(); + << method->getReturnType(); // Ignore the attribute. return; } @@ -2167,13 +2167,14 @@ static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &Attr) { } static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &Attr) { - if (D->getFunctionType() && D->getFunctionType()->getResultType()->isVoidType()) { + if (D->getFunctionType() && + D->getFunctionType()->getReturnType()->isVoidType()) { S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method) << Attr.getName() << 0; return; } if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) - if (MD->getResultType()->isVoidType()) { + if (MD->getReturnType()->isVoidType()) { S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method) << Attr.getName() << 1; return; @@ -3009,7 +3010,7 @@ static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) { static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr) { FunctionDecl *FD = cast<FunctionDecl>(D); - if (!FD->getResultType()->isVoidType()) { + if (!FD->getReturnType()->isVoidType()) { TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc().IgnoreParens(); if (FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>()) { S.Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return) @@ -3374,14 +3375,14 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, QualType returnType; if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) - returnType = MD->getResultType(); + returnType = MD->getReturnType(); else if (S.getLangOpts().ObjCAutoRefCount && hasDeclarator(D) && (Attr.getKind() == AttributeList::AT_NSReturnsRetained)) return; // ignore: was handled as a type attribute else if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D)) returnType = PD->getType(); else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) - returnType = FD->getResultType(); + returnType = FD->getReturnType(); else { S.Diag(D->getLocStart(), diag::warn_attribute_wrong_decl_type) << Attr.getRange() << Attr.getName() @@ -3452,7 +3453,7 @@ static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, SourceLocation loc = attr.getLoc(); QualType resultType; if (isa<ObjCMethodDecl>(D)) - resultType = cast<ObjCMethodDecl>(D)->getResultType(); + resultType = cast<ObjCMethodDecl>(D)->getReturnType(); else resultType = cast<ObjCPropertyDecl>(D)->getType(); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 019b1c189c2..ad8b1b2ba5c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -790,7 +790,7 @@ bool Sema::CheckConstexprFunctionDecl(const FunctionDecl *NewFD) { } // - its return type shall be a literal type; - QualType RT = NewFD->getResultType(); + QualType RT = NewFD->getReturnType(); if (!RT->isDependentType() && RequireLiteralType(NewFD->getLocation(), RT, diag::err_constexpr_non_literal_return)) @@ -1180,7 +1180,7 @@ bool Sema::CheckConstexprFunctionBody(const FunctionDecl *Dcl, Stmt *Body) { // statement. We still do, unless the return type is void, because // otherwise if there's no return statement, the function cannot // be used in a core constant expression. - bool OK = getLangOpts().CPlusPlus1y && Dcl->getResultType()->isVoidType(); + bool OK = getLangOpts().CPlusPlus1y && Dcl->getReturnType()->isVoidType(); Diag(Dcl->getLocation(), OK ? diag::warn_cxx11_compat_constexpr_body_no_return : diag::err_constexpr_body_no_return); @@ -4717,7 +4717,7 @@ updateExceptionSpec(Sema &S, FunctionDecl *FD, const FunctionProtoType *FPT, const Sema::ImplicitExceptionSpecification &ExceptSpec) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); ExceptSpec.getEPI(EPI); - FD->setType(S.Context.getFunctionType(FPT->getResultType(), + FD->setType(S.Context.getFunctionType(FPT->getReturnType(), FPT->getParamTypes(), EPI)); } @@ -4805,7 +4805,7 @@ void Sema::CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD) { QualType ReturnType = Context.VoidTy; if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) { // Check for return type matching. - ReturnType = Type->getResultType(); + ReturnType = Type->getReturnType(); QualType ExpectedReturnType = Context.getLValueReferenceType(Context.getTypeDeclType(RD)); if (!Context.hasSameType(ReturnType, ExpectedReturnType)) { @@ -6221,7 +6221,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R, // case any of the errors above fired) and with "void" as the // return type, since constructors don't have return types. const FunctionProtoType *Proto = R->getAs<FunctionProtoType>(); - if (Proto->getResultType() == Context.VoidTy && !D.isInvalidType()) + if (Proto->getReturnType() == Context.VoidTy && !D.isInvalidType()) return R; FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); @@ -6469,11 +6469,11 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R, // Diagnose "&operator bool()" and other such nonsense. This // is actually a gcc extension which we don't support. - if (Proto->getResultType() != ConvType) { + if (Proto->getReturnType() != ConvType) { Diag(D.getIdentifierLoc(), diag::err_conv_function_with_complex_decl) - << Proto->getResultType(); + << Proto->getReturnType(); D.setInvalidType(); - ConvType = Proto->getResultType(); + ConvType = Proto->getReturnType(); } // C++ [class.conv.fct]p4: @@ -8412,7 +8412,7 @@ private: do declareCtor(UsingLoc, Ctor, SemaRef.Context.getFunctionType( - Ctor->getResultType(), ArgTypes.slice(0, Params), EPI)); + Ctor->getReturnType(), ArgTypes.slice(0, Params), EPI)); while (Params > MinParams && Ctor->getParamDecl(--Params)->hasDefaultArg()); } @@ -8526,7 +8526,7 @@ private: FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExceptionSpecType = EST_Unevaluated; EPI.ExceptionSpecDecl = DerivedCtor; - DerivedCtor->setType(Context.getFunctionType(FPT->getResultType(), + DerivedCtor->setType(Context.getFunctionType(FPT->getReturnType(), FPT->getParamTypes(), EPI)); // Build the parameter declarations. @@ -10687,8 +10687,8 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, CanQualType ExpectedFirstParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag) { - QualType ResultType = - FnDecl->getType()->getAs<FunctionType>()->getResultType(); + QualType ResultType = + FnDecl->getType()->getAs<FunctionType>()->getReturnType(); // Check that the result type is not dependent. if (ResultType->isDependentType()) @@ -12106,8 +12106,8 @@ bool Sema::CheckOverridingFunctionAttributes(const CXXMethodDecl *New, bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old) { - QualType NewTy = New->getType()->getAs<FunctionType>()->getResultType(); - QualType OldTy = Old->getType()->getAs<FunctionType>()->getResultType(); + QualType NewTy = New->getType()->getAs<FunctionType>()->getReturnType(); + QualType OldTy = Old->getType()->getAs<FunctionType>()->getReturnType(); if (Context.hasSameType(NewTy, OldTy) || NewTy->isDependentType() || OldTy->isDependentType()) diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 78c26d38a9f..7d023e1d403 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -49,8 +49,8 @@ bool Sema::checkInitMethod(ObjCMethodDecl *method, // We ignore protocols here. Should we? What about Class? - const ObjCObjectType *result = method->getResultType() - ->castAs<ObjCObjectPointerType>()->getObjectType(); + const ObjCObjectType *result = + method->getReturnType()->castAs<ObjCObjectPointerType>()->getObjectType(); if (result->isObjCId()) { return false; @@ -118,10 +118,10 @@ void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, // implies a related result type, and the original (overridden) method has // a suitable return type, but the new (overriding) method does not have // a suitable return type. - QualType ResultType = NewMethod->getResultType(); + QualType ResultType = NewMethod->getReturnType(); SourceRange ResultTypeRange; - if (const TypeSourceInfo *ResultTypeInfo - = NewMethod->getResultTypeSourceInfo()) + if (const TypeSourceInfo *ResultTypeInfo = + NewMethod->getReturnTypeSourceInfo()) ResultTypeRange = ResultTypeInfo->getTypeLoc().getSourceRange(); // Figure out which class this method is part of, if any. @@ -209,19 +209,19 @@ bool Sema::CheckARCMethodDecl(ObjCMethodDecl *method) { return false; case OMF_dealloc: - if (!Context.hasSameType(method->getResultType(), Context.VoidTy)) { + if (!Context.hasSameType(method->getReturnType(), Context.VoidTy)) { SourceRange ResultTypeRange; - if (const TypeSourceInfo *ResultTypeInfo - = method->getResultTypeSourceInfo()) + if (const TypeSourceInfo *ResultTypeInfo = + method->getReturnTypeSourceInfo()) ResultTypeRange = ResultTypeInfo->getTypeLoc().getSourceRange(); if (ResultTypeRange.isInvalid()) - Diag(method->getLocation(), diag::error_dealloc_bad_result_type) - << method->getResultType() - << FixItHint::CreateInsertion(method->getSelectorLoc(0), "(void)"); + Diag(method->getLocation(), diag::error_dealloc_bad_result_type) + << method->getReturnType() + << FixItHint::CreateInsertion(method->getSelectorLoc(0), "(void)"); else - Diag(method->getLocation(), diag::error_dealloc_bad_result_type) - << method->getResultType() - << FixItHint::CreateReplacement(ResultTypeRange, "void"); + Diag(method->getLocation(), diag::error_dealloc_bad_result_type) + << method->getReturnType() + << FixItHint::CreateReplacement(ResultTypeRange, "void"); return true; } return false; @@ -1341,21 +1341,21 @@ static bool CheckMethodOverrideReturn(Sema &S, (MethodDecl->getObjCDeclQualifier() != MethodImpl->getObjCDeclQualifier())) { if (Warn) { - S.Diag(MethodImpl->getLocation(), - (IsOverridingMode ? - diag::warn_conflicting_overriding_ret_type_modifiers - : diag::warn_conflicting_ret_type_modifiers)) + S.Diag(MethodImpl->getLocation(), + (IsOverridingMode + ? diag::warn_conflicting_overriding_ret_type_modifiers + : diag::warn_conflicting_ret_type_modifiers)) << MethodImpl->getDeclName() - << getTypeRange(MethodImpl->getResultTypeSourceInfo()); - S.Diag(MethodDecl->getLocation(), diag::note_previous_declaration) - << getTypeRange(MethodDecl->getResultTypeSourceInfo()); + << getTypeRange(MethodImpl->getReturnTypeSourceInfo()); + S.Diag(MethodDecl->getLocation(), diag::note_previous_declaration) + << getTypeRange(MethodDecl->getReturnTypeSourceInfo()); } else return false; } - - if (S.Context.hasSameUnqualifiedType(MethodImpl->getResultType(), - MethodDecl->getResultType())) + + if (S.Context.hasSameUnqualifiedType(MethodImpl->getReturnType(), + MethodDecl->getReturnType())) return true; if (!Warn) return false; @@ -1367,9 +1367,9 @@ static bool CheckMethodOverrideReturn(Sema &S, // Mismatches between ObjC pointers go into a different warning // category, and sometimes they're even completely whitelisted. if (const ObjCObjectPointerType *ImplPtrTy = - MethodImpl->getResultType()->getAs<ObjCObjectPointerType>()) { + MethodImpl->getReturnType()->getAs<ObjCObjectPointerType>()) { if (const ObjCObjectPointerType *IfacePtrTy = - MethodDecl->getResultType()->getAs<ObjCObjectPointerType>()) { + MethodDecl->getReturnType()->getAs<ObjCObjectPointerType>()) { // Allow non-matching return types as long as they don't violate // the principle of substitutability. Specifically, we permit // return types that are subclasses of the declared return type, @@ -1384,14 +1384,13 @@ static bool CheckMethodOverrideReturn(Sema &S, } S.Diag(MethodImpl->getLocation(), DiagID) - << MethodImpl->getDeclName() - << MethodDecl->getResultType() - << MethodImpl->getResultType() - << getTypeRange(MethodImpl->getResultTypeSourceInfo()); - S.Diag(MethodDecl->getLocation(), - IsOverridingMode ? diag::note_previous_declaration - : diag::note_previous_definition) - << getTypeRange(MethodDecl->getResultTypeSourceInfo()); + << MethodImpl->getDeclName() << MethodDecl->getReturnType() + << MethodImpl->getReturnType() + << getTypeRange(MethodImpl->getReturnTypeSourceInfo()); + S.Diag(MethodDecl->getLocation(), IsOverridingMode + ? diag::note_previous_declaration + : diag::note_previous_definition) + << getTypeRange(MethodDecl->getReturnTypeSourceInfo()); return false; } @@ -1523,7 +1522,7 @@ static bool checkMethodFamilyMismatch(Sema &S, ObjCMethodDecl *impl, // The only reason these methods don't fall within their families is // due to unusual result types. - if (unmatched->getResultType()->isObjCObjectPointerType()) { + if (unmatched->getReturnType()->isObjCObjectPointerType()) { reasonSelector = R_UnrelatedReturn; } else { reasonSelector = R_NonObjectReturn; @@ -2148,8 +2147,8 @@ static bool tryMatchRecordTypes(ASTContext &Context, bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *left, const ObjCMethodDecl *right, MethodMatchStrategy strategy) { - if (!matchTypes(Context, strategy, - left->getResultType(), right->getResultType())) + if (!matchTypes(Context, strategy, left->getReturnType(), + right->getReturnType())) return false; // If either is hidden, it is not considered to match. @@ -2278,7 +2277,7 @@ static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen, // Don't complain about mismatches for -length if the method we // chose has an integral result type. - return (chosen->getResultType()->isIntegerType()); + return (chosen->getReturnType()->isIntegerType()); } ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R, @@ -2738,8 +2737,8 @@ CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal) { static Sema::ResultTypeCompatibilityKind CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method, ObjCInterfaceDecl *CurrentClass) { - QualType ResultType = Method->getResultType(); - + QualType ResultType = Method->getReturnType(); + // If an Objective-C method inherits its related result type, then its // declared result type must be compatible with its own class type. The // declared result type is compatible if: @@ -3047,9 +3046,9 @@ Decl *Sema::ActOnMethodDeclaration( QualType resultDeclType; bool HasRelatedResultType = false; - TypeSourceInfo *ResultTInfo = 0; + TypeSourceInfo *ReturnTInfo = 0; if (ReturnType) { - resultDeclType = GetTypeFromParser(ReturnType, &ResultTInfo); + resultDeclType = GetTypeFromParser(ReturnType, &ReturnTInfo); if (CheckFunctionReturnType(resultDeclType, MethodLoc)) return 0; @@ -3061,18 +3060,14 @@ Decl *Sema::ActOnMethodDeclaration( << FixItHint::CreateInsertion(SelectorLocs.front(), "(id)"); } - ObjCMethodDecl* ObjCMethod = - ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, - resultDeclType, - ResultTInfo, - CurContext, - MethodType == tok::minus, isVariadic, - /*isPropertyAccessor=*/false, - /*isImplicitlyDeclared=*/false, /*isDefined=*/false, - MethodDeclKind == tok::objc_optional - ? ObjCMethodDecl::Optional - : ObjCMethodDecl::Required, - HasRelatedResultType); + ObjCMethodDecl *ObjCMethod = ObjCMethodDecl::Create( + Context, MethodLoc, EndLoc, Sel, resultDeclType, ReturnTInfo, CurContext, + MethodType == tok::minus, isVariadic, + /*isPropertyAccessor=*/false, + /*isImplicitlyDeclared=*/false, /*isDefined=*/false, + MethodDeclKind == tok::objc_optional ? ObjCMethodDecl::Optional + : ObjCMethodDecl::Required, + HasRelatedResultType); SmallVector<ParmVarDecl*, 16> Params; diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index caa796d1f0a..c1b7e988c59 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -203,7 +203,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { Old->isExternC()) { FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo(); EPI.ExceptionSpecType = EST_DynamicNone; - QualType NewType = Context.getFunctionType(NewProto->getResultType(), + QualType NewType = Context.getFunctionType(NewProto->getReturnType(), NewProto->getParamTypes(), EPI); New->setType(NewType); return false; @@ -224,7 +224,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { // Update the type of the function with the appropriate exception // specification. - QualType NewType = Context.getFunctionType(NewProto->getResultType(), + QualType NewType = Context.getFunctionType(NewProto->getReturnType(), NewProto->getParamTypes(), EPI); New->setType(NewType); @@ -711,11 +711,10 @@ bool Sema::CheckParamExceptionSpec(const PartialDiagnostic & NoteID, const FunctionProtoType *Target, SourceLocation TargetLoc, const FunctionProtoType *Source, SourceLocation SourceLoc) { - if (CheckSpecForTypesEquivalent(*this, - PDiag(diag::err_deep_exception_specs_differ) << 0, - PDiag(), - Target->getResultType(), TargetLoc, - Source->getResultType(), SourceLoc)) + if (CheckSpecForTypesEquivalent( + *this, PDiag(diag::err_deep_exception_specs_differ) << 0, PDiag(), + Target->getReturnType(), TargetLoc, Source->getReturnType(), + SourceLoc)) return true; // We shouldn't even be testing this unless the arguments are otherwise diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ff54b6b24e4..e4e0052424d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -59,8 +59,8 @@ bool Sema::CanUseDecl(NamedDecl *D) { // If the function has a deduced return type, and we can't deduce it, // then we can't use it either. - if (getLangOpts().CPlusPlus1y && FD->getResultType()->isUndeducedType() && - DeduceReturnType(FD, SourceLocation(), /*Diagnose*/false)) + if (getLangOpts().CPlusPlus1y && FD->getReturnType()->isUndeducedType() && + DeduceReturnType(FD, SourceLocation(), /*Diagnose*/ false)) return false; } @@ -295,7 +295,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, // If the function has a deduced return type, and we can't deduce it, // then we can't use it either. - if (getLangOpts().CPlusPlus1y && FD->getResultType()->isUndeducedType() && + if (getLangOpts().CPlusPlus1y && FD->getReturnType()->isUndeducedType() && DeduceReturnType(FD, Loc)) return true; } @@ -2737,7 +2737,7 @@ ExprResult Sema::BuildDeclarationNameExpr( // If we're referring to a function with an __unknown_anytype // result type, make the entire expression __unknown_anytype. - if (fty->getResultType() == Context.UnknownAnyTy) { + if (fty->getReturnType() == Context.UnknownAnyTy) { type = Context.UnknownAnyTy; valueKind = VK_RValue; break; @@ -2756,7 +2756,7 @@ ExprResult Sema::BuildDeclarationNameExpr( // type. if (!cast<FunctionDecl>(VD)->hasPrototype() && isa<FunctionProtoType>(fty)) - type = Context.getFunctionNoProtoType(fty->getResultType(), + type = Context.getFunctionNoProtoType(fty->getReturnType(), fty->getExtInfo()); // Functions are r-values in C. @@ -2774,7 +2774,7 @@ ExprResult Sema::BuildDeclarationNameExpr( // This should only be possible with a type written directly. if (const FunctionProtoType *proto = dyn_cast<FunctionProtoType>(VD->getType())) - if (proto->getResultType() == Context.UnknownAnyTy) { + if (proto->getReturnType() == Context.UnknownAnyTy) { type = Context.UnknownAnyTy; valueKind = VK_RValue; break; @@ -4220,8 +4220,8 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, if (CallType != VariadicDoesNotApply) { // Assume that extern "C" functions with variadic arguments that // return __unknown_anytype aren't *really* variadic. - if (Proto->getResultType() == Context.UnknownAnyTy && - FDecl && FDecl->isExternC()) { + if (Proto->getReturnType() == Context.UnknownAnyTy && FDecl && + FDecl->isExternC()) { for (unsigned i = ArgIx, e = Args.size(); i != e; ++i) { QualType paramType; // ignored ExprResult arg = checkUnknownAnyArg(CallLoc, Args[i], paramType); @@ -4624,7 +4624,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, << FDecl->getName() << Fn->getSourceRange()); // CUDA: Kernel function must have 'void' return type - if (!FuncT->getResultType()->isVoidType()) + if (!FuncT->getReturnType()->isVoidType()) return ExprError(Diag(LParenLoc, diag::err_kern_type_not_void_return) << Fn->getType() << Fn->getSourceRange()); } else { @@ -4636,14 +4636,13 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, } // Check for a valid return type - if (CheckCallReturnType(FuncT->getResultType(), - Fn->getLocStart(), TheCall, + if (CheckCallReturnType(FuncT->getReturnType(), Fn->getLocStart(), TheCall, FDecl)) return ExprError(); // We know the result type of the call, set it. TheCall->setType(FuncT->getCallResultType(Context)); - TheCall->setValueKind(Expr::getValueKindForType(FuncT->getResultType())); + TheCall->setValueKind(Expr::getValueKindForType(FuncT->getReturnType())); const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FuncT); if (Proto) { @@ -7547,8 +7546,8 @@ static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS) { QualType T = Method->param_begin()[0]->getType(); if (!T->isObjCObjectPointerType()) return false; - - QualType R = Method->getResultType(); + + QualType R = Method->getReturnType(); if (!R->isScalarType()) return false; @@ -10322,7 +10321,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, CurBlock->FunctionType = T; const FunctionType *Fn = T->getAs<FunctionType>(); - QualType RetTy = Fn->getResultType(); + QualType RetTy = Fn->getReturnType(); bool isVariadic = (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic()); @@ -10459,7 +10458,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, // Otherwise, if we don't need to change anything about the function type, // preserve its sugar structure. - } else if (FTy->getResultType() == RetTy && + } else if (FTy->getReturnType() == RetTy && (!NoReturn || FTy->getNoReturnAttr())) { BlockTy = BSI->FunctionType; @@ -12953,8 +12952,8 @@ ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) { // Rewrite the method result type if available. if (ObjCMethodDecl *Method = E->getMethodDecl()) { - assert(Method->getResultType() == S.Context.UnknownAnyTy); - Method->setResultType(DestType); + assert(Method->getReturnType() == S.Context.UnknownAnyTy); + Method->setReturnType(DestType); } // Change the type of the message. diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index eb668ccbfe3..e71b5ba3ca0 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -5675,7 +5675,7 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl, ME->setHadMultipleCandidates(true); MarkMemberReferenced(ME); - QualType ResultType = Method->getResultType(); + QualType ResultType = Method->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultType); ResultType = ResultType.getNonLValueExprType(Context); diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 87cff1273a4..54aa6a610e0 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/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. diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index ecf97d75bf5..75f60ba480f 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -3550,7 +3550,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, // Compute the returned type of the conversion. if (isa<CXXConversionDecl>(Function)) - T2 = Function->getResultType(); + T2 = Function->getReturnType(); else T2 = cv1T1; @@ -5888,7 +5888,7 @@ InitializationSequence::Perform(Sema &S, CastKind = CK_UserDefinedConversion; - CreatedObject = Conversion->getResultType()->isRecordType(); + CreatedObject = Conversion->getReturnType()->isRecordType(); } bool RequiresCopy = !IsCopy && !isReferenceBinding(Steps.back()); diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 2023c1f61e3..ac3f2efb5b8 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -364,7 +364,7 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, // dependent type. if (Class->isDependentContext() || TemplateParams) { const FunctionProtoType *FPT = MethodType->castAs<FunctionProtoType>(); - QualType Result = FPT->getResultType(); + QualType Result = FPT->getReturnType(); if (Result->isUndeducedType()) { Result = SubstAutoType(Result, Context.DependentTy); MethodType = Context.getFunctionType(Result, FPT->getParamTypes(), @@ -456,8 +456,8 @@ void Sema::buildLambdaScope(LambdaScopeInfo *LSI, LSI->Mutable = Mutable; if (ExplicitResultType) { - LSI->ReturnType = CallOperator->getResultType(); - + LSI->ReturnType = CallOperator->getReturnType(); + if (!LSI->ReturnType->isDependentType() && !LSI->ReturnType->isVoidType()) { if (RequireCompleteType(CallOperator->getLocStart(), LSI->ReturnType, @@ -1165,7 +1165,7 @@ static void addFunctionPointerConversion(Sema &S, assert(InvokerExtInfo.RefQualifier == RQ_None && "Lambda's call operator should not have a reference qualifier"); InvokerFunctionTy = - S.Context.getFunctionType(CallOpProto->getResultType(), + S.Context.getFunctionType(CallOpProto->getReturnType(), CallOpProto->getParamTypes(), InvokerExtInfo); PtrToFunctionTy = S.Context.getPointerType(InvokerFunctionTy); } @@ -1332,7 +1332,7 @@ static void addBlockPointerConversion(Sema &S, FunctionProtoType::ExtProtoInfo ExtInfo = Proto->getExtProtoInfo(); ExtInfo.TypeQuals = 0; QualType FunctionTy = S.Context.getFunctionType( - Proto->getResultType(), Proto->getParamTypes(), ExtInfo); + Proto->getReturnType(), Proto->getParamTypes(), ExtInfo); BlockPtrTy = S.Context.getBlockPointerType(FunctionTy); } diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 01220769e32..76ea8f3bae0 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2194,7 +2194,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) { } case Type::FunctionNoProto: { const FunctionType *FnType = cast<FunctionType>(T); - T = FnType->getResultType().getTypePtr(); + T = FnType->getReturnType().getTypePtr(); continue; } diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index 659b732c810..beb58ecdfa3 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -1157,13 +1157,11 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, new (Context) ObjCIvarRefExpr(Ivar, Ivar->getType(), PropertyDiagLoc, Ivar->getLocation(), LoadSelfExpr, true, true); - ExprResult Res = - PerformCopyInitialization(InitializedEntity::InitializeResult( - PropertyDiagLoc, - getterMethod->getResultType(), - /*NRVO=*/false), - PropertyDiagLoc, - Owned(IvarRefExpr)); + ExprResult Res = PerformCopyInitialization( + InitializedEntity::InitializeResult(PropertyDiagLoc, + getterMethod->getReturnType(), + /*NRVO=*/false), + PropertyDiagLoc, Owned(IvarRefExpr)); if (!Res.isInvalid()) { Expr *ResExpr = Res.takeAs<Expr>(); if (ResExpr) @@ -1385,7 +1383,7 @@ bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property, SourceLocation Loc) { if (!GetterMethod) return false; - QualType GetterType = GetterMethod->getResultType().getNonReferenceType(); + QualType GetterType = GetterMethod->getReturnType().getNonReferenceType(); QualType PropertyIvarType = property->getType().getNonReferenceType(); bool compat = Context.hasSameType(PropertyIvarType, GetterType); if (!compat) { @@ -1883,8 +1881,8 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCPropertyDecl::PropertyAttributeKind CAttr = property->getPropertyAttributes(); if ((!(CAttr & ObjCPropertyDecl::OBJC_PR_readonly)) && - Context.getCanonicalType(SetterMethod->getResultType()) != - Context.VoidTy) + Context.getCanonicalType(SetterMethod->getReturnType()) != + Context.VoidTy) Diag(SetterMethod->getLocation(), diag::err_setter_type_void); if (SetterMethod->param_size() != 1 || !Context.hasSameUnqualifiedType( diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 2a3ab80ba4f..8e52e620a77 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1027,7 +1027,7 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old, (!TemplateParameterListsAreEqual(NewTemplate->getTemplateParameters(), OldTemplate->getTemplateParameters(), false, TPL_TemplateMatch) || - OldType->getResultType() != NewType->getResultType())) + OldType->getReturnType() != NewType->getReturnType())) return true; // If the function is a class member, its signature includes the @@ -2303,11 +2303,11 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, return false; bool HasObjCConversion = false; - if (Context.getCanonicalType(FromFunctionType->getResultType()) - == Context.getCanonicalType(ToFunctionType->getResultType())) { + if (Context.getCanonicalType(FromFunctionType->getReturnType()) == + Context.getCanonicalType(ToFunctionType->getReturnType())) { // Okay, the types match exactly. Nothing to do. - } else if (isObjCPointerConversion(FromFunctionType->getResultType(), - ToFunctionType->getResultType(), + } else if (isObjCPointerConversion(FromFunctionType->getReturnType(), + ToFunctionType->getReturnType(), ConvertedType, IncompatibleObjC)) { // Okay, we have an Objective-C pointer conversion. HasObjCConversion = true; @@ -2455,12 +2455,12 @@ bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType, return false; bool IncompatibleObjC = false; - if (Context.hasSameType(FromFunctionType->getResultType(), - ToFunctionType->getResultType())) { + if (Context.hasSameType(FromFunctionType->getReturnType(), + ToFunctionType->getReturnType())) { // Okay, the types match exactly. Nothing to do. } else { - QualType RHS = FromFunctionType->getResultType(); - QualType LHS = ToFunctionType->getResultType(); + QualType RHS = FromFunctionType->getReturnType(); + QualType LHS = ToFunctionType->getReturnType(); if ((!getLangOpts().CPlusPlus || !RHS->isRecordType()) && !RHS.hasQualifiers() && LHS.hasQualifiers()) LHS = LHS.getUnqualifiedType(); @@ -2583,10 +2583,10 @@ void Sema::HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, } // Handle different return type. - if (!Context.hasSameType(FromFunction->getResultType(), - ToFunction->getResultType())) { - PDiag << ft_return_type << ToFunction->getResultType() - << FromFunction->getResultType(); + if (!Context.hasSameType(FromFunction->getReturnType(), + ToFunction->getReturnType())) { + PDiag << ft_return_type << ToFunction->getReturnType() + << FromFunction->getReturnType(); return; } @@ -4439,9 +4439,9 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, } else if (ICS.isUserDefined()) { // Don't allow rvalue references to bind to lvalues. if (DeclType->isRValueReferenceType()) { - if (const ReferenceType *RefType - = ICS.UserDefined.ConversionFunction->getResultType() - ->getAs<LValueReferenceType>()) { + if (const ReferenceType *RefType = + ICS.UserDefined.ConversionFunction->getReturnType() + ->getAs<LValueReferenceType>()) { if (!RefType->getPointeeType()->isFunctionType()) { ICS.setBad(BadConversionSequence::lvalue_ref_to_rvalue, Init, DeclType); @@ -9718,7 +9718,7 @@ private: // If any candidate has a placeholder return type, trigger its deduction // now. if (S.getLangOpts().CPlusPlus1y && - FunDecl->getResultType()->isUndeducedType() && + FunDecl->getReturnType()->isUndeducedType() && S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain)) return false; @@ -10023,7 +10023,7 @@ Sema::ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, } if (Matched && getLangOpts().CPlusPlus1y && - Matched->getResultType()->isUndeducedType() && + Matched->getReturnType()->isUndeducedType() && DeduceReturnType(Matched, ovl->getExprLoc(), Complain)) return 0; @@ -10717,7 +10717,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, return ExprError(); // Determine the result type. - QualType ResultTy = FnDecl->getResultType(); + QualType ResultTy = FnDecl->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultTy); ResultTy = ResultTy.getNonLValueExprType(Context); @@ -10726,8 +10726,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, new (Context) CXXOperatorCallExpr(Context, Op, FnExpr.take(), ArgsArray, ResultTy, VK, OpLoc, false); - if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall, - FnDecl)) + if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl)) return ExprError(); return MaybeBindToTemporary(TheCall); @@ -10952,7 +10951,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, return ExprError(); // Determine the result type. - QualType ResultTy = FnDecl->getResultType(); + QualType ResultTy = FnDecl->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultTy); ResultTy = ResultTy.getNonLValueExprType(Context); @@ -10961,7 +10960,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, Args, ResultTy, VK, OpLoc, FPFeatures.fp_contract); - if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall, + if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl)) return ExprError(); @@ -11168,7 +11167,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, return ExprError(); // Determine the result type - QualType ResultTy = FnDecl->getResultType(); + QualType ResultTy = FnDecl->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultTy); ResultTy = ResultTy.getNonLValueExprType(Context); @@ -11178,8 +11177,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, ResultTy, VK, RLoc, false); - if (CheckCallReturnType(FnDecl->getResultType(), LLoc, TheCall, - FnDecl)) + if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl)) return ExprError(); return MaybeBindToTemporary(TheCall); @@ -11271,7 +11269,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, const FunctionProtoType *proto = fnType->castAs<FunctionProtoType>(); QualType resultType = proto->getCallResultType(Context); - ExprValueKind valueKind = Expr::getValueKindForType(proto->getResultType()); + ExprValueKind valueKind = Expr::getValueKindForType(proto->getReturnType()); // Check that the object type isn't more qualified than the // member function we're calling. @@ -11297,8 +11295,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, = new (Context) CXXMemberCallExpr(Context, MemExprE, Args, resultType, valueKind, RParenLoc); - if (CheckCallReturnType(proto->getResultType(), - op->getRHS()->getLocStart(), + if (CheckCallReturnType(proto->getReturnType(), op->getRHS()->getLocStart(), call, 0)) return ExprError(); @@ -11437,7 +11434,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, MemExpr = cast<MemberExpr>(MemExprE->IgnoreParens()); } - QualType ResultType = Method->getResultType(); + QualType ResultType = Method->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultType); ResultType = ResultType.getNonLValueExprType(Context); @@ -11447,7 +11444,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, ResultType, VK, RParenLoc); // Check for a valid return type. - if (CheckCallReturnType(Method->getResultType(), MemExpr->getMemberLoc(), + if (CheckCallReturnType(Method->getReturnType(), MemExpr->getMemberLoc(), TheCall, Method)) return ExprError(); @@ -11696,7 +11693,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, // Once we've built TheCall, all of the expressions are properly // owned. - QualType ResultTy = Method->getResultType(); + QualType ResultTy = Method->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultTy); ResultTy = ResultTy.getNonLValueExprType(Context); @@ -11706,8 +11703,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, ResultTy, VK, RParenLoc, false); MethodArgs.reset(); - if (CheckCallReturnType(Method->getResultType(), LParenLoc, TheCall, - Method)) + if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method)) return true; // We may have default arguments. If so, we need to allocate more @@ -11879,15 +11875,14 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, if (FnExpr.isInvalid()) return ExprError(); - QualType ResultTy = Method->getResultType(); + QualType ResultTy = Method->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultTy); ResultTy = ResultTy.getNonLValueExprType(Context); CXXOperatorCallExpr *TheCall = new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr.take(), Base, ResultTy, VK, OpLoc, false); - if (CheckCallReturnType(Method->getResultType(), OpLoc, TheCall, - Method)) + if (CheckCallReturnType(Method->getReturnType(), OpLoc, TheCall, Method)) return ExprError(); return MaybeBindToTemporary(TheCall); @@ -11948,7 +11943,7 @@ ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R, ConvArgs[ArgIdx] = InputInit.take(); } - QualType ResultTy = FD->getResultType(); + QualType ResultTy = FD->getReturnType(); ExprValueKind VK = Expr::getValueKindForType(ResultTy); ResultTy = ResultTy.getNonLValueExprType(Context); @@ -11957,7 +11952,7 @@ ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R, llvm::makeArrayRef(ConvArgs, Args.size()), ResultTy, VK, LitEndLoc, UDSuffixLoc); - if (CheckCallReturnType(FD->getResultType(), UDSuffixLoc, UDL, FD)) + if (CheckCallReturnType(FD->getReturnType(), UDSuffixLoc, UDL, FD)) return ExprError(); if (CheckFunctionCall(FD, UDL, NULL)) diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index 1301ae32f1a..81657e366e5 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/lib/Sema/SemaPseudoObject.cpp @@ -540,7 +540,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const { T = Prop->getType(); } else if (Getter) { - T = Getter->getResultType(); + T = Getter->getReturnType(); } else { return false; } @@ -813,7 +813,7 @@ bool ObjCPropertyOpBuilder::tryBuildGetOfReference(Expr *op, assert(Getter && "property has no setter and no getter!"); // Only do this if the getter returns an l-value reference type. - QualType resultType = Getter->getResultType(); + QualType resultType = Getter->getReturnType(); if (!resultType->isLValueReferenceType()) return false; result = buildRValueOperation(op); @@ -1170,7 +1170,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() { diag::note_parameter_type) << T; return false; } - QualType R = AtIndexGetter->getResultType(); + QualType R = AtIndexGetter->getReturnType(); if (!R->isObjCObjectPointerType()) { S.Diag(RefExpr->getKeyExpr()->getExprLoc(), diag::err_objc_indexing_method_result_type) << R << arrayRef; @@ -1237,18 +1237,15 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { BaseT->isObjCQualifiedIdType()); if (!AtIndexSetter && S.getLangOpts().DebuggerObjCLiteral) { - TypeSourceInfo *ResultTInfo = 0; + TypeSourceInfo *ReturnTInfo = 0; QualType ReturnType = S.Context.VoidTy; - AtIndexSetter = ObjCMethodDecl::Create(S.Context, SourceLocation(), - SourceLocation(), AtIndexSetterSelector, - ReturnType, - ResultTInfo, - S.Context.getTranslationUnitDecl(), - true /*Instance*/, false/*isVariadic*/, - /*isPropertyAccessor=*/false, - /*isImplicitlyDeclared=*/true, /*isDefined=*/false, - ObjCMethodDecl::Required, - false); + AtIndexSetter = ObjCMethodDecl::Create( + S.Context, SourceLocation(), SourceLocation(), AtIndexSetterSelector, + ReturnType, ReturnTInfo, S.Context.getTranslationUnitDecl(), + true /*Instance*/, false /*isVariadic*/, + /*isPropertyAccessor=*/false, + /*isImplicitlyDeclared=*/true, /*isDefined=*/false, + ObjCMethodDecl::Required, false); SmallVector<ParmVarDecl *, 2> Params; ParmVarDecl *object = ParmVarDecl::Create(S.Context, AtIndexSetter, SourceLocation(), SourceLocation(), diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index e9ae7b90f00..554535dcf22 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -2560,7 +2560,7 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity, static bool hasDeducedReturnType(FunctionDecl *FD) { const FunctionProtoType *FPT = FD->getTypeSourceInfo()->getType()->castAs<FunctionProtoType>(); - return FPT->getResultType()->isUndeducedType(); + return FPT->getReturnType()->isUndeducedType(); } /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements @@ -2579,7 +2579,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // FIXME: Blocks might have a return type of 'auto' explicitly specified. FunctionDecl *FD = CurLambda->CallOperator; if (CurCap->ReturnType.isNull()) - CurCap->ReturnType = FD->getResultType(); + CurCap->ReturnType = FD->getReturnType(); AutoType *AT = CurCap->ReturnType->getContainedAutoType(); assert(AT && "lost auto type from lambda return type"); @@ -2587,7 +2587,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { FD->setInvalidDecl(); return StmtError(); } - CurCap->ReturnType = FnRetType = FD->getResultType(); + CurCap->ReturnType = FnRetType = FD->getReturnType(); } else if (CurCap->HasImplicitReturnType) { // For blocks/lambdas with implicit return types, we check each return // statement individually, and deduce the common return type when the block @@ -2810,14 +2810,14 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { bool isObjCMethod = false; if (const FunctionDecl *FD = getCurFunctionDecl()) { - FnRetType = FD->getResultType(); + FnRetType = FD->getReturnType(); if (FD->hasAttrs()) Attrs = &FD->getAttrs(); if (FD->isNoReturn()) Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << FD->getDeclName(); } else if (ObjCMethodDecl *MD = getCurMethodDecl()) { - FnRetType = MD->getResultType(); + FnRetType = MD->getReturnType(); isObjCMethod = true; if (MD->hasAttrs()) Attrs = &MD->getAttrs(); @@ -2840,7 +2840,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { FD->setInvalidDecl(); return StmtError(); } else { - FnRetType = FD->getResultType(); + FnRetType = FD->getReturnType(); } } } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index dcfdd319990..008ed2755c2 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3899,12 +3899,12 @@ bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType( return true; } - return Visit(T->getResultType()); + return Visit(T->getReturnType()); } bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType( const FunctionNoProtoType* T) { - return Visit(T->getResultType()); + return Visit(T->getReturnType()); } bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType( @@ -6514,7 +6514,7 @@ bool Sema::CheckFunctionTemplateSpecialization( const FunctionProtoType *FPT = FT->castAs<FunctionProtoType>(); FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.TypeQuals |= Qualifiers::Const; - FT = Context.getFunctionType(FPT->getResultType(), + FT = Context.getFunctionType(FPT->getReturnType(), FPT->getParamTypes(), EPI); } } diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 256bb7c3951..94ef7f46fd9 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1375,11 +1375,10 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S, return Sema::TDK_NonDeducedMismatch; // Check return types. - if (Sema::TemplateDeductionResult Result - = DeduceTemplateArgumentsByTypeMatch(S, TemplateParams, - FunctionProtoParam->getResultType(), - FunctionProtoArg->getResultType(), - Info, Deduced, 0)) + if (Sema::TemplateDeductionResult Result = + DeduceTemplateArgumentsByTypeMatch( + S, TemplateParams, FunctionProtoParam->getReturnType(), + FunctionProtoArg->getReturnType(), Info, Deduced, 0)) return Result; return DeduceTemplateArguments( @@ -2614,11 +2613,11 @@ Sema::SubstituteExplicitTemplateArguments( CXXThisScopeRAII ThisScope(*this, ThisContext, ThisTypeQuals, getLangOpts().CPlusPlus11); - - ResultType = SubstType(Proto->getResultType(), - MultiLevelTemplateArgumentList(*ExplicitArgumentList), - Function->getTypeSpecStartLoc(), - Function->getDeclName()); + + ResultType = + SubstType(Proto->getReturnType(), + MultiLevelTemplateArgumentList(*ExplicitArgumentList), + Function->getTypeSpecStartLoc(), Function->getDeclName()); if (ResultType.isNull() || Trap.hasErrorOccurred()) return TDK_SubstitutionFailure; } @@ -2986,8 +2985,8 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, static QualType GetTypeOfFunction(Sema &S, const OverloadExpr::FindResult &R, FunctionDecl *Fn) { // We may need to deduce the return type of the function now. - if (S.getLangOpts().CPlusPlus1y && Fn->getResultType()->isUndeducedType() && - S.DeduceReturnType(Fn, R.Expression->getExprLoc(), /*Diagnose*/false)) + if (S.getLangOpts().CPlusPlus1y && Fn->getReturnType()->isUndeducedType() && + S.DeduceReturnType(Fn, R.Expression->getExprLoc(), /*Diagnose*/ false)) return QualType(); if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Fn)) @@ -3599,7 +3598,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, // type so that we treat it as a non-deduced context in what follows. bool HasDeducedReturnType = false; if (getLangOpts().CPlusPlus1y && InOverloadResolution && - Function->getResultType()->getContainedAutoType()) { + Function->getReturnType()->getContainedAutoType()) { FunctionType = SubstAutoType(FunctionType, Context.DependentTy); HasDeducedReturnType = true; } @@ -3624,7 +3623,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, // If the function has a deduced return type, deduce it now, so we can check // that the deduced function type matches the requested type. if (HasDeducedReturnType && - Specialization->getResultType()->isUndeducedType() && + Specialization->getReturnType()->isUndeducedType() && DeduceReturnType(Specialization, Info.getLocation(), false)) return TDK_MiscellaneousDeductionFailure; @@ -3653,7 +3652,7 @@ static inline void SubstAutoWithinFunctionReturnType(FunctionDecl *F, QualType TypeToReplaceAutoWith, Sema &S) { assert(!TypeToReplaceAutoWith->getContainedAutoType()); - QualType AutoResultType = F->getResultType(); + QualType AutoResultType = F->getReturnType(); assert(AutoResultType->getContainedAutoType()); QualType DeducedResultType = S.SubstAutoType(AutoResultType, TypeToReplaceAutoWith); @@ -3678,7 +3677,7 @@ SpecializeCorrespondingLambdaCallOperatorAndInvoker( assert(LambdaClass && LambdaClass->isGenericLambda()); CXXMethodDecl *CallOpGeneric = LambdaClass->getLambdaCallOperator(); - QualType CallOpResultType = CallOpGeneric->getResultType(); + QualType CallOpResultType = CallOpGeneric->getReturnType(); const bool GenericLambdaCallOperatorHasDeducedReturnType = CallOpResultType->getContainedAutoType(); @@ -3695,15 +3694,15 @@ SpecializeCorrespondingLambdaCallOperatorAndInvoker( return Result; // If we need to deduce the return type, do so (instantiates the callop). - if (GenericLambdaCallOperatorHasDeducedReturnType && - CallOpSpecialized->getResultType()->isUndeducedType()) + if (GenericLambdaCallOperatorHasDeducedReturnType && + CallOpSpecialized->getReturnType()->isUndeducedType()) S.DeduceReturnType(CallOpSpecialized, CallOpSpecialized->getPointOfInstantiation(), /*Diagnose*/ true); // Check to see if the return type of the destination ptr-to-function // matches the return type of the call operator. - if (!S.Context.hasSameType(CallOpSpecialized->getResultType(), + if (!S.Context.hasSameType(CallOpSpecialized->getReturnType(), ReturnTypeOfDestFunctionPtr)) return Sema::TDK_NonDeducedMismatch; // Since we have succeeded in matching the source and destination @@ -3722,8 +3721,8 @@ SpecializeCorrespondingLambdaCallOperatorAndInvoker( "If the call operator succeeded so should the invoker!"); // Set the result type to match the corresponding call operator // specialization's result type. - if (GenericLambdaCallOperatorHasDeducedReturnType && - InvokerSpecialized->getResultType()->isUndeducedType()) { + if (GenericLambdaCallOperatorHasDeducedReturnType && + InvokerSpecialized->getReturnType()->isUndeducedType()) { // Be sure to get the type to replace 'auto' with and not // the full result type of the call op specialization // to substitute into the 'auto' of the invoker and conversion @@ -3732,9 +3731,9 @@ SpecializeCorrespondingLambdaCallOperatorAndInvoker( // int* (*fp)(int*) = [](auto* a) -> auto* { return a; }; // We don't want to subst 'int*' into 'auto' to get int**. - QualType TypeToReplaceAutoWith = - CallOpSpecialized->getResultType()-> - getContainedAutoType()->getDeducedType(); + QualType TypeToReplaceAutoWith = CallOpSpecialized->getReturnType() + ->getContainedAutoType() + ->getDeducedType(); SubstAutoWithinFunctionReturnType(InvokerSpecialized, TypeToReplaceAutoWith, S); SubstAutoWithinFunctionReturnType(ConversionSpecialized, @@ -3750,7 +3749,7 @@ SpecializeCorrespondingLambdaCallOperatorAndInvoker( FunctionProtoType::ExtProtoInfo EPI = InvokerFPT->getExtProtoInfo(); EPI.TypeQuals = 0; InvokerSpecialized->setType(S.Context.getFunctionType( - InvokerFPT->getResultType(), InvokerFPT->getParamTypes(), EPI)); + InvokerFPT->getReturnType(), InvokerFPT->getParamTypes(), EPI)); return Sema::TDK_Success; } /// \brief Deduce template arguments for a templated conversion @@ -3873,8 +3872,8 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *ConversionTemplate, "Can only convert from lambda to ptr-to-function"); const FunctionType *ToFunType = A->getPointeeType().getTypePtr()->getAs<FunctionType>(); - const QualType DestFunctionPtrReturnType = ToFunType->getResultType(); - + const QualType DestFunctionPtrReturnType = ToFunType->getReturnType(); + // Create the corresponding specializations of the call operator and // the static-invoker; and if the return type is auto, // deduce the return type and check if it matches the @@ -4119,12 +4118,12 @@ void Sema::DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init) { bool Sema::DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose) { - assert(FD->getResultType()->isUndeducedType()); + assert(FD->getReturnType()->isUndeducedType()); if (FD->getTemplateInstantiationPattern()) InstantiateFunctionDefinition(Loc, FD); - bool StillUndeduced = FD->getResultType()->isUndeducedType(); + bool StillUndeduced = FD->getReturnType()->isUndeducedType(); if (StillUndeduced && Diagnose && !FD->isInvalidDecl()) { Diag(Loc, diag::err_auto_fn_used_before_defined) << FD; Diag(FD->getLocation(), diag::note_callee_decl) << FD; @@ -4254,12 +4253,10 @@ static bool isAtLeastAsSpecializedAs(Sema &S, case TPOC_Conversion: // - In the context of a call to a conversion operator, the return types // of the conversion function templates are used. - if (DeduceTemplateArgumentsByTypeMatch(S, TemplateParams, - Proto2->getResultType(), - Proto1->getResultType(), - Info, Deduced, TDF_None, - /*PartialOrdering=*/true, - RefParamComparisons)) + if (DeduceTemplateArgumentsByTypeMatch( + S, TemplateParams, Proto2->getReturnType(), Proto1->getReturnType(), + Info, Deduced, TDF_None, + /*PartialOrdering=*/true, RefParamComparisons)) return false; break; @@ -4303,9 +4300,8 @@ static bool isAtLeastAsSpecializedAs(Sema &S, break; case TPOC_Conversion: - ::MarkUsedTemplateParameters(S.Context, Proto2->getResultType(), false, - TemplateParams->getDepth(), - UsedParameters); + ::MarkUsedTemplateParameters(S.Context, Proto2->getReturnType(), false, + TemplateParams->getDepth(), UsedParameters); break; case TPOC_Other: @@ -4880,8 +4876,8 @@ MarkUsedTemplateParameters(ASTContext &Ctx, QualType T, case Type::FunctionProto: { const FunctionProtoType *Proto = cast<FunctionProtoType>(T); - MarkUsedTemplateParameters(Ctx, Proto->getResultType(), OnlyDeduced, - Depth, Used); + MarkUsedTemplateParameters(Ctx, Proto->getReturnType(), OnlyDeduced, Depth, + Used); for (unsigned I = 0, N = Proto->getNumParams(); I != N; ++I) MarkUsedTemplateParameters(Ctx, Proto->getParamType(I), OnlyDeduced, Depth, Used); diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 438798433c1..a434e20634d 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1217,7 +1217,7 @@ static QualType adjustFunctionTypeForInstantiation(ASTContext &Context, FunctionProtoType::ExtProtoInfo NewEPI = NewFunc->getExtProtoInfo(); NewEPI.ExtInfo = OrigFunc->getExtInfo(); - return Context.getFunctionType(NewFunc->getResultType(), + return Context.getFunctionType(NewFunc->getReturnType(), NewFunc->getParamTypes(), NewEPI); } @@ -3160,7 +3160,7 @@ static void InstantiateExceptionSpec(Sema &SemaRef, FunctionDecl *New, EPI.Exceptions = Exceptions.data(); EPI.NoexceptExpr = NoexceptExpr; - New->setType(SemaRef.Context.getFunctionType(NewProto->getResultType(), + New->setType(SemaRef.Context.getFunctionType(NewProto->getReturnType(), NewProto->getParamTypes(), EPI)); } @@ -3177,7 +3177,7 @@ void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, // so that our callers don't have to cope with EST_Uninstantiated. FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); EPI.ExceptionSpecType = EST_None; - Decl->setType(Context.getFunctionType(Proto->getResultType(), + Decl->setType(Context.getFunctionType(Proto->getReturnType(), Proto->getParamTypes(), EPI)); return; } @@ -3262,7 +3262,7 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, EPI.ExceptionSpecDecl = New; EPI.ExceptionSpecTemplate = ExceptionSpecTemplate; New->setType(SemaRef.Context.getFunctionType( - NewProto->getResultType(), NewProto->getParamTypes(), EPI)); + NewProto->getReturnType(), NewProto->getParamTypes(), EPI)); } else { ::InstantiateExceptionSpec(SemaRef, New, Proto, TemplateArgs); } @@ -3390,10 +3390,10 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // initializer or return value, and class template specializations, other // explicit instantiation declarations have the effect of suppressing the // implicit instantiation of the entity to which they refer. - if (Function->getTemplateSpecializationKind() - == TSK_ExplicitInstantiationDeclaration && + if (Function->getTemplateSpecializationKind() == + TSK_ExplicitInstantiationDeclaration && !PatternDecl->isInlined() && - !PatternDecl->getResultType()->getContainedAutoType()) + !PatternDecl->getReturnType()->getContainedAutoType()) return; if (PatternDecl->isInlined()) diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 4b3e6023cf5..c2ff2238d5f 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -3114,7 +3114,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, EPI.TypeQuals = 0; EPI.RefQualifier = RQ_None; - T = Context.getFunctionType(FnTy->getResultType(), FnTy->getParamTypes(), + T = Context.getFunctionType(FnTy->getReturnType(), FnTy->getParamTypes(), EPI); // Rebuild any parens around the identifier in the function type. for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) { diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 27380f8c8d4..37f6bb79ec2 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -2532,11 +2532,9 @@ public: CK_BuiltinFnToFnPtr).take(); // Build the CallExpr - ExprResult TheCall = SemaRef.Owned( - new (SemaRef.Context) CallExpr(SemaRef.Context, Callee, SubExprs, - Builtin->getCallResultType(), - Expr::getValueKindForType(Builtin->getResultType()), - RParenLoc)); + ExprResult TheCall = SemaRef.Owned(new (SemaRef.Context) CallExpr( + SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(), + Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc)); // Type-check the __builtin_shufflevector expression. return SemaRef.SemaBuiltinShuffleVector(cast<CallExpr>(TheCall.take())); @@ -4389,7 +4387,7 @@ TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB, // FIXME: Need to transform the exception-specification too. QualType Result = TL.getType(); - if (getDerived().AlwaysRebuild() || ResultType != T->getResultType() || + if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() || T->getNumParams() != ParamTypes.size() || !std::equal(T->param_type_begin(), T->param_type_end(), ParamTypes.begin())) { @@ -4420,8 +4418,7 @@ QualType TreeTransform<Derived>::TransformFunctionNoProtoType( return QualType(); QualType Result = TL.getType(); - if (getDerived().AlwaysRebuild() || - ResultType != T->getResultType()) + if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType()) Result = getDerived().RebuildFunctionNoProtoType(ResultType); FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result); @@ -9261,7 +9258,7 @@ TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) { const FunctionProtoType *exprFunctionType = E->getFunctionType(); QualType exprResultType = - getDerived().TransformType(exprFunctionType->getResultType()); + getDerived().TransformType(exprFunctionType->getReturnType()); QualType functionType = getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, |