From 7323d07483f201b2d73009deef45d2eff4dcd856 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 4 Nov 2021 14:49:58 +0100 Subject: [PATCH] [lldb][NFC] Remove a bunch of unnecessary nullptr checks Those nullptr checks are after we already accessed the pointer. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D113175 --- .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 49 +++++++++------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index bb57d53..e9c45f1 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1327,19 +1327,16 @@ CompilerType TypeSystemClang::CreateRecordType( decl->setAnonymousStructOrUnion(true); } - if (decl) { - if (metadata) - SetMetadata(decl, *metadata); + if (metadata) + SetMetadata(decl, *metadata); - if (access_type != eAccessNone) - decl->setAccess(ConvertAccessTypeToAccessSpecifier(access_type)); + if (access_type != eAccessNone) + decl->setAccess(ConvertAccessTypeToAccessSpecifier(access_type)); - if (decl_ctx) - decl_ctx->addDecl(decl); + if (decl_ctx) + decl_ctx->addDecl(decl); - return GetType(ast.getTagDeclType(decl)); - } - return CompilerType(); + return GetType(ast.getTagDeclType(decl)); } namespace { @@ -1605,15 +1602,13 @@ ClassTemplateDecl *TypeSystemClang::CreateClassTemplateDecl( template_cxx_decl->setDescribedClassTemplate(class_template_decl); SetOwningModule(class_template_decl, owning_module); - if (class_template_decl) { - if (access_type != eAccessNone) - class_template_decl->setAccess( - ConvertAccessTypeToAccessSpecifier(access_type)); + if (access_type != eAccessNone) + class_template_decl->setAccess( + ConvertAccessTypeToAccessSpecifier(access_type)); - decl_ctx->addDecl(class_template_decl); + decl_ctx->addDecl(class_template_decl); - VerifyDecl(class_template_decl); - } + VerifyDecl(class_template_decl); return class_template_decl; } @@ -1803,7 +1798,7 @@ CompilerType TypeSystemClang::CreateObjCClass( decl->setImplicit(isInternal); SetOwningModule(decl, owning_module); - if (decl && metadata) + if (metadata) SetMetadata(decl, *metadata); return GetType(ast.getObjCInterfaceType(decl)); @@ -2141,8 +2136,7 @@ FunctionDecl *TypeSystemClang::CreateFunctionDeclaration( ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified); SetOwningModule(func_decl, owning_module); - if (func_decl) - decl_ctx->addDecl(func_decl); + decl_ctx->addDecl(func_decl); VerifyDecl(func_decl); @@ -2305,18 +2299,15 @@ CompilerType TypeSystemClang::CreateEnumerationType( enum_decl->setScopedUsingClassTag(is_scoped); enum_decl->setFixed(false); SetOwningModule(enum_decl, owning_module); - if (enum_decl) { - if (decl_ctx) - decl_ctx->addDecl(enum_decl); + if (decl_ctx) + decl_ctx->addDecl(enum_decl); - // TODO: check if we should be setting the promotion type too? - enum_decl->setIntegerType(ClangUtil::GetQualType(integer_clang_type)); + // TODO: check if we should be setting the promotion type too? + enum_decl->setIntegerType(ClangUtil::GetQualType(integer_clang_type)); - enum_decl->setAccess(AS_public); // TODO respect what's in the debug info + enum_decl->setAccess(AS_public); // TODO respect what's in the debug info - return GetType(ast.getTagDeclType(enum_decl)); - } - return CompilerType(); + return GetType(ast.getTagDeclType(enum_decl)); } CompilerType TypeSystemClang::GetIntTypeFromBitSize(size_t bit_size, -- 2.7.4