summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Ricci <riccibrun@gmail.com>2018-08-13 16:40:57 +0000
committerBruno Ricci <riccibrun@gmail.com>2018-08-13 16:40:57 +0000
commit4e34c65ffd9bc6c4a81c50ee5fe0e6f095f9022d (patch)
tree8deab245219f9a3f26eb61862db03b48f52ae1b5
parent1aaf524ea1fd9337b55534ade2d37cc2af4eb3c5 (diff)
downloadbcm5719-llvm-4e34c65ffd9bc6c4a81c50ee5fe0e6f095f9022d.tar.gz
bcm5719-llvm-4e34c65ffd9bc6c4a81c50ee5fe0e6f095f9022d.zip
[AST] Update/correct the static_asserts for the bit-fields in Type
The current static_assert only checks that ObjCObjectTypeBitfields fits into an unsigned. However it turns out that FunctionTypeBitfields do not currently fits into an unsigned. Therefore the anonymous union containing the bit-fields always use 8 bytes instead of 4. This patch removes the lone misguided static_assert and systematically checks the size of each bit-field. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D50630 llvm-svn: 339582
-rw-r--r--clang/include/clang/AST/Type.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index cda84b19fa9..93dafc47dd0 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1539,8 +1539,6 @@ protected:
unsigned IsKindOf : 1;
};
- static_assert(NumTypeBits + 7 + 6 + 1 <= 32, "Does not fit in an unsigned");
-
class ReferenceTypeBitfields {
friend class ReferenceType;
@@ -1619,6 +1617,27 @@ protected:
ReferenceTypeBitfields ReferenceTypeBits;
TypeWithKeywordBitfields TypeWithKeywordBits;
VectorTypeBitfields VectorTypeBits;
+
+ static_assert(sizeof(TypeBitfields) <= 8,
+ "TypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(ArrayTypeBitfields) <= 8,
+ "ArrayTypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(AttributedTypeBitfields) <= 8,
+ "AttributedTypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(AutoTypeBitfields) <= 8,
+ "AutoTypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(BuiltinTypeBitfields) <= 8,
+ "BuiltinTypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(FunctionTypeBitfields) <= 8,
+ "FunctionTypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(ObjCObjectTypeBitfields) <= 8,
+ "ObjCObjectTypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(ReferenceTypeBitfields) <= 8,
+ "ReferenceTypeBitfields is larger than 8 bytes!");
+ static_assert(sizeof(TypeWithKeywordBitfields) <= 8,
+ "TypeWithKeywordBitfields is larger than 8 bytes!");
+ static_assert(sizeof(VectorTypeBitfields) <= 8,
+ "VectorTypeBitfields is larger than 8 bytes!");
};
private:
OpenPOWER on IntegriCloud