[clang-tools-extra] ea48d14 - [Clangd] [NFC] Fix dereference of null value (#159566)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 18 10:25:19 PDT 2025
Author: Zahira Ammarguellat
Date: 2025-09-18T13:25:15-04:00
New Revision: ea48d14faff82beea4181b72986c72a8929a3186
URL: https://github.com/llvm/llvm-project/commit/ea48d14faff82beea4181b72986c72a8929a3186
DIFF: https://github.com/llvm/llvm-project/commit/ea48d14faff82beea4181b72986c72a8929a3186.diff
LOG: [Clangd] [NFC] Fix dereference of null value (#159566)
This is a find from static analysis tool complaining about potential
dereference of `nullptr` for `RD`.
Added:
Modified:
clang-tools-extra/clangd/AST.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index b96a84519e78c..0dcff2eae05e7 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -147,7 +147,8 @@ std::string getQualification(ASTContext &Context,
if (auto *TD = llvm::dyn_cast<TagDecl>(CurD)) {
QualType T;
if (const auto *RD = dyn_cast<CXXRecordDecl>(TD);
- ClassTemplateDecl *CTD = RD->getDescribedClassTemplate()) {
+ ClassTemplateDecl *CTD =
+ RD ? RD->getDescribedClassTemplate() : nullptr) {
ArrayRef<TemplateArgument> Args;
if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
Args = SD->getTemplateArgs().asArray();
More information about the cfe-commits
mailing list