[clang][AST] createNestedNameSpecifierForScopeOf - don't use dyn_cast_or_null on never null DC argument

Fixes static analysis warning about later dereferencing the DC variable which might have been null (assumed due to dyn_cast_or_null) - getRedeclContext shouldn't ever return a null value so safe to use dyn_cast instead.
This commit is contained in:
Simon Pilgrim 2024-06-21 16:41:31 +01:00
parent 6a69cfb607
commit 35bfbb3b21

View File

@ -270,8 +270,8 @@ static NestedNameSpecifier *createNestedNameSpecifierForScopeOf(
assert(Decl);
const DeclContext *DC = Decl->getDeclContext()->getRedeclContext();
const auto *Outer = dyn_cast_or_null<NamedDecl>(DC);
const auto *OuterNS = dyn_cast_or_null<NamespaceDecl>(DC);
const auto *Outer = dyn_cast<NamedDecl>(DC);
const auto *OuterNS = dyn_cast<NamespaceDecl>(DC);
if (Outer && !(OuterNS && OuterNS->isAnonymousNamespace())) {
if (const auto *CxxDecl = dyn_cast<CXXRecordDecl>(DC)) {
if (ClassTemplateDecl *ClassTempl =