Skip to content

Commit ea48d14

Browse files
authored
[Clangd] [NFC] Fix dereference of null value (#159566)
This is a find from static analysis tool complaining about potential dereference of `nullptr` for `RD`.
1 parent b7f0bb9 commit ea48d14

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang-tools-extra/clangd/AST.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ std::string getQualification(ASTContext &Context,
147147
if (auto *TD = llvm::dyn_cast<TagDecl>(CurD)) {
148148
QualType T;
149149
if (const auto *RD = dyn_cast<CXXRecordDecl>(TD);
150-
ClassTemplateDecl *CTD = RD->getDescribedClassTemplate()) {
150+
ClassTemplateDecl *CTD =
151+
RD ? RD->getDescribedClassTemplate() : nullptr) {
151152
ArrayRef<TemplateArgument> Args;
152153
if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
153154
Args = SD->getTemplateArgs().asArray();

0 commit comments

Comments
 (0)