From ef865d16ec3b8ce636786ed472ac28c977f2f304 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 17 Mar 2022 15:15:08 +0000 Subject: [PATCH] [clang] AddObjCKeyValueCompletions - use castAs<> instead of getAs<> to avoid dereference of nullptr The pointers are always dereferenced, so assert the cast is correct instead of returning nullptr --- clang/lib/Sema/SemaCodeComplete.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 0c9bcf5..ba99f18 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -9138,8 +9138,8 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, if (IsInstanceMethod && (ReturnType.isNull() || (ReturnType->isObjCObjectPointerType() && - ReturnType->getAs()->getInterfaceDecl() && - ReturnType->getAs() + ReturnType->castAs()->getInterfaceDecl() && + ReturnType->castAs() ->getInterfaceDecl() ->getName() == "NSEnumerator"))) { std::string SelectorName = (Twine("enumeratorOf") + UpperKey).str(); -- 2.7.4