[PATCH] D152140: [Clang] Limit FunctionTypeExtraBitfields::NumExceptionType to 16 bits.
Sander de Smalen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 5 07:24:11 PDT 2023
sdesmalen updated this revision to Diff 528433.
sdesmalen added a comment.
Use size_t instead of auto.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152140/new/
https://reviews.llvm.org/D152140
Files:
clang/include/clang/AST/Type.h
clang/lib/AST/Type.cpp
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3371,7 +3371,10 @@
// Fill in the exception type array if present.
if (getExceptionSpecType() == EST_Dynamic) {
auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
- ExtraBits.NumExceptionType = epi.ExceptionSpec.Exceptions.size();
+ size_t NumExceptions = epi.ExceptionSpec.Exceptions.size();
+ assert(NumExceptions <= UINT16_MAX &&
+ "Not enough bits to encode exceptions");
+ ExtraBits.NumExceptionType = NumExceptions;
assert(hasExtraBitfields() && "missing trailing extra bitfields!");
auto *exnSlot =
Index: clang/include/clang/AST/Type.h
===================================================================
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3953,7 +3953,7 @@
/// The number of types in the exception specification.
/// A whole unsigned is not needed here and according to
/// [implimits] 8 bits would be enough here.
- unsigned NumExceptionType = 0;
+ uint16_t NumExceptionType = 0;
};
protected:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152140.528433.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230605/a3add616/attachment.bin>
More information about the cfe-commits
mailing list