Skip to content

Commit 7323d07

Browse files
committed
[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
1 parent b8b6a5b commit 7323d07

File tree

1 file changed

+20
-29
lines changed

1 file changed

+20
-29
lines changed

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,19 +1327,16 @@ CompilerType TypeSystemClang::CreateRecordType(
13271327
decl->setAnonymousStructOrUnion(true);
13281328
}
13291329

1330-
if (decl) {
1331-
if (metadata)
1332-
SetMetadata(decl, *metadata);
1330+
if (metadata)
1331+
SetMetadata(decl, *metadata);
13331332

1334-
if (access_type != eAccessNone)
1335-
decl->setAccess(ConvertAccessTypeToAccessSpecifier(access_type));
1333+
if (access_type != eAccessNone)
1334+
decl->setAccess(ConvertAccessTypeToAccessSpecifier(access_type));
13361335

1337-
if (decl_ctx)
1338-
decl_ctx->addDecl(decl);
1336+
if (decl_ctx)
1337+
decl_ctx->addDecl(decl);
13391338

1340-
return GetType(ast.getTagDeclType(decl));
1341-
}
1342-
return CompilerType();
1339+
return GetType(ast.getTagDeclType(decl));
13431340
}
13441341

13451342
namespace {
@@ -1605,15 +1602,13 @@ ClassTemplateDecl *TypeSystemClang::CreateClassTemplateDecl(
16051602
template_cxx_decl->setDescribedClassTemplate(class_template_decl);
16061603
SetOwningModule(class_template_decl, owning_module);
16071604

1608-
if (class_template_decl) {
1609-
if (access_type != eAccessNone)
1610-
class_template_decl->setAccess(
1611-
ConvertAccessTypeToAccessSpecifier(access_type));
1605+
if (access_type != eAccessNone)
1606+
class_template_decl->setAccess(
1607+
ConvertAccessTypeToAccessSpecifier(access_type));
16121608

1613-
decl_ctx->addDecl(class_template_decl);
1609+
decl_ctx->addDecl(class_template_decl);
16141610

1615-
VerifyDecl(class_template_decl);
1616-
}
1611+
VerifyDecl(class_template_decl);
16171612

16181613
return class_template_decl;
16191614
}
@@ -1803,7 +1798,7 @@ CompilerType TypeSystemClang::CreateObjCClass(
18031798
decl->setImplicit(isInternal);
18041799
SetOwningModule(decl, owning_module);
18051800

1806-
if (decl && metadata)
1801+
if (metadata)
18071802
SetMetadata(decl, *metadata);
18081803

18091804
return GetType(ast.getObjCInterfaceType(decl));
@@ -2141,8 +2136,7 @@ FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(
21412136
? ConstexprSpecKind::Constexpr
21422137
: ConstexprSpecKind::Unspecified);
21432138
SetOwningModule(func_decl, owning_module);
2144-
if (func_decl)
2145-
decl_ctx->addDecl(func_decl);
2139+
decl_ctx->addDecl(func_decl);
21462140

21472141
VerifyDecl(func_decl);
21482142

@@ -2305,18 +2299,15 @@ CompilerType TypeSystemClang::CreateEnumerationType(
23052299
enum_decl->setScopedUsingClassTag(is_scoped);
23062300
enum_decl->setFixed(false);
23072301
SetOwningModule(enum_decl, owning_module);
2308-
if (enum_decl) {
2309-
if (decl_ctx)
2310-
decl_ctx->addDecl(enum_decl);
2302+
if (decl_ctx)
2303+
decl_ctx->addDecl(enum_decl);
23112304

2312-
// TODO: check if we should be setting the promotion type too?
2313-
enum_decl->setIntegerType(ClangUtil::GetQualType(integer_clang_type));
2305+
// TODO: check if we should be setting the promotion type too?
2306+
enum_decl->setIntegerType(ClangUtil::GetQualType(integer_clang_type));
23142307

2315-
enum_decl->setAccess(AS_public); // TODO respect what's in the debug info
2308+
enum_decl->setAccess(AS_public); // TODO respect what's in the debug info
23162309

2317-
return GetType(ast.getTagDeclType(enum_decl));
2318-
}
2319-
return CompilerType();
2310+
return GetType(ast.getTagDeclType(enum_decl));
23202311
}
23212312

23222313
CompilerType TypeSystemClang::GetIntTypeFromBitSize(size_t bit_size,

0 commit comments

Comments
 (0)