From 185f5e7b2c1917c293186014567cb5cecf80890e Mon Sep 17 00:00:00 2001 From: Mike Rice Date: Thu, 25 Jul 2024 08:03:16 -0700 Subject: [PATCH] [clang][NFC] remove unneeded nullptr checks after dereference (#100489) Summary: Fix static verifer concerns of null pointer checks after dereferencing the pointer. Update the assert to make it super clear it is not null and remove the checks. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250760 --- clang/lib/Sema/SemaDeclCXX.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 04b8d88cae217b..1cca8ac9b93431 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -12248,16 +12248,15 @@ Decl *Sema::ActOnUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS) { - assert(!SS->isInvalid() && "ScopeSpec is invalid"); + assert(SS && !SS->isInvalid() && "ScopeSpec is invalid"); TypeSourceInfo *TSI = nullptr; SourceLocation IdentLoc = TyLoc.getBegin(); QualType EnumTy = GetTypeFromParser(Ty, &TSI); if (EnumTy.isNull()) { - Diag(IdentLoc, SS && isDependentScopeSpecifier(*SS) + Diag(IdentLoc, isDependentScopeSpecifier(*SS) ? diag::err_using_enum_is_dependent : diag::err_unknown_typename) - << II.getName() - << SourceRange(SS ? SS->getBeginLoc() : IdentLoc, TyLoc.getEnd()); + << II.getName() << SourceRange(SS->getBeginLoc(), TyLoc.getEnd()); return nullptr; }