[clang-tools-extra] [Clangd] [NFC] Fix dereference of null value (PR #159566)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 18 09:15:18 PDT 2025
================
@@ -145,8 +145,11 @@ std::string getQualification(ASTContext &Context,
for (const auto *CurD : llvm::reverse(Parents)) {
if (auto *TD = llvm::dyn_cast<TagDecl>(CurD)) {
QualType T;
- if (const auto *RD = dyn_cast<CXXRecordDecl>(TD);
- ClassTemplateDecl *CTD = RD->getDescribedClassTemplate()) {
+ const auto *RD = dyn_cast<CXXRecordDecl>(TD);
+ ClassTemplateDecl *CTD = nullptr;
+ if (RD)
+ CTD = RD->getDescribedClassTemplate();
+ if (RD && CTD) {
----------------
zahiraam wrote:
I wasn't able to convince myself that `RD` is always a `CXXRecordDecl`. The new code with your suggestion is safer.
https://github.com/llvm/llvm-project/pull/159566
More information about the cfe-commits
mailing list