https://github.com/code-pankaj updated https://github.com/llvm/llvm-project/pull/172001
>From d4ad60364f5c26ffded1e47ebf3e34adbe52a462 Mon Sep 17 00:00:00 2001 From: code-pankaj <[email protected]> Date: Fri, 12 Dec 2025 18:02:34 +0530 Subject: [PATCH] [clang] Fix crash in hasValidIntValue when comparison category type is missing (fixes #170015) Add a null check for `Record` in `ComparisonCategoryInfo::ValueInfo::hasValidIntValue` to avoid dereferencing a null `CXXRecordDecl` when the comparison category types (such as `std::partial_ordering`) are missing, incomplete, or malformed. Previously, this caused a crash in both freestanding (`-nostdinc++`) and normal configurations when <compare> is unavailable or inconsistent. --- clang/lib/AST/ComparisonCategories.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/AST/ComparisonCategories.cpp b/clang/lib/AST/ComparisonCategories.cpp index 1b9c938e2ace3..431d6f77bc0a0 100644 --- a/clang/lib/AST/ComparisonCategories.cpp +++ b/clang/lib/AST/ComparisonCategories.cpp @@ -49,7 +49,7 @@ bool ComparisonCategoryInfo::ValueInfo::hasValidIntValue() const { // Before we attempt to get the value of the first field, ensure that we // actually have one (and only one) field. const auto *Record = VD->getType()->getAsCXXRecordDecl(); - if (Record->getNumFields() != 1 || + if (!Record || Record->getNumFields() != 1 || !Record->field_begin()->getType()->isIntegralOrEnumerationType()) return false; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
