Skip to content

Commit 35bfbb3

Browse files
committed
[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.
1 parent 6a69cfb commit 35bfbb3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/AST/QualTypeNames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ static NestedNameSpecifier *createNestedNameSpecifierForScopeOf(
270270
assert(Decl);
271271

272272
const DeclContext *DC = Decl->getDeclContext()->getRedeclContext();
273-
const auto *Outer = dyn_cast_or_null<NamedDecl>(DC);
274-
const auto *OuterNS = dyn_cast_or_null<NamespaceDecl>(DC);
273+
const auto *Outer = dyn_cast<NamedDecl>(DC);
274+
const auto *OuterNS = dyn_cast<NamespaceDecl>(DC);
275275
if (Outer && !(OuterNS && OuterNS->isAnonymousNamespace())) {
276276
if (const auto *CxxDecl = dyn_cast<CXXRecordDecl>(DC)) {
277277
if (ClassTemplateDecl *ClassTempl =

0 commit comments

Comments
 (0)