[PATCH] D152429: [Clang][Type] Add static assertion to guard future expansion for BuiltinType numbering
Yueh-Ting (eop) Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 8 09:37:17 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8feb84236023: [Clang][Type] Add static assertion to guard future expansion for BuiltinType… (authored by eopXD).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152429/new/
https://reviews.llvm.org/D152429
Files:
clang/include/clang/AST/Type.h
Index: clang/include/clang/AST/Type.h
===================================================================
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1649,7 +1649,8 @@
unsigned : NumTypeBits;
/// The kind (BuiltinType::Kind) of builtin type this is.
- unsigned Kind : 8;
+ static constexpr unsigned NumOfBuiltinTypeBits = 8;
+ unsigned Kind : NumOfBuiltinTypeBits;
};
/// FunctionTypeBitfields store various bits belonging to FunctionProtoType.
@@ -2677,6 +2678,10 @@
: Type(Builtin, QualType(),
K == Dependent ? TypeDependence::DependentInstantiation
: TypeDependence::None) {
+ static_assert(Kind::LastKind <
+ (1 << BuiltinTypeBitfields::NumOfBuiltinTypeBits) &&
+ "Defined builtin type exceeds the allocated space for serial "
+ "numbering");
BuiltinTypeBits.Kind = K;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152429.529638.patch
Type: text/x-patch
Size: 952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230608/184d3a11/attachment-0001.bin>
More information about the cfe-commits
mailing list