sdesmalen updated this revision to Diff 528431. sdesmalen added a comment. Use uint16_t instead of unsigned bitfield. Also removed accessor methods in favour of assert at point of writing NumExceptionType.
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(); + auto 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:
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(); + auto 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:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits