[PATCH] D152140: [Clang] Limit FunctionTypeExtraBitfields::NumExceptionType to 16 bits.

Sander de Smalen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 6 05:08:11 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7013a751f170: [Clang] Limit FunctionTypeExtraBitfields::NumExceptionType to 16 bits. (authored by sdesmalen).

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.528804.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230606/e1b9b88d/attachment.bin>


More information about the cfe-commits mailing list