From 49547a5378cf29e75ff84554469fc20315832806 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 27 Aug 2021 10:32:21 -0700 Subject: [PATCH] [NFC][Basic] Import llvm::isa_and_nonnull to 'swift' namespace Just for convenicence. * Replace `llvm::isa_and_nonnull` with imported `isa_and_nonnull` * Repalce some `EXPR && isa(EXPR)` with `isa_and_nonnull(EXPR)` --- include/swift/Basic/LLVM.h | 1 + lib/AST/ASTWalker.cpp | 2 +- lib/ClangImporter/ImportDecl.cpp | 3 +-- lib/IDE/CodeCompletion.cpp | 6 +++--- lib/IDE/Refactoring.cpp | 4 ++-- lib/IRGen/IRGenDebugInfo.cpp | 8 +++----- lib/IRGen/IRGenSIL.cpp | 5 ++--- lib/Parse/ParseDecl.cpp | 4 ++-- lib/SIL/IR/SILFunctionType.cpp | 4 ++-- lib/SILGen/SILGenApply.cpp | 4 ++-- lib/SILGen/SILGenConvert.cpp | 2 +- lib/SILGen/SILGenLValue.cpp | 3 +-- lib/SILOptimizer/Mandatory/Differentiation.cpp | 2 +- lib/Sema/CSApply.cpp | 3 +-- lib/Sema/CSDiagnostics.cpp | 12 ++++++------ lib/Sema/CSSimplify.cpp | 2 +- lib/Sema/ConstraintSystem.cpp | 2 +- lib/Sema/MiscDiagnostics.cpp | 6 +++--- lib/Sema/TypeCheckAttr.cpp | 2 +- lib/Sema/TypeCheckAvailability.cpp | 3 +-- lib/Sema/TypeCheckConcurrency.cpp | 4 ++-- lib/Sema/TypeCheckDecl.cpp | 2 +- lib/Sema/TypeCheckDeclPrimary.cpp | 2 +- lib/Sema/TypeCheckStmt.cpp | 2 +- lib/Sema/TypeCheckType.cpp | 2 +- lib/Serialization/Deserialization.cpp | 3 +-- 26 files changed, 43 insertions(+), 50 deletions(-) diff --git a/include/swift/Basic/LLVM.h b/include/swift/Basic/LLVM.h index 40ab0fe664509..35eb452f2459d 100644 --- a/include/swift/Basic/LLVM.h +++ b/include/swift/Basic/LLVM.h @@ -73,6 +73,7 @@ namespace llvm { namespace swift { // Casting operators. using llvm::isa; + using llvm::isa_and_nonnull; using llvm::cast; using llvm::dyn_cast; using llvm::dyn_cast_or_null; diff --git a/lib/AST/ASTWalker.cpp b/lib/AST/ASTWalker.cpp index d0e2970fd9e98..a2adbee92cd57 100644 --- a/lib/AST/ASTWalker.cpp +++ b/lib/AST/ASTWalker.cpp @@ -1253,7 +1253,7 @@ class Traversal : public ASTVisitorgetParentPatternBinding()) return true; auto walkerParentAsStmt = Walker.Parent.getAsStmt(); - if (walkerParentAsStmt && isa(walkerParentAsStmt)) + if (isa_and_nonnull(walkerParentAsStmt)) return true; } return false; diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 021dd51fa8ee1..d3d99f3696263 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -1343,8 +1343,7 @@ synthesizeValueConstructorBody(AbstractFunctionDecl *afd, void *context) { for (unsigned i = 0, e = members.size(); i < e; ++i) { auto var = members[i]; - if (var->hasClangNode() && - isa(var->getClangDecl())) + if (isa_and_nonnull(var->getClangDecl())) continue; if (var->hasStorage() == (pass != 0)) { diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 8f10b297b9359..d615459274be7 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -6366,7 +6366,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink, if (ParsedDecl && ParsedDecl == CurDeclContext->getAsDecl()) DC = ParsedDecl->getDeclContext(); if (!isa(DC)) - if (DC->isTypeContext() || (ParsedDecl && isa(ParsedDecl))) + if (DC->isTypeContext() || isa_and_nonnull(ParsedDecl)) addOpaqueTypeKeyword(Sink); LLVM_FALLTHROUGH; @@ -7012,7 +7012,7 @@ void CodeCompletionCallbacksImpl::doneParsing() { } if (auto *DRE = dyn_cast_or_null(ParsedExpr)) { Lookup.setIsSelfRefExpr(DRE->getDecl()->getName() == Context.Id_self); - } else if (ParsedExpr && isa(ParsedExpr)) { + } else if (isa_and_nonnull(ParsedExpr)) { Lookup.setIsSuperRefExpr(); } @@ -7205,7 +7205,7 @@ void CodeCompletionCallbacksImpl::doneParsing() { Lookup.setHaveLParen(true); for (auto &typeAndDecl : ContextInfo.getPossibleCallees()) { auto apply = ContextInfo.getAnalyzedExpr(); - if (apply && isa(apply)) { + if (isa_and_nonnull(apply)) { Lookup.addSubscriptCallPattern( typeAndDecl.Type, dyn_cast_or_null(typeAndDecl.Decl), diff --git a/lib/IDE/Refactoring.cpp b/lib/IDE/Refactoring.cpp index f35cdba32193c..c2681580488c1 100644 --- a/lib/IDE/Refactoring.cpp +++ b/lib/IDE/Refactoring.cpp @@ -4505,7 +4505,7 @@ struct AsyncHandlerParamDesc : public AsyncHandlerDesc { } bool alternativeIsAccessor() const { - return Alternative && isa(Alternative); + return isa_and_nonnull(Alternative); } }; @@ -6828,7 +6828,7 @@ class AsyncConverter : private SourceEntityWalker { // for the completion handler call, e.g 'return completion(args...)'. In // that case, be sure not to add another return. auto *parent = getWalker().Parent.getAsStmt(); - if (parent && isa(parent) && + if (isa_and_nonnull(parent) && !cast(parent)->isImplicit()) { // The statement already has a return keyword. Don't add another one. AddedReturnOrThrow = false; diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index b2ef131188099..6e36a6a0ce02c 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -1690,8 +1690,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { static bool canMangle(TypeBase *Ty) { // TODO: C++ types are not yet supported (SR-13223). if (Ty->getStructOrBoundGenericStruct() && - Ty->getStructOrBoundGenericStruct()->getClangDecl() && - isa( + isa_and_nonnull( Ty->getStructOrBoundGenericStruct()->getClangDecl())) return false; @@ -2445,7 +2444,7 @@ void IRGenDebugInfoImpl::emitVariableDeclaration( while (isa(Scope)) Scope = cast(Scope)->getScope(); } - assert(Scope && isa(Scope) && "variable has no scope"); + assert(isa_and_nonnull(Scope) && "variable has no scope"); llvm::DIFile *Unit = getFile(Scope); llvm::DIType *DITy = getOrCreateType(DbgTy); assert(DITy && "could not determine debug type of variable"); @@ -2636,8 +2635,7 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration( if (MetatypeType *metaTy = dyn_cast(ty)) ty = metaTy->getInstanceType().getPointer(); if (ty->getStructOrBoundGenericStruct() && - ty->getStructOrBoundGenericStruct()->getClangDecl() && - isa( + isa_and_nonnull( ty->getStructOrBoundGenericStruct()->getClangDecl())) return; } diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 2eaea7349f480..c7ad88de3d2a1 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -1065,8 +1065,7 @@ class IRGenSILFunction : if (MetatypeType *metaTy = dyn_cast(ty)) ty = metaTy->getRootClass().getPointer(); if (ty->getStructOrBoundGenericStruct() && - ty->getStructOrBoundGenericStruct()->getClangDecl() && - isa( + isa_and_nonnull( ty->getStructOrBoundGenericStruct()->getClangDecl())) return; } @@ -1709,7 +1708,7 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f) CurFn->addFnAttr(llvm::Attribute::SanitizeAddress); if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Thread) { auto declContext = f->getDeclContext(); - if (declContext && isa(declContext)) { + if (isa_and_nonnull(declContext)) { // Do not report races in deinit and anything called from it // because TSan does not observe synchronization between retain // count dropping to '0' and the object deinitialization. diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index e0ce5a39164d7..a552cef9991c8 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -6906,7 +6906,7 @@ ParserResult Parser::parseDeclFunc(SourceLoc StaticLoc, CurDeclContext); // Let the source file track the opaque return type mapping, if any. - if (FuncRetTy && isa(FuncRetTy) && + if (isa_and_nonnull(FuncRetTy) && !InInactiveClauseEnvironment) { if (auto sf = CurDeclContext->getParentSourceFile()) { sf->addUnvalidatedDeclWithOpaqueResultType(FD); @@ -7773,7 +7773,7 @@ Parser::parseDeclSubscript(SourceLoc StaticLoc, Subscript->getAttrs() = Attributes; // Let the source file track the opaque return type mapping, if any. - if (ElementTy.get() && isa(ElementTy.get()) && + if (isa_and_nonnull(ElementTy.get()) && !InInactiveClauseEnvironment) { if (auto sf = CurDeclContext->getParentSourceFile()) { sf->addUnvalidatedDeclWithOpaqueResultType(Subscript); diff --git a/lib/SIL/IR/SILFunctionType.cpp b/lib/SIL/IR/SILFunctionType.cpp index 21141bf8d9f4a..4d83f23e63e04 100644 --- a/lib/SIL/IR/SILFunctionType.cpp +++ b/lib/SIL/IR/SILFunctionType.cpp @@ -4309,8 +4309,8 @@ TypeConverter::getLoweredFormalTypes(SILDeclRef constant, // If this is a C++ constructor, don't add the metatype "self" parameter // because we'll never use it and it will cause problems in IRGen. - if (constant.getDecl()->getClangDecl() && - isa(constant.getDecl()->getClangDecl())) { + if (isa_and_nonnull( + constant.getDecl()->getClangDecl())) { // But, make sure it is actually a metatype that we're not adding. If // changes to the self parameter are made in the future, this logic may // need to be updated. diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index e75147b5c77f5..f1f00be426a2a 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -555,8 +555,8 @@ class Callee { }; // Remove the metatype "self" parameter by making this a static member. - if (constant->getDecl()->getClangDecl() && - isa(constant->getDecl()->getClangDecl())) + if (isa_and_nonnull( + constant->getDecl()->getClangDecl())) result.foreign.self.setStatic(); return result; diff --git a/lib/SILGen/SILGenConvert.cpp b/lib/SILGen/SILGenConvert.cpp index c9173874c508e..774221b0f5fad 100644 --- a/lib/SILGen/SILGenConvert.cpp +++ b/lib/SILGen/SILGenConvert.cpp @@ -594,7 +594,7 @@ class ExistentialInitialization final : public SingleBufferInitialization { } bool isInPlaceInitializationOfGlobal() const override { - return existential && isa(existential); + return isa_and_nonnull(existential); } void finishInitialization(SILGenFunction &SGF) override { diff --git a/lib/SILGen/SILGenLValue.cpp b/lib/SILGen/SILGenLValue.cpp index 68c3e1847078b..5794db6982823 100644 --- a/lib/SILGen/SILGenLValue.cpp +++ b/lib/SILGen/SILGenLValue.cpp @@ -3138,8 +3138,7 @@ bool isCallToReplacedInDynamicReplacement(SILGenFunction &SGF, bool &isObjCReplacementSelfCall); static bool isCallToSelfOfCurrentFunction(SILGenFunction &SGF, LookupExpr *e) { - return SGF.FunctionDC->getAsDecl() && - isa(SGF.FunctionDC->getAsDecl()) && + return isa_and_nonnull(SGF.FunctionDC->getAsDecl()) && e->getBase()->isSelfExprOf( cast(SGF.FunctionDC->getAsDecl()), false); } diff --git a/lib/SILOptimizer/Mandatory/Differentiation.cpp b/lib/SILOptimizer/Mandatory/Differentiation.cpp index cead8d0615ab6..23a57616a87d0 100644 --- a/lib/SILOptimizer/Mandatory/Differentiation.cpp +++ b/lib/SILOptimizer/Mandatory/Differentiation.cpp @@ -616,7 +616,7 @@ emitDerivativeFunctionReference( context.emitNondifferentiabilityError( original, invoker, diag::autodiff_private_derivative_from_fragile, fragileKind, - llvm::isa_and_nonnull( + isa_and_nonnull( originalFRI->getLoc().getAsASTNode())); return None; } diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 094a6e6c8f1b1..cc553f9828b19 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -202,8 +202,7 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl, // If this is a C++ function template, get it's specialization for the given // substitution map and update the decl accordingly. - if (decl->getClangDecl() && - isa(decl->getClangDecl())) { + if (isa_and_nonnull(decl->getClangDecl())) { auto *newFn = decl->getASTContext() .getClangModuleLoader() diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index 8e3558af86e9e..88454bedbcbb3 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -3162,7 +3162,7 @@ void ContextualFailure::tryComputedPropertyFixIts() const { auto *initExpr = PBD->getInit(i); if (!VD->isStatic() && !VD->getAttrs().getAttribute() && - initExpr && isa(initExpr)) { + isa_and_nonnull(initExpr)) { auto diag = emitDiagnostic(diag::extension_stored_property_fixit, VD->getName()); diag.fixItRemove(PBD->getEqualLoc(i)); @@ -3956,7 +3956,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() { if (!argExpr) return false; auto possibleApplyExpr = findParentExpr(expr); - return possibleApplyExpr && isa(possibleApplyExpr); + return isa_and_nonnull(possibleApplyExpr); }; auto *initCall = findParentExpr(findParentExpr(ctorRef)); @@ -6924,14 +6924,14 @@ bool MissingContextualBaseInMemberRefFailure::diagnoseAsError() { auto *parentExpr = findParentExpr(anchor); // Look through immediate call of unresolved member (e.g., `.foo(0)`). - if (parentExpr && isa(parentExpr)) + if (isa_and_nonnull(parentExpr)) parentExpr = findParentExpr(parentExpr); // FIXME: We should probably look through the entire member chain so that // something like `let _ = .foo().bar` gets the "no contextual type" error // rather than the "Cannot infer contextual base" error. UnresolvedMemberChainResultExpr *resultExpr = nullptr; - if (parentExpr && isa(parentExpr)) { + if (isa_and_nonnull(parentExpr)) { resultExpr = cast(parentExpr); parentExpr = findParentExpr(parentExpr); } @@ -7469,12 +7469,12 @@ bool MissingContextualTypeForNil::diagnoseAsError() { // attempt any types for it. auto *parentExpr = findParentExpr(expr); - while (parentExpr && isa(parentExpr)) + while (isa_and_nonnull(parentExpr)) parentExpr = findParentExpr(parentExpr); // In cases like `_ = nil?` AST would have `nil` // wrapped in `BindOptionalExpr`. - if (parentExpr && isa(parentExpr)) + if (isa_and_nonnull(parentExpr)) parentExpr = findParentExpr(parentExpr); if (parentExpr) { diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 5a3a5824c5a16..98b3432b02157 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -2318,7 +2318,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2, if (shouldAttemptFixes()) { auto *anchor = locator.trySimplifyToExpr(); - if (anchor && isa(anchor) && + if (isa_and_nonnull(anchor) && isSingleTupleParam(ctx, func2Params) && canImplodeParams(func1Params)) { auto *fix = AllowClosureParamDestructuring::create( diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index 55bb06ce7c880..f5e5389d76eab 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -5096,7 +5096,7 @@ ConstraintSystem::isConversionEphemeral(ConversionRestrictionKind conversion, // For an instance member, the base must be an @lvalue struct type. if (auto *lvt = simplifyType(getType(base))->getAs()) { auto *nominal = lvt->getObjectType()->getAnyNominal(); - if (nominal && isa(nominal)) { + if (isa_and_nonnull(nominal)) { subExpr = base; continue; } diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index 8e425b4d589f5..6894823e67226 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -248,7 +248,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC, // Void to _ then warn, because that is redundant. if (auto DAE = dyn_cast(destExpr)) { if (auto CE = dyn_cast(AE->getSrc())) { - if (CE->getCalledValue() && isa(CE->getCalledValue()) && + if (isa_and_nonnull(CE->getCalledValue()) && CE->getType()->isVoid()) { Ctx.Diags .diagnose(DAE->getLoc(), @@ -1427,7 +1427,7 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) { // But silence the warning if the base was explicitly qualified. auto parentAsExpr = Parent.getAsExpr(); - if (parentAsExpr && isa(parentAsExpr)) + if (isa_and_nonnull(parentAsExpr)) shouldDiagnose = false; if (shouldDiagnose) { @@ -4078,7 +4078,7 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E, if (auto *apply = dyn_cast(E)) { auto *decl = apply->getCalledValue(); - if (decl && isa(decl)) + if (isa_and_nonnull(decl)) return decl; } return nullptr; diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 34d9250abed3a..32babe8ab06c0 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -2973,7 +2973,7 @@ void AttributeChecker::visitCustomAttr(CustomAttr *attr) { if (isa(D)) { // Check for unsupported declarations. auto *context = D->getDeclContext()->getAsDecl(); - if (context && isa(context)) { + if (isa_and_nonnull(context)) { diagnose(attr->getLocation(), diag::property_wrapper_param_not_supported, context->getDescriptiveKind()); diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp index 4ce3edf933a5c..e63ee35363d61 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -1978,8 +1978,7 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag, // Continue on to diagnose any argument label renames. - } else if (parsed.BaseName == "init" && - call && isa(call)) { + } else if (parsed.BaseName == "init" && isa_and_nonnull(call)) { // For initializers, replace with a "call" of the context type...but only // if we know we're doing a call (rather than a first-class reference). if (parsed.isMember()) { diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index 78a383e8fb4d4..9c87b32c31430 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -1591,7 +1591,7 @@ namespace { } } - } else if (llvm::isa_and_nonnull(context) && + } else if (isa_and_nonnull(context) && isa(decl)) { // actor-isolated non-isolated-self calls are implicitly async // and thus OK. @@ -1649,7 +1649,7 @@ namespace { ValueDecl *decl = concDeclRef.getDecl(); ThrowsMarkingResult result = ThrowsMarkingResult::NotFound; - if (llvm::isa_and_nonnull(context)) { + if (isa_and_nonnull(context)) { if (auto func = dyn_cast(decl)) { if (func->isDistributed() && !func->hasThrows()) { // A distributed function is implicitly throwing if called from diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index 873e93b0ea98a..db7de0a696460 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -1935,7 +1935,7 @@ bool swift::isMemberOperator(FuncDecl *decl, Type type) { auto selfNominal = DC->getSelfNominalTypeDecl(); // Check the parameters for a reference to 'Self'. - bool isProtocol = selfNominal && isa(selfNominal); + bool isProtocol = isa_and_nonnull(selfNominal); for (auto param : *decl->getParameters()) { // Look through a metatype reference, if there is one. auto paramType = param->getInterfaceType()->getMetatypeInstanceType(); diff --git a/lib/Sema/TypeCheckDeclPrimary.cpp b/lib/Sema/TypeCheckDeclPrimary.cpp index 35b646516e46b..a3e5ef349347e 100644 --- a/lib/Sema/TypeCheckDeclPrimary.cpp +++ b/lib/Sema/TypeCheckDeclPrimary.cpp @@ -2777,7 +2777,7 @@ class DeclChecker : public DeclVisitor { if (FD->getDeclContext()->isTypeContext()) { if (FD->isOperator() && !isMemberOperator(FD, nullptr)) { auto selfNominal = FD->getDeclContext()->getSelfNominalTypeDecl(); - auto isProtocol = selfNominal && isa(selfNominal); + auto isProtocol = isa_and_nonnull(selfNominal); // We did not find 'Self'. Complain. FD->diagnose(diag::operator_in_unrelated_type, FD->getDeclContext()->getDeclaredInterfaceType(), isProtocol, diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index 482b0bd3a1597..647a3ec163492 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -1422,7 +1422,7 @@ void TypeChecker::checkIgnoredExpr(Expr *E) { // Otherwise, complain. Start with more specific diagnostics. // Diagnose unused constructor calls. - if (callee && isa(callee) && !call->isImplicit()) { + if (isa_and_nonnull(callee) && !call->isImplicit()) { DE.diagnose(fn->getLoc(), diag::expression_unused_init_result, callee->getDeclContext()->getDeclaredInterfaceType()) .highlight(call->getArg()->getSourceRange()); diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp index e9ea56b2187ed..233e8e4106df4 100644 --- a/lib/Sema/TypeCheckType.cpp +++ b/lib/Sema/TypeCheckType.cpp @@ -3762,7 +3762,7 @@ TypeResolver::resolveCompositionType(CompositionTypeRepr *repr, if (ty->hasError()) return ty; auto nominalDecl = ty->getAnyNominal(); - if (nominalDecl && isa(nominalDecl)) { + if (isa_and_nonnull(nominalDecl)) { if (checkSuperclass(tyR->getStartLoc(), ty)) continue; diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 1c4aab3483a5a..d1b6d2257b38f 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -6495,8 +6495,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance, } else { fatal(thirdOrError.takeError()); } - if (third && - isa(third) && + if (isa_and_nonnull(third) && third->getModuleContext() != getAssociatedModule() && !third->getDeclaredInterfaceType()->isEqual(second)) { // Conservatively drop references to typealiases in other modules