Author: Shafik Yaghmour Date: 2025-06-09T14:28:47-07:00 New Revision: 28b753b185511eaaf98c5dda39bf9e44fa134212
URL: https://github.com/llvm/llvm-project/commit/28b753b185511eaaf98c5dda39bf9e44fa134212 DIFF: https://github.com/llvm/llvm-project/commit/28b753b185511eaaf98c5dda39bf9e44fa134212.diff LOG: [Clang][NFC] Add nullptr check in InitializationSequence::InitializeFrom (#143067) Static analysis flagged that Var could be nullptr but we were not checking in the branch and unconditionally dereferences the pointer. Note, code was added by 576161cb6069 Added: Modified: clang/lib/Sema/SemaInit.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 5d870f07093ec..da56225b2f926 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -6620,7 +6620,7 @@ void InitializationSequence::InitializeFrom(Sema &S, // initializer present. However, we only do this for structure types, not // union types, because an unitialized field in a union is generally // reasonable, especially in C where unions can be used for type punning. - if (!Initializer && !Rec->isUnion() && !Rec->isInvalidDecl()) { + if (Var && !Initializer && !Rec->isUnion() && !Rec->isInvalidDecl()) { if (const FieldDecl *FD = getConstField(Rec)) { unsigned DiagID = diag::warn_default_init_const_field_unsafe; if (Var->getStorageDuration() == SD_Static || _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits