[clang] [Clang] Added nullptr check to getFriendDecl access (PR #121056)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 24 07:24:05 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (GrumpyPigSkin)
<details>
<summary>Changes</summary>
fixes: #<!-- -->120857 where a `nullptr` access was causing a crash.
@<!-- -->shafik please can you review.
---
Full diff: https://github.com/llvm/llvm-project/pull/121056.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+3-2)
``````````diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc9..64b1fb28e2e184 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -8871,8 +8871,9 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD,
return true;
if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
- return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+ if (NamedDecl* Ffd = F->getFriendDecl())
+ return FD->getCanonicalDecl() == Ffd->getCanonicalDecl();
+ return false;
})) {
Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
<< int(DCK) << int(0) << RD;
``````````
</details>
https://github.com/llvm/llvm-project/pull/121056
More information about the cfe-commits
mailing list