forked from OSchip/llvm-project
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.
This commit is contained in:
parent
93431f96a7
commit
bf03944d5d
|
@ -4806,7 +4806,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add properties from the protocols in a qualified interface.
|
// Add properties from the protocols in a qualified interface.
|
||||||
for (auto *I : BaseType->getAs<ObjCObjectPointerType>()->quals())
|
for (auto *I : BaseType->castAs<ObjCObjectPointerType>()->quals())
|
||||||
AddObjCProperties(CCContext, I, true, /*AllowNullaryMethods=*/true,
|
AddObjCProperties(CCContext, I, true, /*AllowNullaryMethods=*/true,
|
||||||
CurContext, AddedProperties, Results,
|
CurContext, AddedProperties, Results,
|
||||||
IsBaseExprStatement, /*IsClassProperty*/ false,
|
IsBaseExprStatement, /*IsClassProperty*/ false,
|
||||||
|
@ -4819,7 +4819,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
|
||||||
BaseType->getAs<ObjCObjectPointerType>())
|
BaseType->getAs<ObjCObjectPointerType>())
|
||||||
Class = ObjCPtr->getInterfaceDecl();
|
Class = ObjCPtr->getInterfaceDecl();
|
||||||
else
|
else
|
||||||
Class = BaseType->getAs<ObjCObjectType>()->getInterface();
|
Class = BaseType->castAs<ObjCObjectType>()->getInterface();
|
||||||
|
|
||||||
// Add all ivars from this class and its superclasses.
|
// Add all ivars from this class and its superclasses.
|
||||||
if (Class) {
|
if (Class) {
|
||||||
|
@ -7743,8 +7743,8 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
|
||||||
if (IsInstanceMethod &&
|
if (IsInstanceMethod &&
|
||||||
(ReturnType.isNull() ||
|
(ReturnType.isNull() ||
|
||||||
(ReturnType->isObjCObjectPointerType() &&
|
(ReturnType->isObjCObjectPointerType() &&
|
||||||
ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() &&
|
ReturnType->castAs<ObjCObjectPointerType>()->getInterfaceDecl() &&
|
||||||
ReturnType->getAs<ObjCObjectPointerType>()
|
ReturnType->castAs<ObjCObjectPointerType>()
|
||||||
->getInterfaceDecl()
|
->getInterfaceDecl()
|
||||||
->getName() == "NSArray"))) {
|
->getName() == "NSArray"))) {
|
||||||
std::string SelectorName = (Twine(Property->getName()) + "AtIndexes").str();
|
std::string SelectorName = (Twine(Property->getName()) + "AtIndexes").str();
|
||||||
|
@ -8130,8 +8130,8 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
|
||||||
if (!IsInstanceMethod &&
|
if (!IsInstanceMethod &&
|
||||||
(ReturnType.isNull() ||
|
(ReturnType.isNull() ||
|
||||||
(ReturnType->isObjCObjectPointerType() &&
|
(ReturnType->isObjCObjectPointerType() &&
|
||||||
ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() &&
|
ReturnType->castAs<ObjCObjectPointerType>()->getInterfaceDecl() &&
|
||||||
ReturnType->getAs<ObjCObjectPointerType>()
|
ReturnType->castAs<ObjCObjectPointerType>()
|
||||||
->getInterfaceDecl()
|
->getInterfaceDecl()
|
||||||
->getName() == "NSSet"))) {
|
->getName() == "NSSet"))) {
|
||||||
std::string SelectorName =
|
std::string SelectorName =
|
||||||
|
|
Loading…
Reference in New Issue