[clang] 35bfbb3 - [clang][AST] createNestedNameSpecifierForScopeOf - don't use dyn_cast_or_null on never null DC argument
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 21 09:42:39 PDT 2024
Author: Simon Pilgrim
Date: 2024-06-21T17:42:00+01:00
New Revision: 35bfbb3b21e9874d03b730e8ce4eb98b1dcd2d28
URL: https://github.com/llvm/llvm-project/commit/35bfbb3b21e9874d03b730e8ce4eb98b1dcd2d28
DIFF: https://github.com/llvm/llvm-project/commit/35bfbb3b21e9874d03b730e8ce4eb98b1dcd2d28.diff
LOG: [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.
Added:
Modified:
clang/lib/AST/QualTypeNames.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index 18ac4b1eb57e7..4e1243ef79e87 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -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 =
More information about the cfe-commits
mailing list