Skip to content

Commit 857490e

Browse files
authored
Merge pull request #39078 from rintaro/isa_and_nonnull
2 parents bbd516f + 49547a5 commit 857490e

26 files changed

+43
-50
lines changed

include/swift/Basic/LLVM.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace llvm {
7373
namespace swift {
7474
// Casting operators.
7575
using llvm::isa;
76+
using llvm::isa_and_nonnull;
7677
using llvm::cast;
7778
using llvm::dyn_cast;
7879
using llvm::dyn_cast_or_null;

lib/AST/ASTWalker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
12531253
if (Walker.Parent.getAsDecl() && VD->getParentPatternBinding())
12541254
return true;
12551255
auto walkerParentAsStmt = Walker.Parent.getAsStmt();
1256-
if (walkerParentAsStmt && isa<BraceStmt>(walkerParentAsStmt))
1256+
if (isa_and_nonnull<BraceStmt>(walkerParentAsStmt))
12571257
return true;
12581258
}
12591259
return false;

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,7 @@ synthesizeValueConstructorBody(AbstractFunctionDecl *afd, void *context) {
13431343
for (unsigned i = 0, e = members.size(); i < e; ++i) {
13441344
auto var = members[i];
13451345

1346-
if (var->hasClangNode() &&
1347-
isa<clang::IndirectFieldDecl>(var->getClangDecl()))
1346+
if (isa_and_nonnull<clang::IndirectFieldDecl>(var->getClangDecl()))
13481347
continue;
13491348

13501349
if (var->hasStorage() == (pass != 0)) {

lib/IDE/CodeCompletion.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6366,7 +6366,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
63666366
if (ParsedDecl && ParsedDecl == CurDeclContext->getAsDecl())
63676367
DC = ParsedDecl->getDeclContext();
63686368
if (!isa<ProtocolDecl>(DC))
6369-
if (DC->isTypeContext() || (ParsedDecl && isa<FuncDecl>(ParsedDecl)))
6369+
if (DC->isTypeContext() || isa_and_nonnull<FuncDecl>(ParsedDecl))
63706370
addOpaqueTypeKeyword(Sink);
63716371

63726372
LLVM_FALLTHROUGH;
@@ -7012,7 +7012,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
70127012
}
70137013
if (auto *DRE = dyn_cast_or_null<DeclRefExpr>(ParsedExpr)) {
70147014
Lookup.setIsSelfRefExpr(DRE->getDecl()->getName() == Context.Id_self);
7015-
} else if (ParsedExpr && isa<SuperRefExpr>(ParsedExpr)) {
7015+
} else if (isa_and_nonnull<SuperRefExpr>(ParsedExpr)) {
70167016
Lookup.setIsSuperRefExpr();
70177017
}
70187018

@@ -7205,7 +7205,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
72057205
Lookup.setHaveLParen(true);
72067206
for (auto &typeAndDecl : ContextInfo.getPossibleCallees()) {
72077207
auto apply = ContextInfo.getAnalyzedExpr();
7208-
if (apply && isa<SubscriptExpr>(apply)) {
7208+
if (isa_and_nonnull<SubscriptExpr>(apply)) {
72097209
Lookup.addSubscriptCallPattern(
72107210
typeAndDecl.Type,
72117211
dyn_cast_or_null<SubscriptDecl>(typeAndDecl.Decl),

lib/IDE/Refactoring.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4505,7 +4505,7 @@ struct AsyncHandlerParamDesc : public AsyncHandlerDesc {
45054505
}
45064506

45074507
bool alternativeIsAccessor() const {
4508-
return Alternative && isa<AccessorDecl>(Alternative);
4508+
return isa_and_nonnull<AccessorDecl>(Alternative);
45094509
}
45104510
};
45114511

@@ -6828,7 +6828,7 @@ class AsyncConverter : private SourceEntityWalker {
68286828
// for the completion handler call, e.g 'return completion(args...)'. In
68296829
// that case, be sure not to add another return.
68306830
auto *parent = getWalker().Parent.getAsStmt();
6831-
if (parent && isa<ReturnStmt>(parent) &&
6831+
if (isa_and_nonnull<ReturnStmt>(parent) &&
68326832
!cast<ReturnStmt>(parent)->isImplicit()) {
68336833
// The statement already has a return keyword. Don't add another one.
68346834
AddedReturnOrThrow = false;

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,8 +1690,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
16901690
static bool canMangle(TypeBase *Ty) {
16911691
// TODO: C++ types are not yet supported (SR-13223).
16921692
if (Ty->getStructOrBoundGenericStruct() &&
1693-
Ty->getStructOrBoundGenericStruct()->getClangDecl() &&
1694-
isa<clang::CXXRecordDecl>(
1693+
isa_and_nonnull<clang::CXXRecordDecl>(
16951694
Ty->getStructOrBoundGenericStruct()->getClangDecl()))
16961695
return false;
16971696

@@ -2445,7 +2444,7 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
24452444
while (isa<llvm::DILexicalBlock>(Scope))
24462445
Scope = cast<llvm::DILexicalBlock>(Scope)->getScope();
24472446
}
2448-
assert(Scope && isa<llvm::DIScope>(Scope) && "variable has no scope");
2447+
assert(isa_and_nonnull<llvm::DIScope>(Scope) && "variable has no scope");
24492448
llvm::DIFile *Unit = getFile(Scope);
24502449
llvm::DIType *DITy = getOrCreateType(DbgTy);
24512450
assert(DITy && "could not determine debug type of variable");
@@ -2636,8 +2635,7 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
26362635
if (MetatypeType *metaTy = dyn_cast<MetatypeType>(ty))
26372636
ty = metaTy->getInstanceType().getPointer();
26382637
if (ty->getStructOrBoundGenericStruct() &&
2639-
ty->getStructOrBoundGenericStruct()->getClangDecl() &&
2640-
isa<clang::CXXRecordDecl>(
2638+
isa_and_nonnull<clang::CXXRecordDecl>(
26412639
ty->getStructOrBoundGenericStruct()->getClangDecl()))
26422640
return;
26432641
}

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,7 @@ class IRGenSILFunction :
10651065
if (MetatypeType *metaTy = dyn_cast<MetatypeType>(ty))
10661066
ty = metaTy->getRootClass().getPointer();
10671067
if (ty->getStructOrBoundGenericStruct() &&
1068-
ty->getStructOrBoundGenericStruct()->getClangDecl() &&
1069-
isa<clang::CXXRecordDecl>(
1068+
isa_and_nonnull<clang::CXXRecordDecl>(
10701069
ty->getStructOrBoundGenericStruct()->getClangDecl()))
10711070
return;
10721071
}
@@ -1709,7 +1708,7 @@ IRGenSILFunction::IRGenSILFunction(IRGenModule &IGM, SILFunction *f)
17091708
CurFn->addFnAttr(llvm::Attribute::SanitizeAddress);
17101709
if (IGM.IRGen.Opts.Sanitizers & SanitizerKind::Thread) {
17111710
auto declContext = f->getDeclContext();
1712-
if (declContext && isa<DestructorDecl>(declContext)) {
1711+
if (isa_and_nonnull<DestructorDecl>(declContext)) {
17131712
// Do not report races in deinit and anything called from it
17141713
// because TSan does not observe synchronization between retain
17151714
// count dropping to '0' and the object deinitialization.

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6906,7 +6906,7 @@ ParserResult<FuncDecl> Parser::parseDeclFunc(SourceLoc StaticLoc,
69066906
CurDeclContext);
69076907

69086908
// Let the source file track the opaque return type mapping, if any.
6909-
if (FuncRetTy && isa<OpaqueReturnTypeRepr>(FuncRetTy) &&
6909+
if (isa_and_nonnull<OpaqueReturnTypeRepr>(FuncRetTy) &&
69106910
!InInactiveClauseEnvironment) {
69116911
if (auto sf = CurDeclContext->getParentSourceFile()) {
69126912
sf->addUnvalidatedDeclWithOpaqueResultType(FD);
@@ -7773,7 +7773,7 @@ Parser::parseDeclSubscript(SourceLoc StaticLoc,
77737773
Subscript->getAttrs() = Attributes;
77747774

77757775
// Let the source file track the opaque return type mapping, if any.
7776-
if (ElementTy.get() && isa<OpaqueReturnTypeRepr>(ElementTy.get()) &&
7776+
if (isa_and_nonnull<OpaqueReturnTypeRepr>(ElementTy.get()) &&
77777777
!InInactiveClauseEnvironment) {
77787778
if (auto sf = CurDeclContext->getParentSourceFile()) {
77797779
sf->addUnvalidatedDeclWithOpaqueResultType(Subscript);

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4309,8 +4309,8 @@ TypeConverter::getLoweredFormalTypes(SILDeclRef constant,
43094309

43104310
// If this is a C++ constructor, don't add the metatype "self" parameter
43114311
// because we'll never use it and it will cause problems in IRGen.
4312-
if (constant.getDecl()->getClangDecl() &&
4313-
isa<clang::CXXConstructorDecl>(constant.getDecl()->getClangDecl())) {
4312+
if (isa_and_nonnull<clang::CXXConstructorDecl>(
4313+
constant.getDecl()->getClangDecl())) {
43144314
// But, make sure it is actually a metatype that we're not adding. If
43154315
// changes to the self parameter are made in the future, this logic may
43164316
// need to be updated.

lib/SILGen/SILGenApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ class Callee {
555555
};
556556

557557
// Remove the metatype "self" parameter by making this a static member.
558-
if (constant->getDecl()->getClangDecl() &&
559-
isa<clang::CXXConstructorDecl>(constant->getDecl()->getClangDecl()))
558+
if (isa_and_nonnull<clang::CXXConstructorDecl>(
559+
constant->getDecl()->getClangDecl()))
560560
result.foreign.self.setStatic();
561561

562562
return result;

lib/SILGen/SILGenConvert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ class ExistentialInitialization final : public SingleBufferInitialization {
594594
}
595595

596596
bool isInPlaceInitializationOfGlobal() const override {
597-
return existential && isa<GlobalAddrInst>(existential);
597+
return isa_and_nonnull<GlobalAddrInst>(existential);
598598
}
599599

600600
void finishInitialization(SILGenFunction &SGF) override {

lib/SILGen/SILGenLValue.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,8 +3138,7 @@ bool isCallToReplacedInDynamicReplacement(SILGenFunction &SGF,
31383138
bool &isObjCReplacementSelfCall);
31393139

31403140
static bool isCallToSelfOfCurrentFunction(SILGenFunction &SGF, LookupExpr *e) {
3141-
return SGF.FunctionDC->getAsDecl() &&
3142-
isa<AbstractFunctionDecl>(SGF.FunctionDC->getAsDecl()) &&
3141+
return isa_and_nonnull<AbstractFunctionDecl>(SGF.FunctionDC->getAsDecl()) &&
31433142
e->getBase()->isSelfExprOf(
31443143
cast<AbstractFunctionDecl>(SGF.FunctionDC->getAsDecl()), false);
31453144
}

lib/SILOptimizer/Mandatory/Differentiation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ emitDerivativeFunctionReference(
616616
context.emitNondifferentiabilityError(
617617
original, invoker, diag::autodiff_private_derivative_from_fragile,
618618
fragileKind,
619-
llvm::isa_and_nonnull<AbstractClosureExpr>(
619+
isa_and_nonnull<AbstractClosureExpr>(
620620
originalFRI->getLoc().getAsASTNode<Expr>()));
621621
return None;
622622
}

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
202202

203203
// If this is a C++ function template, get it's specialization for the given
204204
// substitution map and update the decl accordingly.
205-
if (decl->getClangDecl() &&
206-
isa<clang::FunctionTemplateDecl>(decl->getClangDecl())) {
205+
if (isa_and_nonnull<clang::FunctionTemplateDecl>(decl->getClangDecl())) {
207206
auto *newFn =
208207
decl->getASTContext()
209208
.getClangModuleLoader()

lib/Sema/CSDiagnostics.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,7 +3162,7 @@ void ContextualFailure::tryComputedPropertyFixIts() const {
31623162
auto *initExpr = PBD->getInit(i);
31633163
if (!VD->isStatic() &&
31643164
!VD->getAttrs().getAttribute<DynamicReplacementAttr>() &&
3165-
initExpr && isa<ClosureExpr>(initExpr)) {
3165+
isa_and_nonnull<ClosureExpr>(initExpr)) {
31663166
auto diag = emitDiagnostic(diag::extension_stored_property_fixit,
31673167
VD->getName());
31683168
diag.fixItRemove(PBD->getEqualLoc(i));
@@ -3956,7 +3956,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
39563956
if (!argExpr)
39573957
return false;
39583958
auto possibleApplyExpr = findParentExpr(expr);
3959-
return possibleApplyExpr && isa<ApplyExpr>(possibleApplyExpr);
3959+
return isa_and_nonnull<ApplyExpr>(possibleApplyExpr);
39603960
};
39613961

39623962
auto *initCall = findParentExpr(findParentExpr(ctorRef));
@@ -6924,14 +6924,14 @@ bool MissingContextualBaseInMemberRefFailure::diagnoseAsError() {
69246924
auto *parentExpr = findParentExpr(anchor);
69256925

69266926
// Look through immediate call of unresolved member (e.g., `.foo(0)`).
6927-
if (parentExpr && isa<CallExpr>(parentExpr))
6927+
if (isa_and_nonnull<CallExpr>(parentExpr))
69286928
parentExpr = findParentExpr(parentExpr);
69296929

69306930
// FIXME: We should probably look through the entire member chain so that
69316931
// something like `let _ = .foo().bar` gets the "no contextual type" error
69326932
// rather than the "Cannot infer contextual base" error.
69336933
UnresolvedMemberChainResultExpr *resultExpr = nullptr;
6934-
if (parentExpr && isa<UnresolvedMemberChainResultExpr>(parentExpr)) {
6934+
if (isa_and_nonnull<UnresolvedMemberChainResultExpr>(parentExpr)) {
69356935
resultExpr = cast<UnresolvedMemberChainResultExpr>(parentExpr);
69366936
parentExpr = findParentExpr(parentExpr);
69376937
}
@@ -7469,12 +7469,12 @@ bool MissingContextualTypeForNil::diagnoseAsError() {
74697469
// attempt any types for it.
74707470
auto *parentExpr = findParentExpr(expr);
74717471

7472-
while (parentExpr && isa<IdentityExpr>(parentExpr))
7472+
while (isa_and_nonnull<IdentityExpr>(parentExpr))
74737473
parentExpr = findParentExpr(parentExpr);
74747474

74757475
// In cases like `_ = nil?` AST would have `nil`
74767476
// wrapped in `BindOptionalExpr`.
7477-
if (parentExpr && isa<BindOptionalExpr>(parentExpr))
7477+
if (isa_and_nonnull<BindOptionalExpr>(parentExpr))
74787478
parentExpr = findParentExpr(parentExpr);
74797479

74807480
if (parentExpr) {

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
23182318

23192319
if (shouldAttemptFixes()) {
23202320
auto *anchor = locator.trySimplifyToExpr();
2321-
if (anchor && isa<ClosureExpr>(anchor) &&
2321+
if (isa_and_nonnull<ClosureExpr>(anchor) &&
23222322
isSingleTupleParam(ctx, func2Params) &&
23232323
canImplodeParams(func1Params)) {
23242324
auto *fix = AllowClosureParamDestructuring::create(

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5096,7 +5096,7 @@ ConstraintSystem::isConversionEphemeral(ConversionRestrictionKind conversion,
50965096
// For an instance member, the base must be an @lvalue struct type.
50975097
if (auto *lvt = simplifyType(getType(base))->getAs<LValueType>()) {
50985098
auto *nominal = lvt->getObjectType()->getAnyNominal();
5099-
if (nominal && isa<StructDecl>(nominal)) {
5099+
if (isa_and_nonnull<StructDecl>(nominal)) {
51005100
subExpr = base;
51015101
continue;
51025102
}

lib/Sema/MiscDiagnostics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
248248
// Void to _ then warn, because that is redundant.
249249
if (auto DAE = dyn_cast<DiscardAssignmentExpr>(destExpr)) {
250250
if (auto CE = dyn_cast<CallExpr>(AE->getSrc())) {
251-
if (CE->getCalledValue() && isa<FuncDecl>(CE->getCalledValue()) &&
251+
if (isa_and_nonnull<FuncDecl>(CE->getCalledValue()) &&
252252
CE->getType()->isVoid()) {
253253
Ctx.Diags
254254
.diagnose(DAE->getLoc(),
@@ -1427,7 +1427,7 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) {
14271427

14281428
// But silence the warning if the base was explicitly qualified.
14291429
auto parentAsExpr = Parent.getAsExpr();
1430-
if (parentAsExpr && isa<DotSyntaxBaseIgnoredExpr>(parentAsExpr))
1430+
if (isa_and_nonnull<DotSyntaxBaseIgnoredExpr>(parentAsExpr))
14311431
shouldDiagnose = false;
14321432

14331433
if (shouldDiagnose) {
@@ -4078,7 +4078,7 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
40784078

40794079
if (auto *apply = dyn_cast<ApplyExpr>(E)) {
40804080
auto *decl = apply->getCalledValue();
4081-
if (decl && isa<AbstractFunctionDecl>(decl))
4081+
if (isa_and_nonnull<AbstractFunctionDecl>(decl))
40824082
return decl;
40834083
}
40844084
return nullptr;

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2973,7 +2973,7 @@ void AttributeChecker::visitCustomAttr(CustomAttr *attr) {
29732973
if (isa<ParamDecl>(D)) {
29742974
// Check for unsupported declarations.
29752975
auto *context = D->getDeclContext()->getAsDecl();
2976-
if (context && isa<SubscriptDecl>(context)) {
2976+
if (isa_and_nonnull<SubscriptDecl>(context)) {
29772977
diagnose(attr->getLocation(),
29782978
diag::property_wrapper_param_not_supported,
29792979
context->getDescriptiveKind());

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,8 +1997,7 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
19971997

19981998
// Continue on to diagnose any argument label renames.
19991999

2000-
} else if (parsed.BaseName == "init" &&
2001-
call && isa<CallExpr>(call)) {
2000+
} else if (parsed.BaseName == "init" && isa_and_nonnull<CallExpr>(call)) {
20022001
// For initializers, replace with a "call" of the context type...but only
20032002
// if we know we're doing a call (rather than a first-class reference).
20042003
if (parsed.isMember()) {

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ namespace {
15911591
}
15921592
}
15931593

1594-
} else if (llvm::isa_and_nonnull<SelfApplyExpr>(context) &&
1594+
} else if (isa_and_nonnull<SelfApplyExpr>(context) &&
15951595
isa<AbstractFunctionDecl>(decl)) {
15961596
// actor-isolated non-isolated-self calls are implicitly async
15971597
// and thus OK.
@@ -1649,7 +1649,7 @@ namespace {
16491649
ValueDecl *decl = concDeclRef.getDecl();
16501650
ThrowsMarkingResult result = ThrowsMarkingResult::NotFound;
16511651

1652-
if (llvm::isa_and_nonnull<SelfApplyExpr>(context)) {
1652+
if (isa_and_nonnull<SelfApplyExpr>(context)) {
16531653
if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
16541654
if (func->isDistributed() && !func->hasThrows()) {
16551655
// A distributed function is implicitly throwing if called from

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ bool swift::isMemberOperator(FuncDecl *decl, Type type) {
19351935
auto selfNominal = DC->getSelfNominalTypeDecl();
19361936

19371937
// Check the parameters for a reference to 'Self'.
1938-
bool isProtocol = selfNominal && isa<ProtocolDecl>(selfNominal);
1938+
bool isProtocol = isa_and_nonnull<ProtocolDecl>(selfNominal);
19391939
for (auto param : *decl->getParameters()) {
19401940
// Look through a metatype reference, if there is one.
19411941
auto paramType = param->getInterfaceType()->getMetatypeInstanceType();

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
27772777
if (FD->getDeclContext()->isTypeContext()) {
27782778
if (FD->isOperator() && !isMemberOperator(FD, nullptr)) {
27792779
auto selfNominal = FD->getDeclContext()->getSelfNominalTypeDecl();
2780-
auto isProtocol = selfNominal && isa<ProtocolDecl>(selfNominal);
2780+
auto isProtocol = isa_and_nonnull<ProtocolDecl>(selfNominal);
27812781
// We did not find 'Self'. Complain.
27822782
FD->diagnose(diag::operator_in_unrelated_type,
27832783
FD->getDeclContext()->getDeclaredInterfaceType(), isProtocol,

lib/Sema/TypeCheckStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ void TypeChecker::checkIgnoredExpr(Expr *E) {
14221422
// Otherwise, complain. Start with more specific diagnostics.
14231423

14241424
// Diagnose unused constructor calls.
1425-
if (callee && isa<ConstructorDecl>(callee) && !call->isImplicit()) {
1425+
if (isa_and_nonnull<ConstructorDecl>(callee) && !call->isImplicit()) {
14261426
DE.diagnose(fn->getLoc(), diag::expression_unused_init_result,
14271427
callee->getDeclContext()->getDeclaredInterfaceType())
14281428
.highlight(call->getArg()->getSourceRange());

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3762,7 +3762,7 @@ TypeResolver::resolveCompositionType(CompositionTypeRepr *repr,
37623762
if (ty->hasError()) return ty;
37633763

37643764
auto nominalDecl = ty->getAnyNominal();
3765-
if (nominalDecl && isa<ClassDecl>(nominalDecl)) {
3765+
if (isa_and_nonnull<ClassDecl>(nominalDecl)) {
37663766
if (checkSuperclass(tyR->getStartLoc(), ty))
37673767
continue;
37683768

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6495,8 +6495,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
64956495
} else {
64966496
fatal(thirdOrError.takeError());
64976497
}
6498-
if (third &&
6499-
isa<TypeAliasDecl>(third) &&
6498+
if (isa_and_nonnull<TypeAliasDecl>(third) &&
65006499
third->getModuleContext() != getAssociatedModule() &&
65016500
!third->getDeclaredInterfaceType()->isEqual(second)) {
65026501
// Conservatively drop references to typealiases in other modules

0 commit comments

Comments
 (0)