Author: Timm Baeder Date: 2026-01-02T11:59:24+01:00 New Revision: 508e3cb7e75654a4ea0f4aaed2afa78b5b865342
URL: https://github.com/llvm/llvm-project/commit/508e3cb7e75654a4ea0f4aaed2afa78b5b865342 DIFF: https://github.com/llvm/llvm-project/commit/508e3cb7e75654a4ea0f4aaed2afa78b5b865342.diff LOG: [clang][bytecode] Check for null Record (#174193) This is an error case that results in a null Record, so don't crash later in that case. Fixes #173941 Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/AST/ByteCode/cxx03.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 4daab0702f147..67980676dcd30 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3258,6 +3258,8 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) { bool ZeroInit = E->requiresZeroInitialization(); if (ZeroInit) { const Record *R = getRecord(E->getType()); + if (!R) + return false; if (!this->visitZeroRecordInitializer(R, E)) return false; diff --git a/clang/test/AST/ByteCode/cxx03.cpp b/clang/test/AST/ByteCode/cxx03.cpp index 58d7f3632082d..ff81ed04e8334 100644 --- a/clang/test/AST/ByteCode/cxx03.cpp +++ b/clang/test/AST/ByteCode/cxx03.cpp @@ -46,3 +46,13 @@ struct S { vi4b w; }; const int s = S().w[1]; + +namespace NullRecord { + struct S { + int arr[1024 * 1024 * 1024]; + s = {1, {2}}; // both-error {{a type specifier is required for all declarations}} \ + // both-warning {{default member initializer for non-static data member is a C++11 extension}} + }; + + S s[2] = {}; +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
