From bf03944d5d9a7e7c8105c69dfa0d7e0d345644df Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 11 Jan 2020 16:01:46 +0000 Subject: [PATCH] Fix "pointer is null" static analyzer warnings. NFCI. Use castAs<> instead of getAs<> since the pointers are dereferenced immediately and castAs will perform the null assertion for us. --- clang/lib/Sema/SemaCodeComplete.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 0f2434fc0a23..e14c63d557ad 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -4806,7 +4806,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, } // Add properties from the protocols in a qualified interface. - for (auto *I : BaseType->getAs()->quals()) + for (auto *I : BaseType->castAs()->quals()) AddObjCProperties(CCContext, I, true, /*AllowNullaryMethods=*/true, CurContext, AddedProperties, Results, IsBaseExprStatement, /*IsClassProperty*/ false, @@ -4819,7 +4819,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, BaseType->getAs()) Class = ObjCPtr->getInterfaceDecl(); else - Class = BaseType->getAs()->getInterface(); + Class = BaseType->castAs()->getInterface(); // Add all ivars from this class and its superclasses. if (Class) { @@ -7743,8 +7743,8 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, if (IsInstanceMethod && (ReturnType.isNull() || (ReturnType->isObjCObjectPointerType() && - ReturnType->getAs()->getInterfaceDecl() && - ReturnType->getAs() + ReturnType->castAs()->getInterfaceDecl() && + ReturnType->castAs() ->getInterfaceDecl() ->getName() == "NSArray"))) { std::string SelectorName = (Twine(Property->getName()) + "AtIndexes").str(); @@ -8130,8 +8130,8 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, if (!IsInstanceMethod && (ReturnType.isNull() || (ReturnType->isObjCObjectPointerType() && - ReturnType->getAs()->getInterfaceDecl() && - ReturnType->getAs() + ReturnType->castAs()->getInterfaceDecl() && + ReturnType->castAs() ->getInterfaceDecl() ->getName() == "NSSet"))) { std::string SelectorName =